On Mon, 12 Apr 2004, David Brownell wrote: > Alan Stern wrote: > > (1) The locking in devices.c needs to be fixed. The USB subsystem > > rwsem should be held over a much larger part of the code. That should be > > pretty easy to do. I don't think it's necessary to use usb_get_dev or to > > lock usbdev->serialize, but someone should verify this. > > Hmm, could you elaborate? The bus rwsem is only to protect > against changes to driver bindings, and there's only one > chunk of code that accesses those bindings (for a brief > moment, already protected by that rwsem).
Maybe the bus rwsem _used_ to protect only against changes to driver bindings, but _now_ it also protects against adding/removing devices to the bus (and adding/removing drivers if you care about that). > I did find a missing claim of dev->serialize though, in > the usb_device_dump() routine ... at least, this was in > one patch I sent ages ago, but nothing I recent. It'd > protect against device reconfig/reset/disconnect. > See the attached patch. Many of these things can be protected against by acquiring either ->serialize or the bus rwsem. Reconfig (I assume by that you mean changing the active configuration) wouldn't cause any problems even if no lock was held, nor would device reset in the non-morphing case. In fact, the only thing I can think of offhand that ->serialize would protect against and the bus rwsem wouldn't is a "device-morphed" reset, and of course we don't yet support those anyway. It's not entirely clear (to me anyway) that holding ->serialize will provide sufficient protection against disconnection. That is, when a device is disconnected, the core doesn't acquire the parent hub's ->serialize. So when traversing the device tree below that hub we run the risk of trying to access a nonexistent device structure. It seems that the _only_ way to protect against these changes in the bus topology is by using the bus rwsem. Then of course we end up running into problems about trying to acquire the two locks in the correct order... Alan Stern ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel