From owner-p4-projects@FreeBSD.ORG Tue Dec 23 21:27:59 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 37F4F1065677; Tue, 23 Dec 2008 21:27:59 +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 F00F41065670 for ; Tue, 23 Dec 2008 21:27:58 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id DD44A8FC0C for ; Tue, 23 Dec 2008 21:27:58 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id mBNLRwIf048920 for ; Tue, 23 Dec 2008 21:27:58 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id mBNLRwsS048918 for perforce@freebsd.org; Tue, 23 Dec 2008 21:27:58 GMT (envelope-from hselasky@FreeBSD.org) Date: Tue, 23 Dec 2008 21:27:58 GMT Message-Id: <200812232127.mBNLRwsS048918@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 155204 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: Tue, 23 Dec 2008 21:27:59 -0000 http://perforce.freebsd.org/chv.cgi?CH=155204 Change 155204 by hselasky@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); } /*------------------------------------------------------------------------*