PERFORCE change 168461 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Sat Sep 12 10:46:31 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=168461
Change 168461 by hselasky at 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"
More information about the p4-projects
mailing list