From cdaa2b6287c7cd0aba59fe9650ce03ac9171c4b7 Mon Sep 17 00:00:00 2001 From: riastradh Date: Tue, 7 Sep 2021 10:43:34 +0000 Subject: 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. --- sys/dev/usb/ugen.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index 986484898e9..894be8ec928 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -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 -__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)) -- cgit