Module Name: src
Committed By: riastradh
Date: Wed Feb 12 15:59:59 UTC 2020
Modified Files:
src/sys/dev/usb: usbdi.c
Log Message:
Nothing guarantees xfer's timeout has completed.
Wait for it when we free the xfer.
To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/sys/dev/usb/usbdi.c
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.189 src/sys/dev/usb/usbdi.c:1.190
--- src/sys/dev/usb/usbdi.c:1.189 Sat Feb 8 07:57:16 2020
+++ src/sys/dev/usb/usbdi.c Wed Feb 12 15:59:59 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.c,v 1.189 2020/02/08 07:57:16 maxv Exp $ */
+/* $NetBSD: usbdi.c,v 1.190 2020/02/12 15:59:59 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.189 2020/02/08 07:57:16 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.190 2020/02/12 15:59:59 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -491,12 +491,14 @@ usbd_free_xfer(struct usbd_xfer *xfer)
if (xfer->ux_buf) {
usbd_free_buffer(xfer);
}
-#if defined(DIAGNOSTIC)
- if (callout_pending(&xfer->ux_callout)) {
- callout_stop(&xfer->ux_callout);
- printf("usbd_free_xfer: timeout_handle pending\n");
- }
-#endif
+
+ /* Wait for any straggling timeout to complete. */
+ mutex_enter(xfer->ux_bus->ub_lock);
+ 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);
+ mutex_exit(xfer->ux_bus->ub_lock);
+
cv_destroy(&xfer->ux_cv);
xfer->ux_bus->ub_methods->ubm_freex(xfer->ux_bus, xfer);
return USBD_NORMAL_COMPLETION;