Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: dummy_hcd: add tick_us module parameter for
@ 2026-08-23 17:15 Mikhail Zubenko
  2026-08-23 17:25 ` Greg Kroah-Hartman
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Mikhail Zubenko @ 2026-08-23 17:15 UTC (permalink / raw)
  To: linux-usb; +Cc: Greg Kroah-Hartman, Alan Stern

From: Mikhail Zubenko <misha.zubenko.01@yandex.ru>
Date: Sun, 23 Aug 2026 17:12:49 +0000
Subject: [PATCH] usb: gadget: dummy_hcd: add tick_us module parameter for
 timer-rate tuning

The simulated controller completes URBs on a hrtimer armed at a fixed
125 us (one high-speed microframe). Against a permanently polled HID
interrupt endpoint this creates a self-sustaining pendulum at ~8 kHz:
every completion triggers an immediate resubmit, which rearms the
timer. The rate is unconditional - it does not depend on traffic.

On timer-rate-sensitive platforms (observed: one consumer AM4 board,
BIOS current, stock kernel) this pendulum co-existing with a live
Bluetooth session behind the same xHCI controller results in a hard,
below-software platform hang: printk, SysRq, NMI and both watchdogs
die in the same instant, with no panic, no MCE, and empty pstore.
13 occurrences over 5 days, fully reproducible; the same workload
with the pendulum slowed to 1000 us (this parameter) ran ~8 hours
with zero hangs, and USB-cable sessions (identical gadget traffic,
no BT co-existence) never hung.

Nothing else in the driver's behaviour depends on the exact tick:
the bandwidth model accounts per-frame budget regardless of how
often frames are simulated, so a larger tick trades latency
(1 ms added worst case at tick_us=1000) for interrupt-rate headroom.

Default keeps the current 125 us behaviour bit-for-bit.

Signed-off-by: Mikhail Zubenko <misha.zubenko.01@yandex.ru>
---
 drivers/usb/gadget/udc/dummy_hcd.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index c0e40fa..f185b87 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -51,7 +51,7 @@
 #define POWER_BUDGET	500	/* in mA; use 8 for low-power port testing */
 #define POWER_BUDGET_3	900	/* in mA */
 
-#define DUMMY_TIMER_INT_NSECS	125000 /* 1 microframe */
+#define DUMMY_TIMER_INT_NSECS	((u64)tick_us * NSEC_PER_USEC)
 
 static const char	driver_name[] = "dummy_hcd";
 static const char	driver_desc[] = "USB Host+Gadget Emulator";
@@ -79,6 +79,12 @@ module_param_named(is_high_speed, mod_data.is_high_speed, bool, S_IRUGO);
 MODULE_PARM_DESC(is_high_speed, "true to simulate HighSpeed connection");
 module_param_named(num, mod_data.num, uint, S_IRUGO);
 MODULE_PARM_DESC(num, "number of emulated controllers");
+
+static unsigned int tick_us = 125;
+module_param(tick_us, uint, 0644);
+MODULE_PARM_DESC(tick_us,
+		"enqueue-to-completion latency of the simulated controller, in microseconds (default 125, one high-speed microframe);"
+		" larger values slow the internal timer pendulum and reduce its interrupt-rate pressure on the host platform");
 /*-------------------------------------------------------------------------*/
 
 /* gadget side driver data structures */
-- 
2.43.0


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

end of thread, other threads:[~2026-08-25  1:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-23 17:15 [PATCH] usb: gadget: dummy_hcd: add tick_us module parameter for Mikhail Zubenko
2026-08-23 17:25 ` Greg Kroah-Hartman
2026-08-23 19:55 ` Alan Stern
2026-08-24  8:29 ` [PATCH v2] usb: gadget: dummy_hcd: add tick_us module parameter for timer-rate tuning Mikhail Zubenko
2026-08-24  8:29 ` Mikhail Zubenko
2026-08-24  8:43   ` Greg Kroah-Hartman
2026-08-24  9:12 ` [PATCH v3] " Mikhail Zubenko
2026-08-24  9:40   ` Greg Kroah-Hartman
2026-08-24 10:42 ` Mikhail Zubenko
2026-08-24 10:42 ` [PATCH v4] " Mikhail Zubenko
2026-08-24 14:27   ` Alan Stern
2026-08-24 15:54 ` [PATCH v5] " Mikhail Zubenko
2026-08-25  1:42   ` Alan Stern

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