[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250826150826.11096-1-ryanzhou54@gmail.com>
Date: Tue, 26 Aug 2025 23:08:26 +0800
From: Ryan Zhou <ryanzhou54@...il.com>
To: Thinh.Nguyen@...opsys.com
Cc: gregkh@...uxfoundation.org,
linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org,
Ryan Zhou <ryanzhou54@...il.com>
Subject: [PATCH] drvier: usb: dwc3: Fix runtime PM trying to activate child device xxx.dwc3 but parent is not active
Issue description:
The parent device dwc3_glue has runtime PM enabled and is in the
runtime suspended state. The system enters the deep sleep process
but is interrupted by another task. When resuming dwc3,
console outputs the log 'runtime PM trying to activate child device
xxx.dwc3 but parent is not active'.
However, the child device dwc3 continues to sleep pm_resume, calling
phy_init and phy_power_on, which sets phy->init_count and
phy->power_count to 1. Later when the system meets the conditions
for deep sleep again, it attempts another 'PM: suspend entry (deep)'.
dwc3 driver executes sleep pm_suspend function but dwc3
already in suspended state, skipping the suspend process in
commit 0227cc84c4441 ("usb: dwc3: core: don't do suspend for device mode
if already suspended"), so phy_exit and phy_power_off are not executed,
keeping phy->init_count and phy->power_count at 1.
During the next deep resume, phy_init and phy_power_on will not be called
due to non-zero count, but the count still increments, preventing recovery.
Eventually, this leads to USB device phy cannot be reinitialized.
Log:
[ 130.284870][C5 t2624] PM: suspend entry (deep)
[ 130.391369][C3 t2624] dwc3 51600000.dwc3: dwc3_suspend
[ 130.406326][C3 t2624] alarmtimer.0.auto: PM: dpm_run_callback():
platform_pm_suspend+0x0/0x90 returns -16
[ 130.407873][C3 t2624] alarmtimer.0.auto: PM: failed to suspend: error -16
[ 130.417756][C3 t2624] PM: Some devices failed to suspend, or early wake
event detected
[ 130.438254][C3 t2624] [asr_drm_resume][726]: ==debug==
[ 130.440178][C3 t2624] dwc3 51600000.dwc3: dwc3_resume
[ 130.440950][C3 t2624] dwc3 51600000.dwc3: runtime PM trying to activate
child device 51600000.dwc3 but parent (51600000.usb) is not active
Solution: During the dwc3 suspend process, check the runtime state of dwc3
to ensure it enters the suspend process only when in the runtime active
state. This way, even if the system suspend process is interrupted,
the parent device will remain in the active state when resuming dwc3 from
deep suspend, allowing successful resumption of the dwc3 device.
Signed-off-by: Ryan Zhou <ryanzhou54@...il.com>
---
drivers/usb/dwc3/core.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 8002c23a5a02..20945cad29a1 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -2439,8 +2439,6 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
switch (dwc->current_dr_role) {
case DWC3_GCTL_PRTCAP_DEVICE:
- if (pm_runtime_suspended(dwc->dev))
- break;
ret = dwc3_gadget_suspend(dwc);
if (ret)
return ret;
@@ -2671,6 +2669,9 @@ int dwc3_pm_suspend(struct dwc3 *dwc)
struct device *dev = dwc->dev;
int ret;
+ if (pm_runtime_suspended(dev))
+ pm_runtime_resume(dev);
+
ret = dwc3_suspend_common(dwc, PMSG_SUSPEND);
if (ret)
return ret;
--
2.25.1
Powered by blists - more mailing lists