Am Montag, 17. Mai 2004 04:32 schrieb Alan Stern:
> On Sun, 16 May 2004, Oliver Neukum wrote:
> 
> > > Right now, none of the completion handlers under drivers/usb clears the 
> > > transfer flags.  But that's no guarantee about the future.
> > 
> > I overlooked something. Currently you cannot write to transfer_flags in the
> > handler at all. It's a classical race.
> 
> I wasn't aware of this.  What's the race?  Once the completion handler is
> running the URB is no longer owned by the core, it's owned by the device
> driver.  So why shouldn't the driver be able to write anything it wants?

CPU A                                   CPU B
mov transfer_flags,R                    mov transfer_flags,R
set_bit X,R                                     ................
mov R,transfer_flags                    set_bit Y,R
.....................                                   mov R,transfer_flag

Classical concurrent access to a nonatomic variable.

The whole point of usb_kill_urb() is _not_ to have synchronisation
of completion handler and the context calling usb_kill_urb().
usb_kill_urb() shall provide synchronisation by waiting for an urb
to be dead and buried. It must provide as much locking as it needs
and cannot depend on it without nullifying its own justification.

        Regards
                Oliver


-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to