Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Xu Yang <xu.yang_2@oss.nxp.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"Frank.Li@nxp.com" <Frank.Li@nxp.com>,
	"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	"festevam@gmail.com" <festevam@gmail.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"imx@lists.linux.dev" <imx@lists.linux.dev>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"jun.li@nxp.com" <jun.li@nxp.com>
Subject: Re: [PATCH 1/2] usb: dwc3: wait for the port to leave RxDetect before xHCI reset
Date: Wed, 25 Nov 2026 01:03:08 +0000	[thread overview]
Message-ID: <awYspGsimvWjR4JY@vbox> (raw)
In-Reply-To: <20261106111943.2868733-2-xu.yang_2@oss.nxp.com>

On Fri, Nov 06, 2026, Xu Yang wrote:
> From: Xu Yang <xu.yang_2@nxp.com>
> 
> When the host controller loses power during system suspend, the port
> state is not retained. After power is restored, the port starts in the
> Disconnected (RxDetect) state instead of its previous Enabled (U3)
> state.
> 
> After the controller is switched back to host mode, testing on an i.MX8/9
> SoC shows that it takes about 2 ms for the port to leave RxDetect and
> enter Polling. If xHCI is reset while the port is still in RxDetect, the
> port does not issue a Warm Reset.
> 
> This prevents the link from recovering because the USB3 device may
> still be in U3. Once the port enters Polling, it sends LFPS.Polling, but
> the device does not respond as expected. After three Polling attempts,
> each taking about 360 ms (tPollingLFPSTimeout), the controller reports
> the device as disconnected.
> 
> If xHCI is reset after the port has entered Polling, the port issues a
> Warm Reset and the link recovers quickly after the device responds.
> 
> Add a 2 ms delay through the xHCI resume quirk before resetting xHCI.
> This allows the port to leave RxDetect so that a Warm Reset can be
> issued, avoiding an unnecessary device disconnect during system
> resume.
> 
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> ---
>  drivers/usb/dwc3/host.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
> index c5674161b2b0..465c170df12c 100644
> --- a/drivers/usb/dwc3/host.c
> +++ b/drivers/usb/dwc3/host.c
> @@ -78,8 +78,29 @@ static void dwc3_xhci_plat_start(struct usb_hcd *hcd)
>  	dwc3_enable_susphy(dwc, true);
>  }
>  
> +static int dwc3_xhci_resume_quirk(struct usb_hcd *hcd)
> +{
> +	struct platform_device *pdev;
> +	struct dwc3 *dwc;
> +
> +	pdev = to_platform_device(hcd->self.controller);
> +	dwc = dev_get_drvdata(pdev->dev.parent);
> +
> +	if (dwc->needs_full_reinit) {

The core is also re-initialized on system resume when wakeup is disabled
(see dwc3_resume_common()). Shouldn't this be like below:

	if (!device_may_wakeup(dwc->dev) || dwc->needs_full_reinit)

> +		/*
> +		 * The port needs some time to leave RxDetect after host mode
> +		 * is restored. Delay the xHCI reset until the port can enter
> +		 * Polling, allowing a Warm Reset to recover the USB3 link.
> +		 */
> +		usleep_range(2000, 2500);

Can we add a comment that this value is tested with i.MX8/9 rather than
a common value for all platforms?

Thanks,
Thinh

> +	}
> +
> +	return 0;
> +}
> +
>  static const struct xhci_plat_priv dwc3_xhci_plat_quirk = {
>  	.plat_start = dwc3_xhci_plat_start,
> +	.resume_quirk = dwc3_xhci_resume_quirk,
>  };
>  
>  static void dwc3_host_fill_xhci_irq_res(struct dwc3 *dwc,
> -- 
> 2.34.1
> 

  reply	other threads:[~2026-11-25  1:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 11:19 [PATCH 0/2] usb: dwc3: recover USB3 link after controller power loss Xu Yang
2026-11-06 11:19 ` [PATCH 1/2] usb: dwc3: wait for the port to leave RxDetect before xHCI reset Xu Yang
2026-11-25  1:03   ` Thinh Nguyen [this message]
2026-11-06 11:19 ` [PATCH 2/2] usb: dwc3: imx8mp: set needs_full_reinit as true Xu Yang

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=awYspGsimvWjR4JY@vbox \
    --to=thinh.nguyen@synopsys.com \
    --cc=Frank.Li@nxp.com \
    --cc=festevam@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=imx@lists.linux.dev \
    --cc=jun.li@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=xu.yang_2@oss.nxp.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