multiple interface test case

Roman Kagan rkagan at mail.ru
Wed Apr 13 04:44:33 EDT 2005


On Wed, Apr 13, 2005 at 11:54:43AM +0400, Roman Kagan wrote:
> On Wed, Apr 13, 2005 at 09:43:02AM +0200, Duncan Sands wrote:
> > > The appended patch fixes it for me (written for 2.6.12-rc2, applied to
> > > and run on 2.6.11).  I'm not yet fluent with klists so it'll take longer
> > > to cook up one for -mm.
> > > 
> > > Still I wonder for how long it was there, because every
> > > usb_driver_release_interface() during rmmod should have revealed that
> > > problem.
> > 
> > I also suspected the lists, however while this may be part of the truth,
> > the situation seems more complicated in -mm.  There one reference is not
> > dropped - but why?  I now have stack dumps of all kobject_put/get calls
> > for the driver, so it should become clear soon I hope...
> 
> I must have been unclear: the reference isn't dropped exactly because
> the driver_detach() never returns.  This applies to -mm too.  I'll try
> to cook up a patch to fix it, let's see if it works for you.

Can you please try the following (completely unteseted) patch?  It does
the same as the other one for rc2: instead of iterating the list, it
always operates on the first entry, assuming device_release_driver()
will clear it (and possibly other entries too, thus protecting from the
problem we saw).

Roman.

P.S. These klists seem to be a terrible overdesign to me...


--- linux-2.6.12-rc2-mm2/drivers/base/dd.c.orig	2005-04-08 17:07:05.000000000 +0400
+++ linux-2.6.12-rc2-mm2/drivers/base/dd.c	2005-04-13 12:38:03.000000000 +0400
@@ -222,7 +222,18 @@ static int __remove_driver(struct device
 
 void driver_detach(struct device_driver * drv)
 {
-	driver_for_each_device(drv, NULL, NULL, __remove_driver);
+	struct klist_iter i;
+	struct klist_node *n;
+	struct device *dev;
+	do {
+		klist_iter_init(&drv->klist_devices, &i);
+		n = klist_next(i);
+		if (n) {
+			dev = container_of(n, struct device, knode_driver);
+			device_release_driver(dev);
+		}
+		klist_iter_exit(&i);
+	} while (n);
 }
 
 EXPORT_SYMBOL_GPL(device_bind_driver);



More information about the Usbatm mailing list