From owner-svn-src-stable@FreeBSD.ORG Thu Oct 29 23:09:03 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0925D1065670; Thu, 29 Oct 2009 23:09:03 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E87348FC15; Thu, 29 Oct 2009 23:09:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9TN92U4013618; Thu, 29 Oct 2009 23:09:02 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9TN92NC013616; Thu, 29 Oct 2009 23:09:02 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200910292309.n9TN92NC013616@svn.freebsd.org> From: Andrew Thompson Date: Thu, 29 Oct 2009 23:09:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198630 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb/controller dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Oct 2009 23:09:03 -0000 Author: thompsa Date: Thu Oct 29 23:09:02 2009 New Revision: 198630 URL: http://svn.freebsd.org/changeset/base/198630 Log: MFC r196488 - allow disabling "root_mount_hold()" by setting a sysctl/tunable at boot - remove some redundant initial explore code Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/usb/controller/usb_controller.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/usb/controller/usb_controller.c ============================================================================== --- stable/8/sys/dev/usb/controller/usb_controller.c Thu Oct 29 21:30:21 2009 (r198629) +++ stable/8/sys/dev/usb/controller/usb_controller.c Thu Oct 29 23:09:02 2009 (r198630) @@ -67,7 +67,6 @@ static device_attach_t usb_attach; static device_detach_t usb_detach; static void usb_attach_sub(device_t, struct usb_bus *); -static void usb_post_init(void *); /* static variables */ @@ -84,8 +83,6 @@ TUNABLE_INT("hw.usb.no_boot_wait", &usb_ SYSCTL_INT(_hw_usb, OID_AUTO, no_boot_wait, CTLFLAG_RDTUN, &usb_no_boot_wait, 0, "No device enumerate waiting at boot."); -static uint8_t usb_post_init_called = 0; - static devclass_t usb_devclass; static device_method_t usb_methods[] = { @@ -142,12 +139,8 @@ usb_attach(device_t dev) bus->bus_roothold = root_mount_hold(device_get_nameunit(dev)); } - if (usb_post_init_called) { - mtx_lock(&Giant); - usb_attach_sub(dev, bus); - mtx_unlock(&Giant); - usb_needs_explore(bus, 1); - } + usb_attach_sub(dev, bus); + return (0); /* return success */ } @@ -226,22 +219,24 @@ usb_bus_explore(struct usb_proc_msg *pm) /* avoid zero, hence that is memory default */ bus->driver_added_refcount = 1; } - USB_BUS_UNLOCK(bus); - mtx_lock(&Giant); + /* + * The following three lines of code are only here to + * recover from DDB: + */ + usb_proc_rewakeup(&bus->control_xfer_proc); + usb_proc_rewakeup(&bus->giant_callback_proc); + usb_proc_rewakeup(&bus->non_giant_callback_proc); + + USB_BUS_UNLOCK(bus); /* * First update the USB power state! */ usb_bus_powerd(bus); - /* - * Explore the Root USB HUB. This call can sleep, - * exiting Giant, which is actually Giant. - */ - (udev->hub->explore) (udev); - - mtx_unlock(&Giant); + /* Explore the Root USB HUB. */ + (udev->hub->explore) (udev); USB_BUS_LOCK(bus); } if (bus->bus_roothold != NULL) { @@ -269,10 +264,10 @@ usb_bus_detach(struct usb_proc_msg *pm) device_set_softc(dev, NULL); USB_BUS_UNLOCK(bus); - mtx_lock(&Giant); - /* detach children first */ + mtx_lock(&Giant); bus_generic_detach(dev); + mtx_unlock(&Giant); /* * Free USB Root device, but not any sub-devices, hence they @@ -281,7 +276,6 @@ usb_bus_detach(struct usb_proc_msg *pm) usb_free_device(udev, USB_UNCFG_FLAG_FREE_EP0); - mtx_unlock(&Giant); USB_BUS_LOCK(bus); /* clear bdev variable last */ bus->bdev = NULL; @@ -297,6 +291,12 @@ usb_power_wdog(void *arg) usb_callout_reset(&bus->power_wdog, 4 * hz, usb_power_wdog, arg); + /* + * The following line of code is only here to recover from + * DDB: + */ + usb_proc_rewakeup(&bus->explore_proc); /* recover from DDB */ + USB_BUS_UNLOCK(bus); usb_bus_power_update(bus); @@ -350,7 +350,6 @@ usb_bus_attach(struct usb_proc_msg *pm) } USB_BUS_UNLOCK(bus); - mtx_lock(&Giant); /* XXX not required by USB */ /* default power_mask value */ bus->hw_power_state = @@ -383,7 +382,6 @@ usb_bus_attach(struct usb_proc_msg *pm) err = USB_ERR_NOMEM; } - mtx_unlock(&Giant); USB_BUS_LOCK(bus); if (err) { @@ -401,17 +399,18 @@ usb_bus_attach(struct usb_proc_msg *pm) /*------------------------------------------------------------------------* * usb_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 - * "usb_post_init". During hot-plug it is called directly from the - * "usb_attach()" method. + * This function creates a thread which runs the USB attach code. *------------------------------------------------------------------------*/ static void usb_attach_sub(device_t dev, struct usb_bus *bus) { const char *pname = device_get_nameunit(dev); + mtx_lock(&Giant); + if (usb_devclass_ptr == NULL) + usb_devclass_ptr = devclass_find("usbus"); + mtx_unlock(&Giant); + /* Initialise USB process messages */ bus->explore_msg[0].hdr.pm_callback = &usb_bus_explore; bus->explore_msg[0].bus = bus; @@ -454,55 +453,12 @@ usb_attach_sub(device_t dev, struct usb_ /* ignore */ } USB_BUS_UNLOCK(bus); - } -} - -/*------------------------------------------------------------------------* - * usb_post_init - * - * This function is called to attach all USB busses that were found - * during bootup. - *------------------------------------------------------------------------*/ -static void -usb_post_init(void *arg) -{ - struct usb_bus *bus; - devclass_t dc; - device_t dev; - int max; - int n; - mtx_lock(&Giant); - - usb_devclass_ptr = devclass_find("usbus"); - - dc = usb_devclass_ptr; - if (dc) { - max = devclass_get_maxunit(dc) + 1; - for (n = 0; n != max; n++) { - dev = devclass_get_device(dc, n); - if (dev && device_is_attached(dev)) { - bus = device_get_ivars(dev); - if (bus) { - mtx_lock(&Giant); - usb_attach_sub(dev, bus); - mtx_unlock(&Giant); - } - } - } - } else { - DPRINTFN(0, "no devclass\n"); + /* Do initial explore */ + usb_needs_explore(bus, 1); } - usb_post_init_called = 1; - - /* explore all USB busses in parallell */ - - usb_needs_explore_all(); - - mtx_unlock(&Giant); } -SYSINIT(usb_post_init, SI_SUB_KICK_SCHEDULER, SI_ORDER_ANY, usb_post_init, NULL); SYSUNINIT(usb_bus_unload, SI_SUB_KLD, SI_ORDER_ANY, usb_bus_unload, NULL); /*------------------------------------------------------------------------*