On Thu, 3 Jun 2004, Olaf Hering wrote: > On Thu, Jun 03, Oliver Neukum wrote: > > > Am Donnerstag, 3. Juni 2004 18:39 schrieb Olaf Hering: > > > This patch causes deadlocks if you unplug and replug an usb-storage > > > device. > > > > Only on replug? > > yes. plug the usbstick in, reboot, everything works ok. unplug, still > ok, replug, threads hang in D state.
This form of failure is an artifact of the current state of the driver. It really should hang during unplug as well. And darn it, I would have realized this earlier if I had been thinking more clearly. The reason is simple enough. usb-storage's disconnect() runs with dev->serialize held, and it has to wait for any currently-executing SCSI command to finish. If executing a SCSI command involves acquiring dev->serialize, that's a perfect recipe for deadlock. The only way I can see to resolve this is to use a separate semaphore for ep0 message exclusion. Call it dev->ep0mutex. The locking order would have to be: acquire dev->serialize _before_ locking dev->ep0mutex. Both usbfs and sysfs would need patching to acquire dev->ep0mutex. Greg, I'm afraid the patch from Vojtech has to be reverted. Alan Stern ------------------------------------------------------- This SF.Net email is sponsored by the new InstallShield X. >From Windows to Linux, servers to mobile, InstallShield X is the one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504 _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel