PERFORCE change 155204 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Tue Dec 23 13:27:59 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=155204
Change 155204 by hselasky at hselasky_laptop001 on 2008/12/23 21:27:14
Fix a problem where the root HUB
must be allowed to do an explore during
initial attach.
Improve bootup time significantly by
parallell probing the USB root HUBs.
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb2/controller/usb2_bus.h#7 edit
.. //depot/projects/usb/src/sys/dev/usb2/controller/usb2_controller.c#18 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb2/controller/usb2_bus.h#7 (text+ko) ====
@@ -54,6 +54,7 @@
struct usb2_process explore_proc;
struct usb2_bus_msg explore_msg[2];
struct usb2_bus_msg detach_msg[2];
+ struct usb2_bus_msg attach_msg[2];
/*
* This mutex protects the USB hardware:
*/
==== //depot/projects/usb/src/sys/dev/usb2/controller/usb2_controller.c#18 (text+ko) ====
@@ -272,24 +272,24 @@
}
/*------------------------------------------------------------------------*
- * usb2_attach_sub
+ * usb2_bus_attach
*
- * This function is the real USB bus attach code. It is factored out,
- * hence it can be called at two different places in time. During
- * bootup this function is called from "usb2_post_init". During
- * hot-plug it is called directly from the "usb2_attach()" method.
+ * This function attaches USB in context of the explore thread.
*------------------------------------------------------------------------*/
static void
-usb2_attach_sub(device_t dev, struct usb2_bus *bus)
+usb2_bus_attach(struct usb2_proc_msg *pm)
{
+ struct usb2_bus *bus;
struct usb2_device *child;
+ device_t dev;
usb2_error_t err;
uint8_t speed;
+ bus = ((struct usb2_bus_msg *)pm)->bus;
+ dev = bus->bdev;
+
DPRINTF("\n");
- mtx_assert(&Giant, MA_OWNED);
-
switch (bus->usbrev) {
case USB_REV_1_0:
speed = USB_SPEED_FULL;
@@ -316,6 +316,9 @@
return;
}
+ USB_BUS_UNLOCK(bus);
+ mtx_lock(&Giant); /* XXX not required by USB */
+
/* Allocate the Root USB device */
child = usb2_alloc_device(bus->bdev, bus, NULL, 0, 0, 1,
@@ -332,10 +335,36 @@
err = USB_ERR_NOMEM;
}
+ mtx_unlock(&Giant);
+ USB_BUS_LOCK(bus);
+
if (err) {
device_printf(bus->bdev, "Root HUB problem, error=%s\n",
usb2_errstr(err));
}
+
+ /* set softc - we are ready */
+ device_set_softc(dev, bus);
+
+ /* start watchdog - this function will unlock the BUS lock ! */
+ usb2_power_wdog(bus);
+
+ /* need to return locked */
+ USB_BUS_LOCK(bus);
+}
+
+/*------------------------------------------------------------------------*
+ * usb2_attach_sub
+ *
+ * This function creates a thread which runs the USB attach code. It
+ * is factored out, hence it can be called at two different places in
+ * time. During bootup this function is called from
+ * "usb2_post_init". During hot-plug it is called directly from the
+ * "usb2_attach()" method.
+ *------------------------------------------------------------------------*/
+static void
+usb2_attach_sub(device_t dev, struct usb2_bus *bus)
+{
/* Initialise USB process messages */
bus->explore_msg[0].hdr.pm_callback = &usb2_bus_explore;
bus->explore_msg[0].bus = bus;
@@ -347,17 +376,24 @@
bus->detach_msg[1].hdr.pm_callback = &usb2_bus_detach;
bus->detach_msg[1].bus = bus;
+ bus->attach_msg[0].hdr.pm_callback = &usb2_bus_attach;
+ bus->attach_msg[0].bus = bus;
+ bus->attach_msg[1].hdr.pm_callback = &usb2_bus_attach;
+ bus->attach_msg[1].bus = bus;
+
/* Create a new USB process */
if (usb2_proc_setup(&bus->explore_proc,
&bus->bus_mtx, USB_PRI_MED)) {
printf("WARNING: Creation of USB explore process failed.\n");
+ } else {
+ /* Get final attach going */
+ USB_BUS_LOCK(bus);
+ if (usb2_proc_msignal(&bus->explore_proc,
+ &bus->attach_msg[0], &bus->attach_msg[1])) {
+ /* ignore */
+ }
+ USB_BUS_UNLOCK(bus);
}
- /* set softc - we are ready */
- device_set_softc(dev, bus);
- /* start watchdog */
- USB_BUS_LOCK(bus);
- /* this function will unlock the BUS lock ! */
- usb2_power_wdog(bus);
}
/*------------------------------------------------------------------------*
More information about the p4-projects
mailing list