From owner-p4-projects@FreeBSD.ORG Fri Oct 2 20:55:44 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 94942106568D; Fri, 2 Oct 2009 20:55:44 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4085E1065679 for ; Fri, 2 Oct 2009 20:55:44 +0000 (UTC) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 2FCD68FC0C for ; Fri, 2 Oct 2009 20:55:44 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n92Kth4Z082899 for ; Fri, 2 Oct 2009 20:55:43 GMT (envelope-from scottl@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n92KthGa082897 for perforce@freebsd.org; Fri, 2 Oct 2009 20:55:43 GMT (envelope-from scottl@freebsd.org) Date: Fri, 2 Oct 2009 20:55:43 GMT Message-Id: <200910022055.n92KthGa082897@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to scottl@freebsd.org using -f From: Scott Long To: Perforce Change Reviews Cc: Subject: PERFORCE change 169159 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Oct 2009 20:55:44 -0000 http://perforce.freebsd.org/chv.cgi?CH=169159 Change 169159 by scottl@scottl-y1 on 2009/10/02 20:54:52 Quick and dirty hack to use the config_intrhook mechanism to synchronizing bus scan. Not sure if it's sufficient as it doesn't refcount the scans. USB is resistant to reliable refcounting, unfortunately. Affected files ... .. //depot/projects/firewire/sys/dev/usb/controller/usb_controller.c#2 edit .. //depot/projects/firewire/sys/dev/usb/usb_bus.h#2 edit Differences ... ==== //depot/projects/firewire/sys/dev/usb/controller/usb_controller.c#2 (text+ko) ==== @@ -67,6 +67,7 @@ static device_detach_t usb_detach; static void usb_attach_sub(device_t, struct usb_bus *); +static void usb_bus_config_hook(void *arg); /* static variables */ @@ -78,11 +79,6 @@ "Debug level"); #endif -static int usb_no_boot_wait = 0; -TUNABLE_INT("hw.usb.no_boot_wait", &usb_no_boot_wait); -SYSCTL_INT(_hw_usb, OID_AUTO, no_boot_wait, CTLFLAG_RDTUN, &usb_no_boot_wait, 0, - "No device enumerate waiting at boot."); - static devclass_t usb_devclass; static device_method_t usb_methods[] = { @@ -134,11 +130,6 @@ return (ENXIO); } - if (usb_no_boot_wait == 0) { - /* delay vfs_mountroot until the bus is explored */ - bus->bus_roothold = root_mount_hold(device_get_nameunit(dev)); - } - usb_attach_sub(dev, bus); return (0); /* return success */ @@ -161,12 +152,6 @@ /* Stop power watchdog */ usb_callout_drain(&bus->power_wdog); - /* Let the USB explore process detach all devices. */ - if (bus->bus_roothold != NULL) { - root_mount_rel(bus->bus_roothold); - bus->bus_roothold = NULL; - } - USB_BUS_LOCK(bus); if (usb_proc_msignal(&bus->explore_proc, &bus->detach_msg[0], &bus->detach_msg[1])) { @@ -239,9 +224,11 @@ (udev->hub->explore) (udev); USB_BUS_LOCK(bus); } - if (bus->bus_roothold != NULL) { - root_mount_rel(bus->bus_roothold); - bus->bus_roothold = NULL; + + if (bus->usb_config_hook != NULL) { + config_intrhook_disestablish(bus->usb_config_hook); + free(bus->usb_config_hook, M_TEMP); + bus->usb_config_hook = NULL; } } @@ -447,16 +434,31 @@ "process failed.\n"); } else { /* Get final attach going */ - USB_BUS_LOCK(bus); - if (usb_proc_msignal(&bus->explore_proc, - &bus->attach_msg[0], &bus->attach_msg[1])) { - /* ignore */ - } - USB_BUS_UNLOCK(bus); + bus->usb_config_hook = malloc(sizeof(struct intr_config_hook), + M_TEMP, M_ZERO); + bus->usb_config_hook->ich_func = usb_bus_config_hook; + bus->usb_config_hook->ich_arg = bus; + config_intrhook_establish(bus->usb_config_hook); + } +} + +static void +usb_bus_config_hook(void *arg) +{ + struct usb_bus *bus; + + bus = (struct usb_bus *)arg; - /* Do initial explore */ - usb_needs_explore(bus, 1); + USB_BUS_LOCK(bus); + bus->buses_to_explore = 0; + if (usb_proc_msignal(&bus->explore_proc, + &bus->attach_msg[0], &bus->attach_msg[1])) { + /* ignore */ } + USB_BUS_UNLOCK(bus); + + /* Do initial explore */ + usb_needs_explore(bus, 1); } SYSUNINIT(usb_bus_unload, SI_SUB_KLD, SI_ORDER_ANY, usb_bus_unload, NULL); ==== //depot/projects/firewire/sys/dev/usb/usb_bus.h#2 (text+ko) ==== @@ -51,7 +51,7 @@ struct usb_bus { struct usb_bus_stat stats_err; struct usb_bus_stat stats_ok; - struct root_hold_token *bus_roothold; + struct intr_config_hook *usb_config_hook; /* * There are two callback processes. One for Giant locked * callbacks. One for non-Giant locked callbacks. This should