Pete Zaitcev wrote:
Date: Thu, 17 Jul 2003 18:39:38 -0700
From: David Brownell <[EMAIL PROTECTED]>


So the completion uses an extra field to indicate that
urb was released by HC driver to the uppper level.
It's not an explicit field, it's an extra field.

This really makes no sense to me. There's a field, with an SMP-safe lock. The protocol between one layer and the next involves holding that lock before changing that field. And you're saying that's racey. How?


The urb->lock is situated in the same chunk of storage
as the urb->status, so it only can protect the status if
there is no hazard of deallocation of the urb. However, our
API makes no such guarantees across the call to the ->complete.

Well, there's a refcount, which should suffice in the absence of other bugs.

Read the giveback() code ... it's the ONLY way
that core+hcd retires an URB, and (finally!) all
the (mainstream) HCDs do it the same.


Therefore, urb->lock cannot be held across the callback.

It must never be held across a callback; I didn't say it was.



Once it cannot be held across the callback, there is a
window for the upper layer to peek at the urb after the
end of transfer and before the calback proper, and then
it's an oops.

What Alan said: I don't follow you at all. It's the upper layer (usbcore is above the HCD) which handles all of that; that's where giveback() lives. In that routine, neither the HCD nor the USB device driver is allowed to access the URB, until the completion callback itself is called. A "window" would imply there's some legitimate possibility of contention.


This is basically the reason urb->lock useage was thrown
out of usb-uhci by Georg (upon my insistence). And the worst
part is what YOU personally went through several rounts of
patching of usb-uhci, we had all this situation with Dell
and bunch of bugs with oopses. And now you do not remember
why usb-uhci is so superior and why urb->lock should have been
thrown out of the struct urb long time ago.

We're not talking LK 2.4 and usb-uhci, but LK 2.6 and uhci-hcd; the usage of urb->lock is cleaner now. My own troubles with usb-uhci had more to do with it oopsing when my completion handler freed the urb ... an issue unrelated to urb->lock.

- Dave




-- Pete





-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to