usb: gadget: dummy_hcd: Set transfer interval to 1 microframe
authorMarcello Sylvester Bauer <sylv@sylv.io>
Thu, 11 Apr 2024 15:22:11 +0000 (17:22 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Apr 2024 14:47:07 +0000 (16:47 +0200)
Currently, the transfer polling interval is set to 1ms, which is the
frame rate of full-speed and low-speed USB. The USB 2.0 specification
introduces microframes (125 microseconds) to improve the timing
precision of data transfers.

Reducing the transfer interval to 1 microframe increases data throughput
for high-speed and super-speed USB communication

Signed-off-by: Marcello Sylvester Bauer <marcello.bauer@9elements.com>
Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
Link: https://lore.kernel.org/r/6295dbb84ca76884551df9eb157cce569377a22c.1712843963.git.sylv@sylv.io
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/udc/dummy_hcd.c

index dab559d8ee8ca455eeeeee22e99f477880dbf2ed..f37b0d8386c1a934c9223c799d6f4fc346bdd4ee 100644 (file)
@@ -50,6 +50,8 @@
 #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 */
+
 static const char      driver_name[] = "dummy_hcd";
 static const char      driver_desc[] = "USB Host+Gadget Emulator";
 
@@ -1302,7 +1304,7 @@ static int dummy_urb_enqueue(
 
        /* kick the scheduler, it'll do the rest */
        if (!hrtimer_active(&dum_hcd->timer))
-               hrtimer_start(&dum_hcd->timer, ms_to_ktime(1), HRTIMER_MODE_REL);
+               hrtimer_start(&dum_hcd->timer, ns_to_ktime(DUMMY_TIMER_INT_NSECS), HRTIMER_MODE_REL);
 
  done:
        spin_unlock_irqrestore(&dum_hcd->dum->lock, flags);
@@ -1993,7 +1995,7 @@ return_urb:
                dum_hcd->udev = NULL;
        } else if (dum_hcd->rh_state == DUMMY_RH_RUNNING) {
                /* want a 1 msec delay here */
-               hrtimer_start(&dum_hcd->timer, ms_to_ktime(1), HRTIMER_MODE_REL);
+               hrtimer_start(&dum_hcd->timer, ns_to_ktime(DUMMY_TIMER_INT_NSECS), HRTIMER_MODE_REL);
        }
 
        spin_unlock_irqrestore(&dum->lock, flags);