Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Oct 2009 20:55:43 GMT
From:      Scott Long <scottl@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 169159 for review
Message-ID:  <200910022055.n92KthGa082897@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910022055.n92KthGa082897>