[RFC PATCH v1 1/6] USB: HCD: support giveback of URB in tasklet context

Ming Lei ming.lei at canonical.com
Fri Jun 21 12:12:23 EDT 2013


On Fri, Jun 21, 2013 at 10:48 PM, Alan Stern <stern at rowland.harvard.edu> wrote:
>
> Come to think of it, this shouldn't be a problem.  Drivers _must_
> insure that all their URBs have completed before their disconnect
> routine returns; otherwise the completion handler could get called
> after the driver has been unloaded from memory.
>
> Currently we have no way to enforce this in usbcore, although with the
> tasklets we could enforce it.  But I don't think it is necessary.  It

One way of enforcing this I thought of is to wait for completions of all
unlinking URBs at the end of usb_hcd_flush_endpoint().

But as you said, it may not be necessary.

> would be sufficient to log a warning if the tasklet's URB list isn't
> empty when exit_giveback_urb_bh() runs.  It won't happen unless there's
> a buggy driver.
>
> Besides, even if you try to flush all the URBs on the tasklet's list at
> the end of usb_hcd_flush_endpoint(), you'll still miss the URBs which
> have been moved to the local_list in usb_giveback_urb_bh().  You'd have
> to wait until the tasklet wasn't running, and it would most likely be a
> waste of time.


Thanks,
--
Ming Lei



More information about the linux-arm-kernel mailing list