From: Felipe Balbi <felipe.balbi@linux.intel.com>
To: evan@gnarbox.com
Cc: linux-usb@vger.kernel.org, rob@gnarbox.com
Subject: Re: [BUG REPORT] usb: dwc3: "failed to enable ep0out" when enabling mass storage mode
Date: Tue, 14 May 2019 11:18:52 +0300 [thread overview]
Message-ID: <87r291a1oz.fsf@linux.intel.com> (raw)
In-Reply-To: <20190513222517.LT4QsTQlr%evan@gnarbox.com>
Hi,
evan@gnarbox.com 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
next prev parent reply other threads:[~2019-05-14 8:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-13 22:25 [BUG REPORT] usb: dwc3: "failed to enable ep0out" when enabling mass storage mode evan
2019-05-14 8:18 ` Felipe Balbi [this message]
2019-05-14 23:07 ` evan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r291a1oz.fsf@linux.intel.com \
--to=felipe.balbi@linux.intel.com \
--cc=evan@gnarbox.com \
--cc=linux-usb@vger.kernel.org \
--cc=rob@gnarbox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).