Re: [PATCH v2] usb: dwc3: tell xHCI that it lost its state when the core is powered off

From: Xu Yang

Date: Tue Nov 24 2026 - 23:47:29 EST


On Wed, Nov 25, 2026 at 02:37:38AM +0000, Thinh Nguyen wrote:
> ++ Xu Yang,
>
> On Thu, Nov 12, 2026, Joonhoe Kim wrote:
> > dwc3_suspend_common() powers the core off for system suspend
> > (dwc3_core_exit()) in OTG mode (DWC3_GCTL_PRTCAP_OTG), and in host mode
> > when the controller may not wake the system or needs a full re-init. The
> > xHCI registers and the state saved with the Controller Save State
> > command are gone then, but nothing tells xhci-plat: xhci_resume() takes
> > the "state intact" path, writes the saved registers back and asks the
> > controller to restore its state (CRS).
> >
> > xhci-plat has a flag for exactly this, power_lost (commit 668cc6bc1178
> > ("usb: host: xhci-plat: allow upper layers to signal power loss"), used
> > by cdns3), but dwc3 never sets it.
> >
> > On a Lenovo Y700 Gen 5 (TB323FU, SM8850; DWC3 + eUSB2 PHY) with a USB
> > 2.0 hub, a USB 3 flash drive and a Billboard device attached, and USB
> > wakeup disabled, s2idle then broke the host controller on resume: either
> > the controller wrote to an address that was not mapped
> >
> > arm-smmu 15000000.iommu: Unhandled context fault: fsr=0x402,
> > iova=0xd85e7c300, fsynr=0x3d0011, cbfrsynra=0x40, cb=13
> > xhci-hcd xhci-hcd.2.auto: WARNING: Host System Error
> > usb 1-1: hub failed to enable device, error -108
> >
> > or its command ring would not stop
> >
> > xhci-hcd xhci-hcd.2.auto: Abort failed to stop command ring: -110
> > xhci-hcd xhci-hcd.2.auto: xHCI host controller not responding, assume dead
> > xhci-hcd xhci-hcd.2.auto: HC died; cleaning up
> > usb 1-1: PM: **** DPM device timeout ****
> > Kernel panic - not syncing: usb 1-1: unrecoverable failure
> >
> > With wakeup enabled (the core stays powered) the same setup survived
> > every cycle.
> >
> > Record that the core was powered off and pass this to xhci-plat as
> > power_lost from a resume_quirk, so that xhci_resume() resets the
> > controller and the devices are re-enumerated. Unlike a static
> > XHCI_RESET_ON_RESUME this only applies to the resumes that follow a
> > power-off; resumes with the core kept powered (host mode with wakeup
> > enabled) and runtime resume keep the restore path. Clear the flag once
> > xhci-plat has read it, so that a later system suspend that fails before
> > the dwc3 core is suspended does not reset the controller.
> >
> > Fixes: c4a5153e87fd ("usb: dwc3: core: Power-off core/PHYs on system_suspend in host mode")
> > Fixes: f09cc79b4b33 ("usb: dwc3: add dual role support using OTG block")
>
> Can we also Cc stable?
>
> > Signed-off-by: Joonhoe Kim <26rote@xxxxxxxxx>
> > ---
> > v2:
> > - Also set the flag when the core is powered off in OTG mode with the
> > host role active (Sashiko [1])
> > - Clear the flag once xhci-plat has read it (Sashiko [1]), instead of in
> > the host branch that keeps the core powered
> > - Drop the comment above the resume quirk
> > - Add a Fixes tag for the OTG branch
> > - Rebased on next-20261111
> >
> > Testing, 30 s RTC s2idle with wakeup disabled on the setup above:
> > without this change 1/1 cycles lost the controller; with this version
> > 3/3 cycles reset the controller and re-enumerated all devices.
> > OTG mode (DWC3_GCTL_PRTCAP_OTG) is not tested; this board switches
> > roles through usb-role-switch and never uses it.
> >
> > host.c now includes xhci.h for hcd_to_xhci_priv().
> >
>
> This looks good to me.
>
> Acked-by: Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx>
>
> Hi Xu,
>
> This may conflict with your "usb: dwc3: wait for the port to leave
> RxDetect before xHCI reset" patch. Can you check if rebasing on this
> patch work for you?

OK, I can rework a new patch based on this one later.
Maybe I should wait for it to land first?

Thanks,
Xu Yang