From: Felipe Balbi <balbi@kernel.org>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Ferry Toth <fntoth@gmail.com>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
John Stultz <john.stultz@linaro.org>
Cc: John Youn <John.Youn@synopsys.com>,
"stable@vger.kernel.org" <stable@vger.kernel.org>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Wesley Cheng <wcheng@codeaurora.org>,
Yu Chen <chenyu56@huawei.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: [PATCH v3] usb: dwc3: core: Do core softreset when switch mode
Date: Mon, 19 Apr 2021 12:47:28 +0300 [thread overview]
Message-ID: <87h7k2mwr3.fsf@kernel.org> (raw)
In-Reply-To: <4a1245e3-023c-ec69-2ead-dacf5560ff9f@synopsys.com>
[-- Attachment #1: Type: text/plain, Size: 3113 bytes --]
Hi,
Thinh Nguyen <Thinh.Nguyen@synopsys.com> writes:
>> (Issue history:
>> https://urldefense.com/v3/__https://github.com/andy-shev/linux/issues/31__;!!A4F2R9G_pg!Oa6XGH3IqY3wwG5KK4FwPuNA0m3q5bRj7N6vdP-y4sAY6mya-96J90NJ0tJnXNc7KgAw$
>> )
>>
>> On the PC side this resulted to:
>>
>> apr 17 18:17:44 delfion kernel: usb 1-5: new high-speed USB device
>> number 12 using xhci_hcd
>> apr 17 18:17:44 delfion kernel: usb 1-5: New USB device found,
>> idVendor=1d6b, idProduct=0104, bcdDevice= 1.00
>> apr 17 18:17:44 delfion kernel: usb 1-5: New USB device strings: Mfr=1,
>> Product=2, SerialNumber=3
>> apr 17 18:17:44 delfion kernel: usb 1-5: Product: USBArmory Gadget
>> apr 17 18:17:44 delfion kernel: usb 1-5: Manufacturer: USBArmory
>> apr 17 18:17:44 delfion kernel: usb 1-5: SerialNumber: 0123456789abcdef
>> apr 17 18:17:49 delfion kernel: usb 1-5: can't set config #1, error -110
>>
>>
>> Thanks for all your help!
>>
>
> Looks like it's LPM related again. To confirm, try this:
> Disable LPM with this property "snps,usb2-gadget-lpm-disable"
> (Note that it's not the same as "snps,dis_enblslpm_quirk")
>
> Make sure that your testing kernel has this patch [1]
> 475e8be53d04 ("usb: dwc3: gadget: Check for disabled LPM quirk")
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/commit/?h=usb-next&id=475e8be53d0496f9bc6159f4abb3ff5f9b90e8de
>
>
> The failure you saw was probably due the gadget function attempting
> to start a delayed status stage of the SET_CONFIGURATION request.
> By this time, the host already put the device in low power.
>
> The START_TRANSFER command needs to be executed while the device
> is on "ON" state (or U0 if eSS). We shouldn't use dwc->link_state
> to check for link state because we only enable link state change
> interrupt for some controller versions.
>
> Once you confirms disabling LPM works, try this fix:
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 6227641f2d31..06cdec79244e 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -309,10 +309,14 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
>
> if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) {
> int needs_wakeup;
> + u8 link_state;
>
> - needs_wakeup = (dwc->link_state == DWC3_LINK_STATE_U1 ||
> - dwc->link_state == DWC3_LINK_STATE_U2 ||
> - dwc->link_state == DWC3_LINK_STATE_U3);
> + reg = dwc3_readl(dwc->regs, DWC3_DSTS);
> + link_state = DWC3_DSTS_USBLNKST(reg);
> +
> + needs_wakeup = (link_state == DWC3_LINK_STATE_U1 ||
> + link_state == DWC3_LINK_STATE_U2 ||
> + link_state == DWC3_LINK_STATE_U3);
this makes sense. We used to track state using the state change
interrupts, but that's long since being disabled. I think, either way,
we need this fix.
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 857 bytes --]
next prev parent reply other threads:[~2021-04-19 9:47 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-15 2:23 [PATCH] usb: dwc3: core: Do core softreset when switch mode Thinh Nguyen
2021-04-15 6:23 ` Felipe Balbi
2021-04-15 7:10 ` Thinh Nguyen
2021-04-15 7:53 ` Greg Kroah-Hartman
2021-04-15 8:04 ` Thinh Nguyen
2021-04-15 10:45 ` Felipe Balbi
2021-04-15 14:57 ` Thinh Nguyen
2021-04-15 22:31 ` Thinh Nguyen
2021-04-15 16:29 ` [PATCH v2] " Thinh Nguyen
2021-04-15 19:54 ` John Stultz
2021-04-15 20:11 ` Thinh Nguyen
2021-04-15 22:20 ` [PATCH v3] " Thinh Nguyen
2021-04-15 22:23 ` Thinh Nguyen
2021-04-16 21:17 ` Ferry Toth
2021-04-17 2:27 ` Thinh Nguyen
2021-04-17 14:22 ` Ferry Toth
2021-04-17 16:32 ` Ferry Toth
2021-04-18 23:03 ` Thinh Nguyen
2021-04-19 8:43 ` Andy Shevchenko
2021-04-19 20:24 ` Ferry Toth
2021-04-19 9:47 ` Felipe Balbi [this message]
2021-04-19 20:15 ` Ferry Toth
2021-04-19 21:23 ` Thinh Nguyen
2021-04-20 19:55 ` Ferry Toth
2021-04-21 19:01 ` Thinh Nguyen
2021-04-21 22:30 ` Ferry Toth
2021-04-22 20:55 ` Ferry Toth
2021-04-22 21:58 ` Thinh Nguyen
2021-04-23 7:18 ` Ferry Toth
2021-04-16 0:12 ` John Stultz
2021-04-16 3:28 ` John Stultz
2021-04-16 9:10 ` Ferry Toth
2021-04-16 10:47 ` Felipe Balbi
2021-04-16 19:05 ` Wesley Cheng
2021-04-16 19:38 ` John Stultz
2021-04-16 19:49 ` Thinh Nguyen
2021-04-16 21:08 ` John Stultz
2021-04-17 6:25 ` Felipe Balbi
2021-04-19 19:49 ` Thinh Nguyen
2021-04-19 21:26 ` Wesley Cheng
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=87h7k2mwr3.fsf@kernel.org \
--to=balbi@kernel.org \
--cc=John.Youn@synopsys.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=andy.shevchenko@gmail.com \
--cc=chenyu56@huawei.com \
--cc=fntoth@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=john.stultz@linaro.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=wcheng@codeaurora.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.