From owner-svn-src-all@FreeBSD.ORG Mon Mar 12 17:54:18 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8DEC9106566B; Mon, 12 Mar 2012 17:54:18 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 62B178FC0A; Mon, 12 Mar 2012 17:54:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q2CHsITo077331; Mon, 12 Mar 2012 17:54:18 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q2CHsIgS077329; Mon, 12 Mar 2012 17:54:18 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201203121754.q2CHsIgS077329@svn.freebsd.org> From: Hans Petter Selasky Date: Mon, 12 Mar 2012 17:54:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232870 - stable/9/sys/dev/usb/controller X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Mar 2012 17:54:18 -0000 Author: hselasky Date: Mon Mar 12 17:54:17 2012 New Revision: 232870 URL: http://svn.freebsd.org/changeset/base/232870 Log: MFC r232448: Make sure that the USB system suspend event is executed synchronously and not asynchronously. Modified: stable/9/sys/dev/usb/controller/usb_controller.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/dev/usb/controller/usb_controller.c ============================================================================== --- stable/9/sys/dev/usb/controller/usb_controller.c Mon Mar 12 17:25:35 2012 (r232869) +++ stable/9/sys/dev/usb/controller/usb_controller.c Mon Mar 12 17:54:17 2012 (r232870) @@ -89,10 +89,15 @@ 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 USB device enumerate waiting at boot."); +static int usb_no_suspend_wait = 0; +TUNABLE_INT("hw.usb.no_suspend_wait", &usb_no_suspend_wait); +SYSCTL_INT(_hw_usb, OID_AUTO, no_suspend_wait, CTLFLAG_RW|CTLFLAG_TUN, + &usb_no_suspend_wait, 0, "No USB device waiting at system suspend."); + static int usb_no_shutdown_wait = 0; TUNABLE_INT("hw.usb.no_shutdown_wait", &usb_no_shutdown_wait); -SYSCTL_INT(_hw_usb, OID_AUTO, no_shutdown_wait, CTLFLAG_RW|CTLFLAG_TUN, &usb_no_shutdown_wait, 0, - "No USB device waiting at system shutdown."); +SYSCTL_INT(_hw_usb, OID_AUTO, no_shutdown_wait, CTLFLAG_RW|CTLFLAG_TUN, + &usb_no_shutdown_wait, 0, "No USB device waiting at system shutdown."); static devclass_t usb_devclass; @@ -239,6 +244,11 @@ usb_suspend(device_t dev) USB_BUS_LOCK(bus); usb_proc_msignal(&bus->explore_proc, &bus->suspend_msg[0], &bus->suspend_msg[1]); + if (usb_no_suspend_wait == 0) { + /* wait for suspend callback to be executed */ + usb_proc_mwait(&bus->explore_proc, + &bus->suspend_msg[0], &bus->suspend_msg[1]); + } USB_BUS_UNLOCK(bus); return (0); @@ -406,6 +416,15 @@ usb_bus_suspend(struct usb_proc_msg *pm) USB_BUS_UNLOCK(bus); + /* + * We use the shutdown event here because the suspend and + * resume events are reserved for the USB port suspend and + * resume. The USB system suspend is implemented like full + * shutdown and all connected USB devices will be disconnected + * subsequently. At resume all USB devices will be + * re-connected again. + */ + bus_generic_shutdown(bus->bdev); usbd_enum_lock(udev);