Skip to content

Commit 9cfb31e

Browse files
rogerqgregkh
authored andcommitted
usb: dwc3: fix fault at system suspend if device was already runtime suspended
If the device was already runtime suspended then during system suspend we cannot access the device registers else it will crash. Also we cannot access any registers after dwc3_core_exit() on some platforms so move the dwc3_enable_susphy() call to the top. Cc: stable@vger.kernel.org # v5.15+ Reported-by: William McVicker <willmcvicker@google.com> Closes: https://lore.kernel.org/all/ZyVfcUuPq56R2m1Y@google.com Fixes: 705e3ce ("usb: dwc3: core: Fix system suspend on TI AM62 platforms") Signed-off-by: Roger Quadros <rogerq@kernel.org> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Tested-by: Will McVicker <willmcvicker@google.com> Link: https://lore.kernel.org/r/20241104-am62-lpm-usb-fix-v1-1-e93df73a4f0d@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 029778a commit 9cfb31e

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

drivers/usb/dwc3/core.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,10 +2342,18 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
23422342
u32 reg;
23432343
int i;
23442344

2345-
dwc->susphy_state = (dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)) &
2346-
DWC3_GUSB2PHYCFG_SUSPHY) ||
2347-
(dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)) &
2348-
DWC3_GUSB3PIPECTL_SUSPHY);
2345+
if (!pm_runtime_suspended(dwc->dev) && !PMSG_IS_AUTO(msg)) {
2346+
dwc->susphy_state = (dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)) &
2347+
DWC3_GUSB2PHYCFG_SUSPHY) ||
2348+
(dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)) &
2349+
DWC3_GUSB3PIPECTL_SUSPHY);
2350+
/*
2351+
* TI AM62 platform requires SUSPHY to be
2352+
* enabled for system suspend to work.
2353+
*/
2354+
if (!dwc->susphy_state)
2355+
dwc3_enable_susphy(dwc, true);
2356+
}
23492357

23502358
switch (dwc->current_dr_role) {
23512359
case DWC3_GCTL_PRTCAP_DEVICE:
@@ -2398,15 +2406,6 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
23982406
break;
23992407
}
24002408

2401-
if (!PMSG_IS_AUTO(msg)) {
2402-
/*
2403-
* TI AM62 platform requires SUSPHY to be
2404-
* enabled for system suspend to work.
2405-
*/
2406-
if (!dwc->susphy_state)
2407-
dwc3_enable_susphy(dwc, true);
2408-
}
2409-
24102409
return 0;
24112410
}
24122411

0 commit comments

Comments
 (0)