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
This commit is contained in:
Andriy Gapon 2011-12-21 10:52:17 +00:00
parent 85b44a018c
commit 6703915ee7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=228760

View File

@ -2150,7 +2150,7 @@ usbd_callback_wrapper(struct usb_xfer_queue *pq)
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 **ppxfer, uint16_t max)
/* 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++;
}