usb_detach_wait() will simply wait usb_detach_wakeup() for 60 sec. So
ugen_detach() will continue to destroy device context before threads
finish their io.

Index: sys/dev/usb/ugen.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/ugen.c,v
retrieving revision 1.105
diff -u -p -r1.105 ugen.c
--- sys/dev/usb/ugen.c  7 Apr 2020 13:27:51 -0000       1.105
+++ sys/dev/usb/ugen.c  9 Apr 2020 14:08:20 -0000
@@ -764,7 +764,8 @@ ugen_detach(struct device *self, int fla
        }
 
        s = splusb();
-       if (--sc->sc_refcnt >= 0) {
+       --sc->sc_refcnt;
+       while (sc->sc_refcnt >= 0) {
                /* Wake everyone */
                for (i = 0; i < USB_MAX_ENDPOINTS; i++)
                        wakeup(&sc->sc_endpoints[i][IN]);

Reply via email to