From owner-svn-src-head@FreeBSD.ORG Thu Oct 9 06:24:07 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A5E59D46; Thu, 9 Oct 2014 06:24:07 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 91A2BB40; Thu, 9 Oct 2014 06:24:07 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s996O7PA081473; Thu, 9 Oct 2014 06:24:07 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s996O78a081471; Thu, 9 Oct 2014 06:24:07 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201410090624.s996O78a081471@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 9 Oct 2014 06:24:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272807 - in head/sys/dev/usb: . controller X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Oct 2014 06:24:07 -0000 Author: hselasky Date: Thu Oct 9 06:24:06 2014 New Revision: 272807 URL: https://svnweb.freebsd.org/changeset/base/272807 Log: Refine support for disabling USB enumeration to allow device detach and suspend and resume of existing devices. MFC after: 2 weeks Modified: head/sys/dev/usb/controller/usb_controller.c head/sys/dev/usb/usb_hub.c Modified: head/sys/dev/usb/controller/usb_controller.c ============================================================================== --- head/sys/dev/usb/controller/usb_controller.c Thu Oct 9 06:02:53 2014 (r272806) +++ head/sys/dev/usb/controller/usb_controller.c Thu Oct 9 06:24:06 2014 (r272807) @@ -102,14 +102,6 @@ static int usb_no_shutdown_wait = 0; SYSCTL_INT(_hw_usb, OID_AUTO, no_shutdown_wait, CTLFLAG_RWTUN, &usb_no_shutdown_wait, 0, "No USB device waiting at system shutdown."); -#if USB_HAVE_DISABLE_ENUM -static int usb_disable_enumeration = 0; -SYSCTL_INT(_hw_usb, OID_AUTO, disable_enumeration, CTLFLAG_RWTUN, - &usb_disable_enumeration, 0, "Set to disable all USB device enumeration."); -#else -#define usb_disable_enumeration 0 -#endif - static devclass_t usb_devclass; static device_method_t usb_methods[] = { @@ -379,8 +371,7 @@ usb_bus_explore(struct usb_proc_msg *pm) USB_BUS_LOCK(bus); } - if (usb_disable_enumeration == 0 && - udev != NULL && udev->hub != NULL) { + if (udev != NULL && udev->hub != NULL) { if (bus->do_probe) { bus->do_probe = 0; Modified: head/sys/dev/usb/usb_hub.c ============================================================================== --- head/sys/dev/usb/usb_hub.c Thu Oct 9 06:02:53 2014 (r272806) +++ head/sys/dev/usb/usb_hub.c Thu Oct 9 06:24:06 2014 (r272807) @@ -97,6 +97,12 @@ SYSCTL_INT(_hw_usb, OID_AUTO, power_time &usb_power_timeout, 0, "USB power timeout"); #endif +#if USB_HAVE_DISABLE_ENUM +static int usb_disable_enumeration = 0; +SYSCTL_INT(_hw_usb, OID_AUTO, disable_enumeration, CTLFLAG_RWTUN, + &usb_disable_enumeration, 0, "Set to disable all USB device enumeration."); +#endif + struct uhub_current_state { uint16_t port_change; uint16_t port_status; @@ -621,9 +627,9 @@ repeat: err = usbd_req_clear_port_feature(udev, NULL, portno, UHF_C_PORT_CONNECTION); - if (err) { + if (err) goto error; - } + /* check if there is a child */ if (child != NULL) { @@ -636,14 +642,22 @@ repeat: /* get fresh status */ err = uhub_read_port_status(sc, portno); - if (err) { + if (err) + goto error; + +#if USB_HAVE_DISABLE_ENUM + /* check if we should skip enumeration from this USB HUB */ + if (usb_disable_enumeration != 0 || + sc->sc_disable_enumeration != 0) { + DPRINTF("Enumeration is disabled!\n"); goto error; } +#endif /* check if nothing is connected to the port */ - if (!(sc->sc_st.port_status & UPS_CURRENT_CONNECT_STATUS)) { + if (!(sc->sc_st.port_status & UPS_CURRENT_CONNECT_STATUS)) goto error; - } + /* check if there is no power on the port and print a warning */ switch (udev->speed) { @@ -996,13 +1010,6 @@ uhub_explore(struct usb_device *udev) DPRINTFN(11, "udev=%p addr=%d\n", udev, udev->address); -#if USB_HAVE_DISABLE_ENUM - /* check if we should skip enumeration from this USB HUB */ - if (sc->sc_disable_enumeration != 0) { - DPRINTF("Enumeration is disabled!\n"); - return (0); - } -#endif /* ignore devices that are too deep */ if (uhub_is_too_deep(udev)) return (USB_ERR_TOO_DEEP);