Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb usbdi(9): Make sure aborting a pipe waits for al...
details: https://anonhg.NetBSD.org/src/rev/b9e9b89bff6b
branches: trunk
changeset: 364381:b9e9b89bff6b
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Mar 20 00:40:52 2022 +0000
description:
usbdi(9): Make sure aborting a pipe waits for all callbacks.
There may be a callback in flight from an xfer that has already been
taken off the queue by the time usbd_ar_pipe gets to it. We must
guarantee that even that callback has completed before returning
control to the caller.
diffstat:
sys/dev/usb/usbdi.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diffs (38 lines):
diff -r 0f0ec0fd0c4c -r b9e9b89bff6b sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c Sun Mar 20 00:19:11 2022 +0000
+++ b/sys/dev/usb/usbdi.c Sun Mar 20 00:40:52 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.c,v 1.239 2022/03/19 10:05:52 riastradh Exp $ */
+/* $NetBSD: usbdi.c,v 1.240 2022/03/20 00:40:52 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.239 2022/03/19 10:05:52 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.240 2022/03/20 00:40:52 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -1071,6 +1071,19 @@
}
}
+ /*
+ * There may be an xfer callback already in progress which was
+ * taken off the queue before we got to it. We must wait for
+ * the callback to finish before returning control to the
+ * caller.
+ */
+ while (pipe->up_callingxfer) {
+ USBHIST_LOG(usbdebug, "wait for callback"
+ "pipe = %#jx xfer = %#jx",
+ (uintptr_t)pipe, (uintptr_t)pipe->up_callingxfer, 0, 0);
+ cv_wait(&pipe->up_callingcv, pipe->up_dev->ud_bus->ub_lock);
+ }
+
KASSERT(mutex_owned(pipe->up_dev->ud_bus->ub_lock));
KASSERTMSG(pipe->up_abortlwp == curlwp, "pipe->up_abortlwp=%p",
pipe->up_abortlwp);
Home |
Main Index |
Thread Index |
Old Index