> > The simplest answer is (b): > > > > (b) usb_find_interface_driver() uses the dev->serialize semaphore > > for exclusion, but usbdevfs uses the BKL instead. > > This is not all, it uses driver->serialize() as well.
Ah so it does. But still, usbdevfs uses neither, and that's clearly wrong: three locks to cover one data item ... wrong, wrong, wrong. (BKL, dev->serialize, and driver->serialize). Even if I were to acccept your claim that the driver->serialize semaphore should protect probe() and disconnect(), it couldn't work for usbdevfs doing device claiming since it's not using those driver entries. > Using only dev->serialize() confuses drivers that expect > a single thread in probe(), and they do need a single thread > in proble because they need to initialize their mutual > exclusion primitives that they might use to serialize other calls. This is clearly an undocumented behavior. I think it's also a bad API guarantee too; static init of global locks is the rule (that's the only kind they "might use to serialize other calls"). That's stuff module init should handle (and precious little else, beyond registering with usbcore). > driver->serialize is common between probe and disconnect. Not in usbdevfs. And then there's the curiousity that dev->serialize is NOT common. Too many locks for handling one data structure. > Using dev->serialize would not work for the reason I pointed > out above: driver may attempt to set its globals in probe(). Which isn't a good API usage policy. Which drivers do that? I scanned a bunch, didn't see any expecting that to be needed. But I did see a bunch that do static init or use module_init() for such stuff. > I realize that current Linux has statically initializeable > locking primitives which would allow a driver to self-serialize, > but I am not sure it would be wise to structure an API around > their availability. Ah, why might that be? They're part of the kernel API, and they aren't even remotely a radical notion. Why should Linux drivers not be expected to use appropriate kernel APIs? - Dave _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel