Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb New xfer state variables ux_timeout_set and ux_t...



details:   https://anonhg.NetBSD.org/src/rev/18c9a25b5442
branches:  trunk
changeset: 1007266:18c9a25b5442
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Feb 12 16:00:17 2020 +0000

description:
New xfer state variables ux_timeout_set and ux_timeout_reset.

These are needed because:

- The host controller interrupt cannot wait for the callout or task
  to finish running.

- Nothing in the USBD API as is waits for the callout or task to
  finish running.

- Callers expect to be able to resubmit USB xfers from xfer callbacks
  without waiting for anything to finish running.

The variable ux_timeout_set can be used by a host controller to
decide on submission whether to schedule the callout or to ask an
already-scheduled callout or already-queued task to reschedule the
callout, by setting the variable ux_timeout_reset to true.

When the callout or task runs and sees that ux_timeout_reset is true,
rather than queue the task or abort the xfer, it can instead just
schedule the callout anew.

diffstat:

 sys/dev/usb/usbdi.c    |   5 +++--
 sys/dev/usb/usbdivar.h |  15 ++++++++++++++-
 2 files changed, 17 insertions(+), 3 deletions(-)

diffs (55 lines):

diff -r 1bc6ee8e0178 -r 18c9a25b5442 sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c       Wed Feb 12 15:59:59 2020 +0000
+++ b/sys/dev/usb/usbdi.c       Wed Feb 12 16:00:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi.c,v 1.190 2020/02/12 15:59:59 riastradh Exp $    */
+/*     $NetBSD: usbdi.c,v 1.191 2020/02/12 16:00:17 riastradh Exp $    */
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.190 2020/02/12 15:59:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.191 2020/02/12 16:00:17 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -494,6 +494,7 @@
 
        /* Wait for any straggling timeout to complete. */
        mutex_enter(xfer->ux_bus->ub_lock);
+       xfer->ux_timeout_reset = false; /* do not resuscitate */
        callout_halt(&xfer->ux_callout, xfer->ux_bus->ub_lock);
        usb_rem_task_wait(xfer->ux_pipe->up_dev, &xfer->ux_aborttask,
            USB_TASKQ_HC, xfer->ux_bus->ub_lock);
diff -r 1bc6ee8e0178 -r 18c9a25b5442 sys/dev/usb/usbdivar.h
--- a/sys/dev/usb/usbdivar.h    Wed Feb 12 15:59:59 2020 +0000
+++ b/sys/dev/usb/usbdivar.h    Wed Feb 12 16:00:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdivar.h,v 1.120 2020/02/08 08:47:27 maxv Exp $      */
+/*     $NetBSD: usbdivar.h,v 1.121 2020/02/12 16:00:17 riastradh Exp $ */
 
 /*
  * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -288,6 +288,19 @@
 
        struct usb_task         ux_aborttask;
        struct callout          ux_callout;
+
+       /*
+        * Protected by bus lock.
+        *
+        * - ux_timeout_set: The timeout is scheduled as a callout or
+        *   usb task, and has not yet acquired the bus lock.
+        *
+        * - ux_timeout_reset: The xfer completed, and was resubmitted
+        *   before the callout or task was able to acquire the bus
+        *   lock, so one or the other needs to schedule a new callout.
+        */
+       bool                    ux_timeout_set;
+       bool                    ux_timeout_reset;
 };
 
 void usbd_init(void);



Home | Main Index | Thread Index | Old Index