Linux USB
 help / color / mirror / Atom feed
* [PATCH v2] usb: chipidea: otg: use autosuspend in ci_otg_work
@ 2026-01-08 15:34 Mario Peter
  2026-01-08 16:12 ` Alan Stern
  0 siblings, 1 reply; 6+ messages in thread
From: Mario Peter @ 2026-01-08 15:34 UTC (permalink / raw)
  To: peter.chen, gregkh; +Cc: linux-usb, Mario Peter

Switch to autosuspend mechanism in ci_otg_work() to prevent race
conditions during rapid device plug/unplug cycles.

The current implementation uses pm_runtime_put_sync() which triggers
immediate runtime suspend. This creates a race condition when a USB
device is unplugged and quickly replugged. The controller may suspend
before the new device detection completes, causing detection to fail.

Replace pm_runtime_put_sync() with pm_runtime_put_sync_autosuspend()
as recommended by Section 9 of Documentation/power/runtime_pm.rst.
This updates the device's last_busy timestamp and delays the suspend
until after the autosuspend_delay period, allowing pending device
detection to complete. As documented, this approach prevents
"bouncing too rapidly between low-power and full-power states".

The synchronous variant pm_runtime_put_sync_autosuspend() is used
(rather than the asynchronous __pm_runtime_put_autosuspend()) to match
the semantics of the original pm_runtime_put_sync() call.

Signed-off-by: Mario Peter <mario.peter@leica-geosystems.com>
---

Testing was performed using a scripted sequence with a relay to simulate
USB plug/unplug operations at various timing intervals, verifying that
devices are consistently detected after replugging.

v1: submitted (https://lore.kernel.org/linux-usb/zuzsjr6isq6i5izw3rkyo45opyikiqjmy5xk7flpmlgmqb6mgh@rpbdvi3s4u54/)
v2: dropped redundant pm_runtime_mark_last_busy() call

 drivers/usb/chipidea/otg.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 647e98f4e351..d19c27f44424 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -230,7 +230,7 @@ static void ci_otg_work(struct work_struct *work)
 		ci_handle_vbus_change(ci);
 	}

-	pm_runtime_put_sync(ci->dev);
+	pm_runtime_put_sync_autosuspend(ci->dev);

 	enable_irq(ci->irq);
 }

base-commit: f0b9d8eb98dfee8d00419aa07543bdc2c1a44fb1
--
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-01-29  9:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-08 15:34 [PATCH v2] usb: chipidea: otg: use autosuspend in ci_otg_work Mario Peter
2026-01-08 16:12 ` Alan Stern
2026-01-09 11:57   ` PETER Mario
2026-01-09 16:23     ` Alan Stern
2026-01-14  1:34     ` Peter Chen (CIX)
2026-01-29  9:40       ` PETER Mario

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox