On Saturday 03 November 2001 12:40 pm, Thomas Sailer wrote: > Oliver Neukum wrote: > > A look through usbdevfs shows that there's no locking. > > ??? > > usbdevfs has devsem to prevent these races (it's a rwsem, > reading used to access the device, disconnect requires taking > the semaphore for writing, thus locking out readers). > > That's the way USB locking works. The driver has to protect > itself against disconnect, and in case transfers are still > going on when the disconnect function is called, the driver > has to delay termination of the disconnect function until > it is finished using the device.
Hi Tom, I'm not sure I follow you. For sure, usbdevfs has a rwsem to avoid some races, but I don't see how it avoids races with disconnect. In usb.c there is the usb_disconnect function which first calls driver->disconnect, then only later calls usbdevfs_remove_device. usbdevfs_remove_device acquires (w) the semaphore before removing the device. Suppose I do an ioctl via usbdevfs after (or even during) the call to device->disconnect but before the call to usbdevfs_remove_device. Well, as far as I can see it will go through, and the driver will get an ioctl after or during the disconnect. This is the race I was asking about. As far as I can see it is possible, and drivers simply need to protect themselves against it. Thanks, Duncan. _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel