Re: USB Bluetooth dongle stop response with timeout error

2018-10-30 Thread Morikazu Fumita

On 30/10/2018 5:15 PM, Oliver Neukum wrote:

On Sa, 2018-10-27 at 22:56 +0800, Morikazu Fumita wrote:

I always found error messages of
"Bluetooth: hci0: command 0x0406 tx timeout" and

The problem is likely shortly before that.


"dwc2 ffb4.usb: --Host Channel x Interrupt: Frame Overrun--"
when this problem is happening.

Here's an example log:
[  251.748320] pan: port 1(bnep0) entered disabled state
[  251.752153] device bnep0 left promiscuous mode
[  251.754541] pan: port 1(bnep0) entered disabled state
[  257.879162] Bluetooth: hci0: command 0x0406 tx timeout
Oct 25 04:47:14 cyclone5 systemd-networkd[132]: bnep0: Lost carrier
Oct 25 04:47:14 cyclone5 kernel: pan: port 1(bnep0) entered disabled state
Oct 25 04:47:14 cyclone5 kernel: dwc2 ffb4.usb: --Host Channel 15
Interrupt: Frame Overrun--

You need to find out under which circumstances the hang happens.
Is it always when leaving the promiscuous mode?

Regards
Oliver


Hello Oliver,

Thank you for your reply.

I narrowed the problem down a little bit.
This problem seems to happen after the virtual network interface which 
is added

by Bluez for PAN-NAP service is down.
Turning promiscuous mode OFF is not the cause of the issue.

My test procedure is below (assuming Bluetooth devices are already paired).

1. Adding a network bridge for PAN using "brctl".
2. Link the bridge up.
3. Run "hciconfig hci0 up" to power the USB Bluetooth dongle up.
4. Register "nap" service and the network bridge to 
"org.bluez.NetworkServer1"

via d-bus using a Python script.
5. Bluez makes "bnep0" virtual network interface automatically.
6. Connect to the PAN-NAP server from the client. Network is working 
fine at

this point.
(Note: The hang does not happen even if turning promiscuous mode off at 
this

point by running "ip link set bnep0 promisc off")
7. Disconnect PAN from the client or make the "bnep0" virtual network 
adapter

down by running "ip link set bnep0 down".
8. The hang happens with "Bluetooth: hci0: command 0x tx timeout" 
errors.

9. No response from the USB Bluetooth dongle anymore.
For example, running "discoverable on" from "bluetoothctl" fails with error
message of "Failed to set discoverable on: org.bluez.Error.Failed".
The timeout error is logged in "dmesg" as well.

 From this fact, I believe this issue is related to Bluez but not to USB.
What do you think?


This is the log from the USB Bluetooth dongle is detected and PAN-NAP is 
started

to the timeout happened.

[  705.813455] usb 1-1: new full-speed USB device number 2 using dwc2
[  706.027240] usb 1-1: New USB device found, idVendor=0a12, 
idProduct=0001,

bcdDevice= 1.00
[  706.031407] usb 1-1: New USB device strings: Mfr=1, Product=2, 
SerialNumber=0

[  706.035859] usb 1-1: Product: Bluetooth V2.0 Dongle
[  706.038304] usb 1-1: Manufacturer: Allcom Corp
[  706.041282] device: '1-1': device_add
[  706.041388] bus: 'usb': add device 1-1
[  706.041426] PM: Adding info for usb:1-1
[  706.043371] bus: 'usb': driver_probe_device: matched device 1-1 with 
driver usb

[  706.043389] bus: 'usb': really_probe: probing driver usb with device 1-1
[  706.044501] usb 1-1: no default pinctrl state
[  706.044554] devices_kset: Moving 1-1 to end of list
[  706.044818] device: '1-1:1.0': device_add
[  706.044872] bus: 'usb': add device 1-1:1.0
[  706.044897] PM: Adding info for usb:1-1:1.0
[  706.045823] bus: 'usb': driver_probe_device: matched device 1-1:1.0 with
driver btusb
[  706.045841] bus: 'usb': really_probe: probing driver btusb with 
device 1-1:1.0

[  706.045861] btusb 1-1:1.0: no default pinctrl state
[  706.045891] devices_kset: Moving 1-1:1.0 to end of list
[  706.046024] device: 'hci0': device_add
[  706.046082] PM: Adding info for No Bus:hci0
[  706.046669] driver: 'btusb': driver_bound: bound to device '1-1:1.0'
[  706.047243] bus: 'usb': really_probe: bound device 1-1:1.0 to driver 
btusb

[  706.047273] device: 'ep_81': device_add
[  706.047340] PM: Adding info for No Bus:ep_81
[  706.047356] device: 'ep_82': device_add
[  706.047407] PM: Adding info for No Bus:ep_82
[  706.047423] device: 'ep_02': device_add
[  706.047504] PM: Adding info for No Bus:ep_02
[  706.047517] device: '1-1:1.1': device_add
[  706.047580] bus: 'usb': add device 1-1:1.1
[  706.047600] PM: Adding info for usb:1-1:1.1
[  706.048189] driver: 'btusb': driver_bound: bound to device '1-1:1.1'
[  706.054130] device: 'ep_83': device_add
[  706.054199] PM: Adding info for No Bus:ep_83
[  706.054217] device: 'ep_03': device_add
[  706.054271] PM: Adding info for No Bus:ep_03
[  706.054283] device: '1-1:1.2': device_add
[  706.054327] bus: 'usb': add device 1-1:1.2
[  706.054346] PM: Adding info for usb:1-1:1.2
[  706.054504] bus: 'usb': driver_probe_device: matched device 1-1:1.2 with
driver btusb
[  706.054518] bus: 'usb': really_probe: probing driver btusb with 
device 1-1:1.2

[  706.054537] btusb 1-1:1.2: no default pinctrl state
[  706.054564] devices_kset: Moving 1-1:1.2 to end of 

Re: [RFC PATCH 1/1] usb: dwc3: drd: Register a USB role switch

2018-10-30 Thread Chen Yu
Hi,

On 2018/10/30 22:03, Heikki Krogerus wrote:
> The Type-C drivers use USB role switch API to inform the
> system about the negotiated data role, so registering a role
> switch in the DRD code in order to support platforms with
> USB Type-C connectors.
> 
> Signed-off-by: Heikki Krogerus 
> ---
> Hi Chen Yu,
> 
> This is related to your Hikey960 USB patches series [1]. I can't test
> this patch, but I don't think this part should require anything else.
> 
> And about the device graph you'll need for this and the other
> components, I noticed that
> 
>   Documentation/devicetree/bindings/connector/usb-connector.txt
> 
> has some nice examples. I believe your port controller device will be
> one remote-endpoint for dwc3, and that hub/mux device another.
> 
> cheers,
> 
> [1] https://lkml.org/lkml/2018/10/27/178
> 
Thanks a lot for the patches! I will test the patches series on Hikey960.
I will read the examples in
Documentation/devicetree/bindings/connector/usb-connector.txt
and try to use it in my HiKey960 patches. Thansks!

> ---
>  drivers/usb/dwc3/core.h |  2 ++
>  drivers/usb/dwc3/drd.c  | 45 +
>  2 files changed, 47 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index 5bfb62533e0f..9d2a236354f9 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -25,6 +25,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include 
> @@ -1053,6 +1054,7 @@ struct dwc3 {
>   struct extcon_dev   *edev;
>   struct notifier_block   edev_nb;
>   enum usb_phy_interface  hsphy_mode;
> + struct usb_role_switch  *role_sw;
>  
>   u32 fladj;
>   u32 irq_gadget;
> diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
> index 218371f985ca..1795ea2a4570 100644
> --- a/drivers/usb/dwc3/drd.c
> +++ b/drivers/usb/dwc3/drd.c
> @@ -463,6 +463,44 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 
> *dwc)
>   return edev;
>  }
>  
> +static int dwc3_usb_role_switch_set(struct device *dev, enum usb_role role)
> +{
> + u32 mode;
> +
> + switch (role) {
> + case USB_ROLE_HOST:
> + mode = DWC3_GCTL_PRTCAP_HOST;
> + break;
> + case USB_ROLE_DEVICE:
> + mode = DWC3_GCTL_PRTCAP_DEVICE;
> + break;
> + default:
> + mode = DWC3_GCTL_PRTCAP_OTG;
> + break;
> + };
> +
> + dwc3_set_mode(dev_get_drvdata(dev), mode);
> + return 0;
> +}
> +
> +static enum usb_role dwc3_usb_role_switch_get(struct device *dev)
> +{
> + struct dwc3 *dwc = dev_get_drvdata(dev);
> + unsigned long flags;
> + enum usb_role role;
> +
> + spin_lock_irqsave(>lock, flags);
> + role = dwc->current_otg_role;
> + spin_unlock_irqrestore(>lock, flags);
> +
> + return role;
> +}
> +
> +static const struct usb_role_switch_desc dwc3_role_switch = {
> + .set = dwc3_usb_role_switch_set,
> + .get = dwc3_usb_role_switch_get,
> +};
> +
>  int dwc3_drd_init(struct dwc3 *dwc)
>  {
>   int ret, irq;
> @@ -511,6 +549,11 @@ int dwc3_drd_init(struct dwc3 *dwc)
>   dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
>   }
>  
> + dwc->role_sw = usb_role_switch_register(dwc->dev, _role_switch);
> + if (ret) {
> + dwc3_drd_exit(dwc);
> + return PTR_ERR(dwc->role_sw);
> + }
>   return 0;
>  }
>  
> @@ -546,4 +589,6 @@ void dwc3_drd_exit(struct dwc3 *dwc)
>  
>   if (!dwc->edev)
>   free_irq(dwc->otg_irq, dwc);
> +
> + usb_role_switch_unregister(dwc->role_sw);
>  }
> 



Re: [PATCH 2/2] usb: dwc2: gadget: Accept LPM token when TxFIFO is not empty

2018-10-30 Thread Sergei Shtylyov
Hello!

On 10/30/2018 03:26 PM, Artur Petrosyan wrote:

> To accept LPM token during ISOC transfers when TxFIFO
> is not empty.
> 
> Signed-off-by: Artur Petrosyan 
> Signed-off-by: Minas Harutyunyan 
> ---
>  drivers/usb/dwc2/gadget.c | 1 +
>  drivers/usb/dwc2/hw.h | 3 +++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 6bd4054e894d..63d53619fd21 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -5026,6 +5026,7 @@ void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg)
>   val |= hsotg->params.lpm_clock_gating ? GLPMCFG_ENBLSLPM : 0;
>   val |= hsotg->params.hird_threshold << GLPMCFG_HIRD_THRES_SHIFT;
>   val |= hsotg->params.besl ? GLPMCFG_ENBESL : 0;
> + val |= GLPMCFG_RETRY_CNT_1;
>   dwc2_writel(hsotg, val, GLPMCFG);
>   dev_dbg(hsotg->dev, "GLPMCFG=0x%08x\n", dwc2_readl(hsotg, GLPMCFG));
>  
> diff --git a/drivers/usb/dwc2/hw.h b/drivers/usb/dwc2/hw.h
> index 2b1ea441b7d4..84d2b32f4831 100644
> --- a/drivers/usb/dwc2/hw.h
> +++ b/drivers/usb/dwc2/hw.h
> @@ -333,6 +333,9 @@
>  #define GLPMCFG_SNDLPM   BIT(24)
>  #define GLPMCFG_RETRY_CNT_MASK   (0x7 << 21)
>  #define GLPMCFG_RETRY_CNT_SHIFT  21
> +#define GLPMCFG_RETRY_CNT_0  21
> +#define GLPMCFG_RETRY_CNT_1  22
> +#define GLPMCFG_RETRY_CNT_2  23

   Not '(0|1|2 << 21)'?

[...]

MBR, Sergei


Re: [PATCH 0/2] usb: dwc2: gadget: Fix Service Interval support.

2018-10-30 Thread Artur Petrosyan
Hi Balbi,

On 10/30/2018 16:33, Felipe Balbi wrote:
> 
> Hi,
> 
> Artur Petrosyan  writes:
> 
>> 1. This patch set fixes WkupAlert interrupt handler.
>> 2. Adds support to accept LPM token when TxFIFO
>> is not empty.
>>
>> NOTE: Request to add this patch set on "tag: usb-for-v4.20"
> 
> now that the merge window is already open? patch 1 seems like a fix, so
> it may be accepted during the -rc cycle. Patch 2 is more likely to be
> delayed for the next merge window.
> 

Both patches are required to complete Service Interval feature support. 
I would prefer to have both patches on the -rc cycle.

Regards,
Artur


Re: [PATCH 2/2] usb: dwc2: gadget: Accept LPM token when TxFIFO is not empty

2018-10-30 Thread Artur Petrosyan
Hi Balbi,

On 10/30/2018 16:35, Felipe Balbi wrote:
> 
> Hi,
> 
> Artur Petrosyan  writes:
>> To accept LPM token during ISOC transfers when TxFIFO
>> is not empty.
> 
> this commit log tells me nothing. Why do you need this patch? Why CNT1
> and not CNT0 or CNT2?
> 

Thanks for the quick reply and the review.
I will accordingly add descriptive information about the importance of 
the patch and the use of the CNT0, CNT1 and CNT2 (from the data book). 
Will create a version 2 for this patch.

Regards,
Artur


Re: [PATCH 1/2] usb: dwc2: gadget: Fix WkupAlert interrupt handler.

2018-10-30 Thread Artur Petrosyan
Hi Balbi,

On 10/30/2018 16:34, Felipe Balbi wrote:
> 
> Hi,
> 
> Artur Petrosyan  writes:
>> According to the databook DCTL_RMTWKUPSIG bit
>> is defined in DCTL register not in DCFG.
>>
>> Updated setting DCTL_RMTWKUPSIG bit to DCTL
>> register.
>>
> 
> looks like this needs a Cc stable and Fixes tag. Care to add?
> 
> 

I think, we don't need to add this patch to stable as this code is not 
included in any stable version. According Greg's mail ([GIT PULL] USB 
driver patches for 4.20-rc1) this code first appeared in 4.20-rc1.

I will add the Fixes tag to the patch and send it with version 2.

Regards,
Artur



[RFC PATCH 1/1] usb: dwc3: drd: Register a USB role switch

2018-10-30 Thread Heikki Krogerus
The Type-C drivers use USB role switch API to inform the
system about the negotiated data role, so registering a role
switch in the DRD code in order to support platforms with
USB Type-C connectors.

Signed-off-by: Heikki Krogerus 
---
Hi Chen Yu,

This is related to your Hikey960 USB patches series [1]. I can't test
this patch, but I don't think this part should require anything else.

And about the device graph you'll need for this and the other
components, I noticed that

Documentation/devicetree/bindings/connector/usb-connector.txt

has some nice examples. I believe your port controller device will be
one remote-endpoint for dwc3, and that hub/mux device another.

cheers,

[1] https://lkml.org/lkml/2018/10/27/178

---
 drivers/usb/dwc3/core.h |  2 ++
 drivers/usb/dwc3/drd.c  | 45 +
 2 files changed, 47 insertions(+)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 5bfb62533e0f..9d2a236354f9 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -1053,6 +1054,7 @@ struct dwc3 {
struct extcon_dev   *edev;
struct notifier_block   edev_nb;
enum usb_phy_interface  hsphy_mode;
+   struct usb_role_switch  *role_sw;
 
u32 fladj;
u32 irq_gadget;
diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
index 218371f985ca..1795ea2a4570 100644
--- a/drivers/usb/dwc3/drd.c
+++ b/drivers/usb/dwc3/drd.c
@@ -463,6 +463,44 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
return edev;
 }
 
+static int dwc3_usb_role_switch_set(struct device *dev, enum usb_role role)
+{
+   u32 mode;
+
+   switch (role) {
+   case USB_ROLE_HOST:
+   mode = DWC3_GCTL_PRTCAP_HOST;
+   break;
+   case USB_ROLE_DEVICE:
+   mode = DWC3_GCTL_PRTCAP_DEVICE;
+   break;
+   default:
+   mode = DWC3_GCTL_PRTCAP_OTG;
+   break;
+   };
+
+   dwc3_set_mode(dev_get_drvdata(dev), mode);
+   return 0;
+}
+
+static enum usb_role dwc3_usb_role_switch_get(struct device *dev)
+{
+   struct dwc3 *dwc = dev_get_drvdata(dev);
+   unsigned long flags;
+   enum usb_role role;
+
+   spin_lock_irqsave(>lock, flags);
+   role = dwc->current_otg_role;
+   spin_unlock_irqrestore(>lock, flags);
+
+   return role;
+}
+
+static const struct usb_role_switch_desc dwc3_role_switch = {
+   .set = dwc3_usb_role_switch_set,
+   .get = dwc3_usb_role_switch_get,
+};
+
 int dwc3_drd_init(struct dwc3 *dwc)
 {
int ret, irq;
@@ -511,6 +549,11 @@ int dwc3_drd_init(struct dwc3 *dwc)
dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
}
 
+   dwc->role_sw = usb_role_switch_register(dwc->dev, _role_switch);
+   if (ret) {
+   dwc3_drd_exit(dwc);
+   return PTR_ERR(dwc->role_sw);
+   }
return 0;
 }
 
@@ -546,4 +589,6 @@ void dwc3_drd_exit(struct dwc3 *dwc)
 
if (!dwc->edev)
free_irq(dwc->otg_irq, dwc);
+
+   usb_role_switch_unregister(dwc->role_sw);
 }
-- 
2.19.1



Re: [PATCH] usb: dwc3: core: Clean up ULPI device

2018-10-30 Thread Felipe Balbi

Hi,

Felipe Balbi  writes:
> From: Andy Shevchenko 
>
> If dwc3_core_init_mode() fails with deferred probe,
> next probe fails on sysfs with
>
> sysfs: cannot create duplicate filename 
> '/devices/pci:00/:00:11.0/dwc3.0.auto/dwc3.0.auto.ulpi'
>
> To avoid this failure, clean up ULPI device.
>
> Cc: 
> Signed-off-by: Andy Shevchenko 
> Signed-off-by: Felipe Balbi 
> ---
>  drivers/usb/dwc3/core.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 88c80fcc39f5..fec97465ccac 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1499,6 +1499,7 @@ static int dwc3_probe(struct platform_device *pdev)
>  
>  err5:
>   dwc3_event_buffers_cleanup(dwc);
> + dwc3_ulpi_exit(dwc);
>  
>  err4:
>   dwc3_free_scratch_buffers(dwc);
> -- 
> 2.19.1
>
> -
> Intel Finland Oy
> Registered Address: PL 281, 00181 Helsinki 
> Business Identity Code: 0357606 - 4 
> Domiciled in Helsinki 
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.

argh, apologies for this footer. Mail server had changes recently.

-- 
balbi


signature.asc
Description: PGP signature


Re: EPROTO when USB 3 GbE adapters are under load

2018-10-30 Thread Hao Wei Tee

On 25/10/18 11:04 PM, Mathias Nyman wrote:

There is a patch in usb-next that might help.
f8f80be xhci: Use soft retry to recover faster from transaction errors

It soft resets the halted host side endpoint, clears the halt without clearing 
the sequence number.


FWIW, although I guess you might've guessed, the patch didn't seem to change 
the behaviour at all. But thanks in any case.

I'll see what else I can figure out.

--
Hao Wei


[PATCH] usb: dwc3: core: Clean up ULPI device

2018-10-30 Thread Felipe Balbi
From: Andy Shevchenko 

If dwc3_core_init_mode() fails with deferred probe,
next probe fails on sysfs with

sysfs: cannot create duplicate filename 
'/devices/pci:00/:00:11.0/dwc3.0.auto/dwc3.0.auto.ulpi'

To avoid this failure, clean up ULPI device.

Cc: 
Signed-off-by: Andy Shevchenko 
Signed-off-by: Felipe Balbi 
---
 drivers/usb/dwc3/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 88c80fcc39f5..fec97465ccac 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1499,6 +1499,7 @@ static int dwc3_probe(struct platform_device *pdev)
 
 err5:
dwc3_event_buffers_cleanup(dwc);
+   dwc3_ulpi_exit(dwc);
 
 err4:
dwc3_free_scratch_buffers(dwc);
-- 
2.19.1

-
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.



Re: [PATCH 2/2] usb: dwc2: gadget: Accept LPM token when TxFIFO is not empty

2018-10-30 Thread Felipe Balbi

Hi,

Artur Petrosyan  writes:
> To accept LPM token during ISOC transfers when TxFIFO
> is not empty.

this commit log tells me nothing. Why do you need this patch? Why CNT1
and not CNT0 or CNT2?

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 1/2] usb: dwc2: gadget: Fix WkupAlert interrupt handler.

2018-10-30 Thread Felipe Balbi

Hi,

Artur Petrosyan  writes:
> According to the databook DCTL_RMTWKUPSIG bit
> is defined in DCTL register not in DCFG.
>
> Updated setting DCTL_RMTWKUPSIG bit to DCTL
> register.
>

looks like this needs a Cc stable and Fixes tag. Care to add?


-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 0/2] usb: dwc2: gadget: Fix Service Interval support.

2018-10-30 Thread Felipe Balbi

Hi,

Artur Petrosyan  writes:

> 1. This patch set fixes WkupAlert interrupt handler.
> 2. Adds support to accept LPM token when TxFIFO
>is not empty.
>
> NOTE: Request to add this patch set on "tag: usb-for-v4.20"

now that the merge window is already open? patch 1 seems like a fix, so
it may be accepted during the -rc cycle. Patch 2 is more likely to be
delayed for the next merge window.

-- 
balbi


signature.asc
Description: PGP signature


[PATCH 2/2] usb: dwc2: gadget: Accept LPM token when TxFIFO is not empty

2018-10-30 Thread Artur Petrosyan
To accept LPM token during ISOC transfers when TxFIFO
is not empty.

Signed-off-by: Artur Petrosyan 
Signed-off-by: Minas Harutyunyan 
---
 drivers/usb/dwc2/gadget.c | 1 +
 drivers/usb/dwc2/hw.h | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 6bd4054e894d..63d53619fd21 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -5026,6 +5026,7 @@ void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg)
val |= hsotg->params.lpm_clock_gating ? GLPMCFG_ENBLSLPM : 0;
val |= hsotg->params.hird_threshold << GLPMCFG_HIRD_THRES_SHIFT;
val |= hsotg->params.besl ? GLPMCFG_ENBESL : 0;
+   val |= GLPMCFG_RETRY_CNT_1;
dwc2_writel(hsotg, val, GLPMCFG);
dev_dbg(hsotg->dev, "GLPMCFG=0x%08x\n", dwc2_readl(hsotg, GLPMCFG));
 
diff --git a/drivers/usb/dwc2/hw.h b/drivers/usb/dwc2/hw.h
index 2b1ea441b7d4..84d2b32f4831 100644
--- a/drivers/usb/dwc2/hw.h
+++ b/drivers/usb/dwc2/hw.h
@@ -333,6 +333,9 @@
 #define GLPMCFG_SNDLPM BIT(24)
 #define GLPMCFG_RETRY_CNT_MASK (0x7 << 21)
 #define GLPMCFG_RETRY_CNT_SHIFT21
+#define GLPMCFG_RETRY_CNT_021
+#define GLPMCFG_RETRY_CNT_122
+#define GLPMCFG_RETRY_CNT_223
 #define GLPMCFG_LPM_CHNL_INDX_MASK (0xf << 17)
 #define GLPMCFG_LPM_CHNL_INDX_SHIFT17
 #define GLPMCFG_L1RESUMEOK BIT(16)
-- 
2.11.0



[PATCH 0/2] usb: dwc2: gadget: Fix Service Interval support.

2018-10-30 Thread Artur Petrosyan
1. This patch set fixes WkupAlert interrupt handler.
2. Adds support to accept LPM token when TxFIFO
   is not empty.

NOTE: Request to add this patch set on "tag: usb-for-v4.20"


Artur Petrosyan (2):
  usb: dwc2: gadget: Fix WkupAlert interrupt handler.
  usb: dwc2: gadget: Accept LPM token when TxFIFO is not empty

 drivers/usb/dwc2/gadget.c | 3 ++-
 drivers/usb/dwc2/hw.h | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

-- 
2.11.0



[PATCH 1/2] usb: dwc2: gadget: Fix WkupAlert interrupt handler.

2018-10-30 Thread Artur Petrosyan
According to the databook DCTL_RMTWKUPSIG bit
is defined in DCTL register not in DCFG.

Updated setting DCTL_RMTWKUPSIG bit to DCTL
register.

Signed-off-by: Artur Petrosyan 
Signed-off-by: Minas Harutyunyan 
---
 drivers/usb/dwc2/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 2d6d2c8244de..6bd4054e894d 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -262,7 +262,7 @@ static void dwc2_gadget_wkup_alert_handler(struct 
dwc2_hsotg *hsotg)
if (gintsts2 & GINTSTS2_WKUP_ALERT_INT) {
dev_dbg(hsotg->dev, "%s: Wkup_Alert_Int\n", __func__);
dwc2_clear_bit(hsotg, GINTSTS2, GINTSTS2_WKUP_ALERT_INT);
-   dwc2_set_bit(hsotg, DCFG, DCTL_RMTWKUPSIG);
+   dwc2_set_bit(hsotg, DCTL, DCTL_RMTWKUPSIG);
}
 }
 
-- 
2.11.0



Re: USB Bluetooth dongle stop response with timeout error

2018-10-30 Thread Oliver Neukum
On Sa, 2018-10-27 at 22:56 +0800, Morikazu Fumita wrote:
> I always found error messages of
> "Bluetooth: hci0: command 0x0406 tx timeout" and

The problem is likely shortly before that.

> "dwc2 ffb4.usb: --Host Channel x Interrupt: Frame Overrun--"
> when this problem is happening.
> 
> Here's an example log:
> [  251.748320] pan: port 1(bnep0) entered disabled state
> [  251.752153] device bnep0 left promiscuous mode
> [  251.754541] pan: port 1(bnep0) entered disabled state
> [  257.879162] Bluetooth: hci0: command 0x0406 tx timeout
> Oct 25 04:47:14 cyclone5 systemd-networkd[132]: bnep0: Lost carrier
> Oct 25 04:47:14 cyclone5 kernel: pan: port 1(bnep0) entered disabled state
> Oct 25 04:47:14 cyclone5 kernel: dwc2 ffb4.usb: --Host Channel 15 
> Interrupt: Frame Overrun--

You need to find out under which circumstances the hang happens.
Is it always when leaving the promiscuous mode?

Regards
Oliver