[PATCH] usb: dwc3: fix fault at system suspend if device was already runtime suspended
From: Roger Quadros
Date: Sat Nov 02 2024 - 08:14:47 EST
If the device was already runtime suspended then during system suspend
we cannot access the device registers else it will crash.
Cc: stable@xxxxxxxxxxxxxxx # v5.15+
Reported-by: William McVicker <willmcvicker@xxxxxxxxxx>
Closes: https://lore.kernel.org/all/ZyVfcUuPq56R2m1Y@xxxxxxxxxx
Fixes: 705e3ce37bcc ("usb: dwc3: core: Fix system suspend on TI AM62 platforms")
Signed-off-by: Roger Quadros <rogerq@xxxxxxxxxx>
---
drivers/usb/dwc3/core.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 427e5660f87c..4933f1b4d9c6 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -2342,10 +2342,12 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
u32 reg;
int i;
- dwc->susphy_state = (dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)) &
- DWC3_GUSB2PHYCFG_SUSPHY) ||
- (dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)) &
- DWC3_GUSB3PIPECTL_SUSPHY);
+ if (!pm_runtime_suspended(dwc->dev)) {
+ dwc->susphy_state = (dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)) &
+ DWC3_GUSB2PHYCFG_SUSPHY) ||
+ (dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)) &
+ DWC3_GUSB3PIPECTL_SUSPHY);
+ }
switch (dwc->current_dr_role) {
case DWC3_GCTL_PRTCAP_DEVICE:
base-commit: 4b57d665bce1306a2a887cb760aa0c0e7efb42ab
--
2.34.1
--
cheers,
-roger