Module Name:    src
Committed By:   riastradh
Date:           Tue Sep  7 10:43:34 UTC 2021

Modified Files:
        src/sys/dev/usb: ugen.c

Log Message:
ugen(4): Use cv_broadcast to wake all I/O operations on detach.

Nothing prevents two concurrent reads or two concurrent writes on any
particular ugen endpoint, as far as I can tell, and we need to wake
all of them, so use cv_broadcast rather than cv_signal on detach.

XXX It's not clear to me that cv_signal in the xfer completion
callbacks is correct either: any one consumer might use less than the
full buffer.  So I think either we should use cv_broadcast, or
consumers that don't use the whole buffer need to issue cv_signal too
to wake up another consumer even if we want to avoid a thundering
herd.


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sys/dev/usb/ugen.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/ugen.c
diff -u src/sys/dev/usb/ugen.c:1.164 src/sys/dev/usb/ugen.c:1.165
--- src/sys/dev/usb/ugen.c:1.164	Tue Sep  7 10:43:21 2021
+++ src/sys/dev/usb/ugen.c	Tue Sep  7 10:43:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ugen.c,v 1.164 2021/09/07 10:43:21 riastradh Exp $	*/
+/*	$NetBSD: ugen.c,v 1.165 2021/09/07 10:43:34 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.164 2021/09/07 10:43:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.165 2021/09/07 10:43:34 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1220,7 +1220,7 @@ ugen_detach(device_t self, int flags)
 		/* Wake everyone */
 		for (i = 0; i < USB_MAX_ENDPOINTS; i++) {
 			for (dir = OUT; dir <= IN; dir++)
-				cv_signal(&sc->sc_endpoints[i][dir].cv);
+				cv_broadcast(&sc->sc_endpoints[i][dir].cv);
 		}
 		/* Wait for processes to go away. */
 		if (cv_timedwait(&sc->sc_detach_cv, &sc->sc_lock, hz * 60))

Reply via email to