From 3cb59c8f6c4a52219470d5d6a1d0ae8aaf50b799 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sat, 16 Jun 2007 23:22:32 +0000 Subject: [PATCH] Backout the last commit, it's creating panics. Reported-by: Sascha Wildner --- sys/bus/usb/usb.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/sys/bus/usb/usb.c b/sys/bus/usb/usb.c index 73c0ecea19..02e10a9130 100644 --- a/sys/bus/usb/usb.c +++ b/sys/bus/usb/usb.c @@ -1,6 +1,6 @@ /* $NetBSD: usb.c,v 1.68 2002/02/20 20:30:12 christos Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb.c,v 1.106 2005/03/27 15:31:23 iedowse Exp $ */ -/* $DragonFly: src/sys/bus/usb/usb.c,v 1.27 2007/06/16 20:57:59 dillon Exp $ */ +/* $DragonFly: src/sys/bus/usb/usb.c,v 1.28 2007/06/16 23:22:32 dillon Exp $ /* Also already merged from NetBSD: * $NetBSD: usb.c,v 1.70 2002/05/09 21:54:32 augustss Exp $ @@ -175,8 +175,7 @@ Static void usb_task_thread(void *); #if defined(__FreeBSD__) || defined(__DragonFly__) Static cdev_t usb_dev; /* The /dev/usb device. */ -Static int usb_ndevs; /* Number of /dev/usbN devices. */ -Static int usb_exitevthreads; /* Ask the event threads to exit */ +Static int usb_ndevs; /* Number of /dev/usbN devices. */ #endif #define USB_MAX_EVENTS 100 @@ -280,10 +279,6 @@ USB_ATTACH(usb) usb_callout_init(sc->sc_bus->softi); #endif #endif -#if defined(__FreeBSD__) || defined(__DragonFly__) - usb_exitevthreads = 0; - usb_create_event_thread(sc); -#endif err = usbd_new_device(USBDEV(sc->sc_dev), sc->sc_bus, 0, speed, 0, &sc->sc_port); @@ -332,6 +327,7 @@ USB_ATTACH(usb) #endif #if defined(__FreeBSD__) || defined(__DragonFly__) + usb_create_event_thread(sc); /* The per controller devices (used for usb_discover) */ /* XXX This is redundant now, but old usbd's will want it */ dev_ops_add(&usb_ops, -1, device_get_unit(self)); @@ -359,6 +355,13 @@ usb_create_event_thread(void *arg) struct usb_softc *sc = arg; int i; + if (usb_kthread_create1(usb_event_thread, sc, &sc->sc_event_thread, + "%s", USBDEVNAME(sc->sc_dev))) { + kprintf("%s: unable to create event thread for\n", + USBDEVNAME(sc->sc_dev)); + panic("usb_create_event_thread"); + } + for (i = 0; i < USB_NUM_TASKQS; i++) { struct usb_taskq *taskq = &usb_taskq[i]; @@ -373,12 +376,6 @@ usb_create_event_thread(void *arg) } } } - if (usb_kthread_create1(usb_event_thread, sc, &sc->sc_event_thread, - "%s", USBDEVNAME(sc->sc_dev))) { - kprintf("%s: unable to create event thread for\n", - USBDEVNAME(sc->sc_dev)); - panic("usb_create_event_thread"); - } } /* @@ -508,7 +505,7 @@ usb_task_thread(void *arg) taskq = arg; DPRINTF(("usb_task_thread: start taskq %s\n", taskq->name)); - while (usb_exitevthreads == 0) { + while (usb_ndevs > 0) { task = TAILQ_FIRST(&taskq->tasks); if (task == NULL) { tsleep(&taskq->tasks, 0, "usbtsk", 0); @@ -962,7 +959,6 @@ USB_DETACH(usb) destroy_dev(usb_dev); usb_dev = NULL; - usb_exitevthreads = 1; for (i = 0; i < USB_NUM_TASKQS; i++) { struct usb_taskq *taskq = &usb_taskq[i]; wakeup(&taskq->tasks); -- 2.11.4.GIT