Module Name: src
Committed By: riastradh
Date: Wed Feb 12 16:00:17 UTC 2020
Modified Files:
src/sys/dev/usb: usbdi.c usbdivar.h
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.120 -r1.121 src/sys/dev/usb/usbdivar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/usb/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.190 src/sys/dev/usb/usbdi.c:1.191
--- src/sys/dev/usb/usbdi.c:1.190 Wed Feb 12 15:59:59 2020
+++ src/sys/dev/usb/usbdi.c Wed Feb 12 16:00:17 2020
@@ -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 @@ usbd_free_xfer(struct usbd_xfer *xfer)
/* 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);
Index: src/sys/dev/usb/usbdivar.h
diff -u src/sys/dev/usb/usbdivar.h:1.120 src/sys/dev/usb/usbdivar.h:1.121
--- src/sys/dev/usb/usbdivar.h:1.120 Sat Feb 8 08:47:27 2020
+++ src/sys/dev/usb/usbdivar.h Wed Feb 12 16:00:17 2020
@@ -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 usbd_xfer {
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);