summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/usb.c
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2014-12-18 10:44:17 +0000
committermpi <mpi@openbsd.org>2014-12-18 10:44:17 +0000
commit8dafe54adcd775a216b17d85b80b81947967fb86 (patch)
treef611db2ccf9945bd64148a9ed110c4b0e0897d72 /sys/dev/usb/usb.c
parentDocument * and :: to listen on all IPv4 or IPv6 addresses. (diff)
downloadwireguard-openbsd-8dafe54adcd775a216b17d85b80b81947967fb86.tar.xz
wireguard-openbsd-8dafe54adcd775a216b17d85b80b81947967fb86.zip
If a host controller has been detached or reported a halt condition it
should be considered as dead. In such condition the stack no longer submits I/O or schedules any USB task for its bus. However we need an explore task to detach the root hub since only the task thread is supposed to discover buses and attach/detach devices in order to avoid races. So reset the bus' dying flag when marking it as disconnecting in order to let the task be scheduled. This should be safe because a detached or halted HC should not trigger any new interrupt. Fix a panic when detaching USB PCMCIA cards reported by Tilo Stritzky.
Diffstat (limited to 'sys/dev/usb/usb.c')
-rw-r--r--sys/dev/usb/usb.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c
index ef99af42c9e..ab8ce995603 100644
--- a/sys/dev/usb/usb.c
+++ b/sys/dev/usb/usb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb.c,v 1.102 2014/08/10 11:18:57 mpi Exp $ */
+/* $OpenBSD: usb.c,v 1.103 2014/12/18 10:44:17 mpi Exp $ */
/* $NetBSD: usb.c,v 1.77 2003/01/01 00:10:26 thorpej Exp $ */
/*
@@ -262,6 +262,13 @@ usb_detach_roothub(struct usb_softc *sc)
* it.
*/
sc->sc_bus->flags |= USB_BUS_DISCONNECTING;
+ /*
+ * Reset the dying flag in case it has been set by the interrupt
+ * handler when unplugging an HC card otherwise the task wont be
+ * scheduled. This is safe since a dead HC should not trigger
+ * new interrupt.
+ */
+ sc->sc_bus->dying = 0;
usb_needs_explore(sc->sc_bus->root_hub, 0);
usb_wait_task(sc->sc_bus->root_hub, &sc->sc_explore_task);