On Thu, 25 Aug 2005, Daniel Ritz wrote: > > The remark in parenthesis is wrong. dev->driver can be set when calling > > device_add, at which time the device obviously is not already bound to a > > driver. When this is done, device_attach will automatically bind the > > device to dev->driver. > > yeah, i noticed that too. see my answer in: > http://marc.theaimsgroup.com/?l=linux-kernel&m=112481438512222&w=2 > > it's the easiest way to 'fix' the race by allowing a call to > device_bind_driver() > even if the device is already bound. fixes my rmmod hang and shoudln't mess > with USB. comment is updated too :) > what do you think about that as a short term fix?
It looks fine for now. (Although I might have left the test in bus_rescan_devices_helper as a simple optimization.) For the long run, we do need to switch to a sane API. I was going to fix things by passing the driver as an explicit argument to device_bind_driver and device_release_driver. That way the subroutines can test the current value of dev->driver while holding the semaphore, avoiding a race. Calls to device_add with dev->driver already set can be handled by making the initial driver an explicit argument to device_attach. There's still the possibility of a race (another driver manages to get there first), but at least it won't cause an oops. What do you think? Complications arise from places where these routines are called with no explicit synchronization other than the subsystem rwsem. Fortunately some of those are going to go away. Alan Stern ------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel