[PATCH] usb: core: raise root-hub autosuspend delay to stop a busy-loop

From: Jianping Liu

Date: Wed Oct 28 2026 - 00:19:30 EST


From: Jianping Liu <frankjpliu@xxxxxxxxxxx>

hub_probe() sets the hub autosuspend delay to 0. An idle hub is
therefore suspended at once, with no waiting time.

Suspending the root hub can fail. While a port reports over-current
or a connect change, xHCI refuses the bus suspend and returns -EBUSY.
usb_runtime_suspend() returns that error. The hub is resumed, and when
its status URB completes the same suspend runs again.

The PM core would normally leave a gap before that next attempt. It
starts the autosuspend timer only when the delay is still in the
future. A delay of 0 is already due, so no timer is started and there
is nothing to wait for. Suspend and resume repeat immediately, and one
CPU core stays at 100% until the port is no longer stuck.

If a root-hub runtime suspend fails while the delay is still 0, set
the delay to 1000 ms so the next attempt waits. If a later runtime
suspend succeeds and the delay is not 0, put it back to 0.

Signed-off-by: Jianping Liu <frankjpliu@xxxxxxxxxxx>
---
drivers/usb/core/driver.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index d3a61ebc6afb..30965d6ffd67 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -2008,6 +2008,20 @@ int usb_runtime_suspend(struct device *dev)
if (status == -EAGAIN || status == -EBUSY)
usb_mark_last_busy(udev);

+ /*
+ * Root hubs use 0ms delay, so a persistent -EBUSY retries with no
+ * wait and pins one CPU at 100%. Set autosuspend_delay to 1000ms
+ * on fail, then back to 0 ms on success.
+ */
+ if (!udev->parent) {
+ int delay = READ_ONCE(dev->power.autosuspend_delay);
+
+ if (unlikely(status != 0 && delay == 0))
+ pm_runtime_set_autosuspend_delay(dev, 1000);
+ if (unlikely(status == 0 && delay != 0))
+ pm_runtime_set_autosuspend_delay(dev, 0);
+ }
+
/*
* The PM core reacts badly unless the return code is 0,
* -EAGAIN, or -EBUSY, so always return -EBUSY on an error
--
2.43.7