> > > Also it's not clear whether completion handler can free urb or not.
> > > usb-uhci and usb-ohci don't seem to use
> > > urb after calling completion handler (except interrupt and ring transfers
> > > where you obviosly must not free urb)
> > > but uhci uses bunch of fields in urb after calling completion.
> >
> >There are those who think that you can and those who think
> >that you can't.
> >If uhci touches it and you want your driver to work with uhci,
> >you must not free them or fix uhci.
>
> What do other people think ?

I think that completion handlers should be able to free URBs,
except for periodic URBs that are being resubmitted, but I
know that Oliver has problems with that position.

In practical terms, I believe some of the HC drivers (I thought
it was only usb-uhci, actually) continue to access URBs in
some cases after they are returned to drivers.  I call that sort
of behavior buggy, but for now drivers in 2.4 need to cope.


> This should be fairly easily to fix. But the question is should we fix that
> or should we just say "no completion handler _must_ not free urb"
> because it's fundamentally wrong.

Not fundamentally wrong.  However in 2.5 there's now refcounting
inside URBs so that one won't know exactly when the free happens.
Maybe that stack will eventually be backported to 2.4, but not yet.


> >I may point out that it is very hard to write a disconnect() handler
> >if urbs can be freed in the completion handler, as you need
> >complicated locking.
>
> Not really. I have an skb queue of outstanding transfers. Each skb has a 
> pointer to appropriate urb. On disconnect I just traverse the queue and
> synchronously  unlink urbs and let the completion handler free recourses.
> So, simple skb queue locking is enough in my case.

Except for using _synchronous_ unlink (N msec*length of queue) instead
of synchronous (less :), that sounds like what the "usbnet" driver does.
I have some faith in that logic.  For the record, sometime back I changed
it so it didn't free urbs in the callback ... it does so in the tasklet, to get
rid of oopses that came up with usb-uhci.

- Dave



_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to