lkml.org 
[lkml]   [2003]   [Aug]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] call drv->shutdown at rmmod
From
Date

At the kexec BOF at OSDL there was some discussion on calling the
device shutdown method at module remove time, in addition to calling
it during reboot. The driver was the observation that the primary
source of problems in booting linux from linux are drivers with bad
or missing drv->shutdown() routines. The hope is this will increase
the testing so people can get it right and kexec can become more
useful. In addition to making normal reboots more reliable.

The following patch is an implementation of that idea it calls drv->shutdown()
before calling drv->remove(). If drv->shutdown() is implemented.

In addition the driver model documentation in 2.6.0-test3 is badly out of
date. So I have attached a minor correction which at least mentions
drv->shutdown().

Eric


diff -uNr linux-2.6.0-test3/Documentation/driver-model/driver.txt linux-2.6.0-test3-shutdown_before_remove/Documentation/driver-model/driver.txt
--- linux-2.6.0-test3/Documentation/driver-model/driver.txt Mon Jul 14 03:34:33 2003
+++ linux-2.6.0-test3-shutdown_before_remove/Documentation/driver-model/driver.txt Wed Aug 13 12:51:49 2003
@@ -16,10 +16,10 @@
int (*probe) (struct device * dev);
int (*remove) (struct device * dev);

+ void (*shutdown) (struct device * dev);
+
int (*suspend) (struct device * dev, u32 state, u32 level);
int (*resume) (struct device * dev, u32 level);
-
- void (*release) (struct device_driver * drv);
};


@@ -194,6 +194,18 @@

If the device is still present, it should quiesce the device and place
it into a supported low-power state.
+
+
+ void (*shutdown) (struct device * dev);
+
+shutdown is called to quiescent a device before a reboot, or before
+the device is removed. A device is quiescent if all on going
+transactions are stopped, and it is not setup to spontaneously
+generate new ones. In addition the device should be in a state
+that it is reasonable for the drivers initialization code can get it
+working again. shutdown is a separate case from remove because on a
+reboot the data structures do not need to be freed, and not freeing
+them increases the robustness of a reboot.

int (*suspend) (struct device * dev, u32 state, u32 level);

diff -uNr linux-2.6.0-test3/drivers/base/bus.c linux-2.6.0-test3-shutdown_before_remove/drivers/base/bus.c
--- linux-2.6.0-test3/drivers/base/bus.c Mon Jul 14 03:31:58 2003
+++ linux-2.6.0-test3-shutdown_before_remove/drivers/base/bus.c Wed Aug 13 12:52:20 2003
@@ -350,6 +350,8 @@
if (drv) {
sysfs_remove_link(&drv->kobj,dev->kobj.name);
list_del_init(&dev->driver_list);
+ if (drv->shutdown)
+ drv->shutdown(dev);
if (drv->remove)
drv->remove(dev);
dev->driver = NULL;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:47    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site