diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2005-10-11 09:09:22 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2005-10-11 09:09:22 +0000 |
commit | e95cb658412bd7b36b6183ba5b9dd9b5645a0acd (patch) | |
tree | 04fdb728efdcd80c66da1d47e8f4430958b8fcbb /sys/dev/usb/usb.c | |
parent | c9ec682a78051706752b6df5886296cb43b07be3 (diff) |
make all usb1 controllers sleep until all the usb2 controllers have probed
and handed over any usb1 devices to the companion. without this usb1
devices didnt appear till after root was mounted, which is frustrating if
you want to use a usb keyboard to enter the root device.
tested by kettenis@ and drahn@
ok drahn@ go for it deraadt@
Diffstat (limited to 'sys/dev/usb/usb.c')
-rw-r--r-- | sys/dev/usb/usb.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index b5aa2161c6b..5f65b0597bf 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb.c,v 1.30 2004/12/12 05:17:40 dlg Exp $ */ +/* $OpenBSD: usb.c,v 1.31 2005/10/11 09:09:21 dlg Exp $ */ /* $NetBSD: usb.c,v 1.77 2003/01/01 00:10:26 thorpej Exp $ */ /* @@ -119,6 +119,8 @@ const struct cdevsw usb_cdevsw = { }; #endif +Static volatile int threads_pending = 0; + Static void usb_discover(void *); Static void usb_create_event_thread(void *); Static void usb_event_thread(void *); @@ -246,6 +248,9 @@ usb_create_event_thread(void *arg) struct usb_softc *sc = arg; static int created = 0; + if (sc->sc_bus->usbrev == USBREV_2_0) + threads_pending++; + if (usb_kthread_create1(usb_event_thread, sc, &sc->sc_event_thread, "%s", sc->sc_dev.dv_xname)) { printf("%s: unable to create event thread for\n", @@ -305,11 +310,21 @@ usb_event_thread(void *arg) DPRINTF(("usb_event_thread: start\n")); + /* USB1 threads wait for USB2 threads to finish their first probe. */ + while (sc->sc_bus->usbrev != USBREV_2_0 && threads_pending) + (void)tsleep((void *)&threads_pending, PWAIT, "config", 0); + /* Make sure first discover does something. */ sc->sc_bus->needs_explore = 1; usb_discover(sc); config_pending_decr(); + /* Wake up any companions waiting for handover before their probes. */ + if (sc->sc_bus->usbrev == USBREV_2_0) { + threads_pending--; + wakeup((void *)&threads_pending); + } + while (!sc->sc_dying) { #ifdef USB_DEBUG if (usb_noexplore < 2) |