From owner-svn-src-all@FreeBSD.ORG Wed Dec 21 10:52:18 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 83856106564A; Wed, 21 Dec 2011 10:52:18 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 729908FC0A; Wed, 21 Dec 2011 10:52: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 pBLAqInS065051; Wed, 21 Dec 2011 10:52:18 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pBLAqIik065049; Wed, 21 Dec 2011 10:52:18 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201112211052.pBLAqIik065049@svn.freebsd.org> From: Andriy Gapon Date: Wed, 21 Dec 2011 10:52:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228760 - head/sys/dev/usb 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: Wed, 21 Dec 2011 10:52:18 -0000 Author: avg Date: Wed Dec 21 10:52:17 2011 New Revision: 228760 URL: http://svn.freebsd.org/changeset/base/228760 Log: adapt usb transfer code for SCHEDULER_STOPPED When SCHEDULER_STOPPED() is true the mtx_owned() call may return an unexpected and thus meaningless result. So, in the code paths that can be reached when SCHEDULER_STOPPED() is true we need to protect the mtx_owned() calls with the SCHEDULER_STOPPED() checks and ensure that an appropriate branch is taken in each case. Reviewed by: hselasky MFC after: 3 months X-MFC after: r228424 Modified: head/sys/dev/usb/usb_transfer.c Modified: head/sys/dev/usb/usb_transfer.c ============================================================================== --- head/sys/dev/usb/usb_transfer.c Wed Dec 21 09:08:41 2011 (r228759) +++ head/sys/dev/usb/usb_transfer.c Wed Dec 21 10:52:17 2011 (r228760) @@ -2150,7 +2150,7 @@ usbd_callback_wrapper(struct usb_xfer_qu struct usb_xfer_root *info = xfer->xroot; USB_BUS_LOCK_ASSERT(info->bus, MA_OWNED); - if (!mtx_owned(info->xfer_mtx)) { + if (!mtx_owned(info->xfer_mtx) && !SCHEDULER_STOPPED()) { /* * Cases that end up here: * @@ -3119,14 +3119,14 @@ usbd_transfer_poll(struct usb_xfer **ppx /* make sure that the BUS mutex is not locked */ drop_bus = 0; - while (mtx_owned(&xroot->udev->bus->bus_mtx)) { + while (mtx_owned(&xroot->udev->bus->bus_mtx) && !SCHEDULER_STOPPED()) { mtx_unlock(&xroot->udev->bus->bus_mtx); drop_bus++; } /* make sure that the transfer mutex is not locked */ drop_xfer = 0; - while (mtx_owned(xroot->xfer_mtx)) { + while (mtx_owned(xroot->xfer_mtx) && !SCHEDULER_STOPPED()) { mtx_unlock(xroot->xfer_mtx); drop_xfer++; }