linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] call drv->shutdown at rmmod
@ 2003-08-14  7:06 Eric W. Biederman
  2003-08-14  7:54 ` Christoph Hellwig
  2003-08-14 16:02 ` Patrick Mochel
  0 siblings, 2 replies; 17+ messages in thread
From: Eric W. Biederman @ 2003-08-14  7:06 UTC (permalink / raw)
  To: Pavel Machek, Greg KH, linux-kernel


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;

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2003-08-17 22:30 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-14  7:06 [PATCH] call drv->shutdown at rmmod Eric W. Biederman
2003-08-14  7:54 ` Christoph Hellwig
2003-08-14  8:06   ` Russell King
2003-08-14 15:50     ` Eric W. Biederman
2003-08-14 16:07       ` Russell King
2003-08-14 17:26         ` Eric W. Biederman
2003-08-17 22:26           ` [PATCH] don't call device_shutdown on halt Eric W. Biederman
2003-08-14 16:40     ` [PATCH] call drv->shutdown at rmmod Russell King
2003-08-14 16:02 ` Patrick Mochel
2003-08-14 16:26   ` Eric W. Biederman
2003-08-14 16:41     ` Patrick Mochel
2003-08-14 17:41       ` Eric W. Biederman
2003-08-15  8:51       ` Benjamin Herrenschmidt
2003-08-15 15:28         ` Eric W. Biederman
2003-08-15 16:01           ` Benjamin Herrenschmidt
2003-08-15 16:30         ` Patrick Mochel
2003-08-14 16:47     ` Randy.Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).