> > Hi Oliver, I understand better now - both the new module subsystem and > > how USB uses it. However, the USB subsystem should be doing > > try_module_get before any call into a driver. But there is one case in > > which it doesn't: calling urb completion handlers. Isn't this wrong? > > Yes, this is a problem, the module can be unloaded and then the > completion fuction can be called. > > I talked a lot with Rusty about this problem, and he insists that the > new module reference counts are lightweight enough to handle this > properly. Meaning that we need to increment the module count for every > urb in flight. He's going to do the same thing for skbufs. > > Only bad thing with this change is we need to change the api somehow to > get the module reference to be assigned to the urb. We can do this > either through changing the usb_submit_urb() function, or changing the > urb to point to the interface it is bound to, not the dev (the interface > has a pointer to the driver which has the pointer to the module > reference). Any opinions on which would be better to use? > > Also, if anyone wants to code up a patch to do this, I would be greatly > appreciate it. I'm trying to fix up the usb device reference counting > logic right now and running into issues where host controllers try to > access urbs after their devices have been removed from the system :(
Hi Greg, after sending this message I changed my mind: I don't think try_module_get is needed. We already have the rule that all urbs must be completed (maybe forcefully) by the time the disconnect method returns. (Why? - because the USB device does not exist afterwards...) Another rule: usb_deregister must be called in the module exit routine (or earlier), and it calls disconnect if needed. Thus all completion handlers will run before or during the module exit routine. Since completion handlers don't sleep (or shouldn't: it is true that the handler is not called in_interrupt() if the urb is unlinked), there is no problem if one is called during module exit. In short, I don't see that there is a problem with urb completion. In fact, going down the path of reference counting urbs, sk_buffs etc seems to me like a big mistake. It is never ending. For example, in the speedtouch driver I use a tasklet. Thus there is a callback into the module by the tasklet. The tasklet code does not use try_module_get! But that's OK: the tasklet callback does not sleep and I kill the tasklet during shutdown. There must be an endless number of similar examples. Maybe the sk_buff case is a bit different: the finalization method can sleep if I remember. But urb completion handlers don't ever sleep, right? Duncan. ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
