On Tue, 9 Dec 2003, Oliver Neukum wrote:

> from usb_hcd_giveback_urb()
>  * @urb: urb being returned to the USB device driver.
>  * @regs: pt_regs, passed down to the URB completion handler
>  * Context: in_interrupt()
> 
> If you wish to drop that requirement you'll have to audit all drivers with
> respect to spinlocks.
> 
> > hardware must not no longer access the URB.  If the driver could establish
> > during the unlink call that the hardware had not even _begun_ to access
> > the URB, it would be a perfectly valid optimization to call giveback_urb
> > right then and there.
> 
> Yes, under an irqsave spinlock or equivalent thereof. David has done a
> very crafty job of ensuring this in the hcd layer. His use of
> local_irq_disable() seemed like black magic to me at first.

I concede the point.  There's no need to check for nested giveback's.

It would still be a good idea to give drivers an easy way to wait for an
URB to be completely idle (i.e., completion handler not running and URB
not currently linked) without making them do careful locking and
synchronization themselves.  To do so would require the core to be able to
tell, after the completion handler returns, whether the URB has been
resubmitted.  Currently I don't think there is any way to do this.

> Hm, I am unsure.
> Couldn't we eliminate most uses of usb_unlink_urb() from 2.6 anyway?

A lot of them, probably yes.  However there must be cases where drivers
want to unlink an URB because of a timeout rather than disconnection.  
usb-storage does that, but it always uses async unlinking.

Alan Stern



-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&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