On Sun, 1 Apr 2007, Pavel Machek wrote:
> 
> > @@ -183,7 +183,8 @@ int driver_register(struct device_driver
> >  void driver_unregister(struct device_driver * drv)
> >  {
> >     bus_remove_driver(drv);
> > -   wait_for_completion(&drv->unloaded);
> > +   if (!drv->unloaded.done)
> > +           WARN_ON(1);
> >  }
> 
> WARN_ON(!done)?

I think the whole "wait_for_completion()" is just broken. 

We asked to *unregister* the driver, not to wait for users.

I would suggest that for 2.6.21, the minimal fix is actually something 
like the appended. Comments? Ingo, does this fix things for you?

In general, I think the whole "wait for locks" or "wait for users" is 
almost always a sign of a much bigger bug in reference counting. Modules 
are special, though, since module code/data doesn't really get reference 
counted. But doing it for built-in stuff when you don't need to really 
just sounds *wrong*.

                Linus

---
 drivers/base/driver.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 1214cbd..082bfde 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -183,7 +183,14 @@ int driver_register(struct device_driver * drv)
 void driver_unregister(struct device_driver * drv)
 {
        bus_remove_driver(drv);
-       wait_for_completion(&drv->unloaded);
+       /*
+        * If the driver is a module, we are probably in
+        * the module unload path, and we want to wait
+        * for everything to unload before we can actually
+        * finish the unload.
+        */
+       if (drv->owner)
+               wait_for_completion(&drv->unloaded);
 }
 
 /**
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to