Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb ugen(4): Issue explicit wakeup on detach for OUT...



details:   https://anonhg.NetBSD.org/src/rev/09ec2ae98cda
branches:  trunk
changeset: 985775:09ec2ae98cda
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Sep 07 10:43:21 2021 +0000

description:
ugen(4): Issue explicit wakeup on detach for OUT endpoints too.

Writers can be blocked in cv_timedwait_sig too.

While here, fix comment: aborting the pipes does not cause all
waiters to wake, because the xfer completion callbacks sometimes skip
the notification.  We should maybe change that, but this is a simpler
fix to ensure everyone waiting on I/O is woken to notice sc_dying.

diffstat:

 sys/dev/usb/ugen.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (40 lines):

diff -r f9a8b9664c92 -r 09ec2ae98cda sys/dev/usb/ugen.c
--- a/sys/dev/usb/ugen.c        Tue Sep 07 10:43:11 2021 +0000
+++ b/sys/dev/usb/ugen.c        Tue Sep 07 10:43:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ugen.c,v 1.163 2021/09/07 10:43:11 riastradh Exp $     */
+/*     $NetBSD: ugen.c,v 1.164 2021/09/07 10:43:21 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.163 2021/09/07 10:43:11 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.164 2021/09/07 10:43:21 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1206,7 +1206,7 @@
        if (!sc->sc_attached)
                goto out;
 
-       /* Abort all pipes.  Causes processes waiting for transfer to wake. */
+       /* Abort all pipes.  */
        for (i = 0; i < USB_MAX_ENDPOINTS; i++) {
                for (dir = OUT; dir <= IN; dir++) {
                        sce = &sc->sc_endpoints[i][dir];
@@ -1218,8 +1218,10 @@
        mutex_enter(&sc->sc_lock);
        if (--sc->sc_refcnt >= 0) {
                /* Wake everyone */
-               for (i = 0; i < USB_MAX_ENDPOINTS; i++)
-                       cv_signal(&sc->sc_endpoints[i][IN].cv);
+               for (i = 0; i < USB_MAX_ENDPOINTS; i++) {
+                       for (dir = OUT; dir <= IN; dir++)
+                               cv_signal(&sc->sc_endpoints[i][dir].cv);
+               }
                /* Wait for processes to go away. */
                if (cv_timedwait(&sc->sc_detach_cv, &sc->sc_lock, hz * 60))
                        aprint_error_dev(self, ": didn't detach\n");



Home | Main Index | Thread Index | Old Index