Re: [BUG REPORT] usb: dwc3: "failed to enable ep0out" when enabling mass storage mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

evan@xxxxxxxxxxx writes:

> Hi Felipe,
>
> I'm picking up a bug my coworker Rob touched on in this thread:
> https://marc.info/?l=linux-usb&m=155349928622570&w=2
>
> We occasionally see the following dmesg when enabling mass storage mode:
>
> 	dwc3 dwc3.1.auto: failed to enable ep0out
>
> To reproduce after a clean boot:
>
> 	Enable mass storage mode
> 	Disable mass storage mode
> 	Enable mass storage mode
>
> I don't need to plug any devices, just switch modes.
>
> The error does not happen every boot.  If I don't get the error on that
> second enable, then as far as I can tell I won't get the error at all
> during that boot.
>
> I've attached the trace and regdump.  When capturing these I was running
> a 4.9.115 kernel and using the g_mass_storage driver for simplicity.
> Here is the shell session:
>
> 	root@gnarbox-2:~# echo device > /sys/class/usb_role/intel_xhci_usb_sw-role-switch/role && modprobe g_mass_storage file=/dev/nvme0n1p7 iSerialNumber=90405
> 	[  118.627628] Mass Storage Function, version: 2009/09/11
> 	[  118.633426] LUN: removable file: (no medium)
> 	[  118.638283] LUN: file: /dev/nvme0n1p7
> 	[  118.642397] Number of LUNs=1
> 	[  118.646080] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
> 	[  118.653902] g_mass_storage gadget: g_mass_storage ready
> 	root@gnarbox-2:~# modprobe -r g_mass_storage && echo host > /sys/class/usb_role/intel_xhci_usb_sw-role-switch/role 
> 	root@gnarbox-2:~# echo device > /sys/class/usb_role/intel_xhci_usb_sw-role-switch/role && modprobe g_mass_storage file=/dev/nvme0n1p7 iSerialNumber=90405
> 	[  123.416789] Mass Storage Function, version: 2009/09/11
> 	[  123.422546] LUN: removable file: (no medium)
> 	[  123.427386] LUN: file: /dev/nvme0n1p7
> 	[  123.431531] Number of LUNs=1
> 	[  123.435278] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
> 	[  123.443168] g_mass_storage gadget: g_mass_storage ready
> 	[  123.451998] dwc3 dwc3.1.auto: failed to enable ep0out

When this happens, I see this:

        modprobe-1046  [001] d..1   123.450054: dwc3_gadget_ep_cmd: ep0out: cmd 'Start New Configuration' [9] params 00000000 00000000 00000000 --> status: Successful
        modprobe-1046  [001] d..1   123.451990: dwc3_gadget_ep_cmd: ep0out: cmd 'Set Endpoint Transfer Resource' [2] params 00000001 00000000 00000000 --> status: Timed Out

Why is that waiting only 1ms? Maybe your platform takes longer,
sometimes, to complete xfer resource allocation?

Try this:

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index d67655384eb2..ad1069fe3b8f 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -270,7 +270,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd,
 {
 	const struct usb_endpoint_descriptor *desc = dep->endpoint.desc;
 	struct dwc3		*dwc = dep->dwc;
-	u32			timeout = 1000;
+	u32			timeout = 5000;
 	u32			saved_config = 0;
 	u32			reg;
 
Let me know if it helps or not. I guess it's also time to switch this
block of code to readl_poll_timeout_atomic().

-- 
balbi



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux