On Tue, 2004-01-13 at 03:14, David Brownell wrote:
Somewhere there's a patch floating around which makes UHCI wait for those URBs to complete too. Lacking that patch, you need to do what all robust USB drivers have always done: wait for all their urbs to complete.
Should I wait with a timeout or forever?
Neither; for now, disconnect() should wait until all the urbs complete. Definitely no timeout.
What am i supposed to do if the usb_unlink_urb call returns -EBUSY?
Think about the problem a bit differently: you should synchronize on the completion of the URB, not on the return from cancel/unlink. In fact, don't use the synchronous unlink calls -- they've always had issues, the async unlink has always been more portable.
OK, I have no problem with changing that aspect to get a more robust driver, but I can't see how this helps in this particular situation. As I understand it (from what Alan said), the URB gets unlinked in hcd_endpoint_disable() and this happens the moment I unplug the device.
Actually it happens when khubd gets around to it, which will rarely be sooner than about 1/8 second later. And except for UHCI, it will also wait for all those unlinks to complete.
Then about 3 seconds later my wait_event call, waiting for the URB completion, times out. By that time, the URB should be long gone. And
Yes, the controller driver doesn't have much excuse for holding on to an urb more than a handful of milliseconds after they're told to dequeue() it ASAP.
Are you sure your wait_event() logic is working correctly? One explanation for these questions is that it missed the event.
then I try to unlink the URB because from the drivers point of view, it could just be valid timeout, due to a device malfunctioning. If I call unlink_urb asynchronously and wait for the completion again, I would expect that wait never to return. Or is the URB_ASYNC_UNLINK flag itself the key to the problem?
I'd use URB_ASYNC_UNLINK myself, but that's unlikely to be the root of the problem if your disconnect() is correctly waiting for all of the urbs to complete.
I don't quite understand what you try to tell me here. In my case I have exactly one URB and I wait for this very one but still 3 seconds after the unplug event, it is not completed. So there is a bug in the underling core/controller code that has nothing to do with my synchronization, right?
Sounds like that's so -- assuming your wait_event() logic is working as you imply. Once the controller driver returned from its dequeue() method, that meant the URB was going to be returned "soon". Isn't there a uhci timer that's supposed to make that happen?
- Dave
------------------------------------------------------- This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
