Date: Sat, 12 Sep 2009 10:46:30 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 168461 for review Message-ID: <200909121046.n8CAkUu4002121@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=168461 Change 168461 by hselasky@hselasky_laptop001 on 2009/09/12 10:45:51 USB CORE: - add extra safety locking when clobbering xfer->flags_int.started in start and stop functions, because xfer->flags_int is also updated by the USB controller, under the controller lock. - fix a comment. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#168 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#168 (text+ko) ==== @@ -1622,7 +1622,10 @@ /* mark the USB transfer started */ if (!xfer->flags_int.started) { + /* lock the BUS lock to avoid races updating flags_int */ + USB_BUS_LOCK(xfer->xroot->bus); xfer->flags_int.started = 1; + USB_BUS_UNLOCK(xfer->xroot->bus); } /* check if the USB transfer callback is already transferring */ @@ -1657,14 +1660,21 @@ /* check if the USB transfer was ever opened */ if (!xfer->flags_int.open) { - /* nothing to do except clearing the "started" flag */ - xfer->flags_int.started = 0; + if (xfer->flags_int.started) { + /* nothing to do except clearing the "started" flag */ + /* lock the BUS lock to avoid races updating flags_int */ + USB_BUS_LOCK(xfer->xroot->bus); + xfer->flags_int.started = 0; + USB_BUS_UNLOCK(xfer->xroot->bus); + } return; } /* try to stop the current USB transfer */ USB_BUS_LOCK(xfer->xroot->bus); - xfer->error = USB_ERR_CANCELLED;/* override any previous error */ + /* override any previous error */ + xfer->error = USB_ERR_CANCELLED; + /* * Clear "open" and "started" when both private and USB lock * is locked so that we don't get a race updating "flags_int"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909121046.n8CAkUu4002121>