On Friday 30 March 2007 7:59 pm, Alan Stern wrote:

> > > Nope.  If an smp_mb() is needed, the reason is because of other
> > > driver-internal bugs.
> > > 
> > > Remember that the driver isn't allowed to so much as *LOOK* at any
> > > field of an URB until the completion callback.  That generalizes:
> > > it mustn't do so until that callback (cleanly) hands the URB back
> 
> While correct, this summary sort of glides over the important point, 

It has the virtue of highlighting the fact that the urb->status thing is
irrelevant ... at best, a red herring.  Changing that part of usbcore
might make some things prettier, but wouldn't solve those driver bugs.


> which is: How should the completion routine cleanly hand the URB
> back to the  rest of the driver?

That must be a driver-specific answer.


> There still remains the question of how to do this cleanly.  Obviously 
> some sort of synchronization primitive is needed.  wait_for_completion() 
> includes all the necessary memory barriers, whereas wait_event() does not.
> Or a spinlock could be used, although it would be somewhat awkward.

When it's the right model, wait_for_completion() should be used.
When it's the right model, spinlock should be used.
When it's the right model, RCU should be used.
When it's the right model, ...

I don't see spinlocks as being awkward, but the issue they solve is
not the issue being solved by wait_for_completion(), or wait_event().

Regardless, some explicit synchronization is the right model to
be aiming for.  The two drivers mentioned so far (parport, serial)
are sufficiently low throughput that locking overhead will not be
an issue ... in fact, even for high throughput drivers it's rarely
close to an issue, since any sanely designed locking scheme won't
have enough contention to worry about.

- Dave

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to