From: ebiederm@xmission.com (Eric W. Biederman)
To: Pavel Machek <pavel@suse.cz>, Greg KH <greg@kroah.com>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH] call drv->shutdown at rmmod
Date: 14 Aug 2003 01:06:45 -0600 [thread overview]
Message-ID: <m1he4kzpiy.fsf@frodo.biederman.org> (raw)
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;
next reply other threads:[~2003-08-14 7:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-14 7:06 Eric W. Biederman [this message]
2003-08-14 7:54 ` [PATCH] call drv->shutdown at rmmod 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1he4kzpiy.fsf@frodo.biederman.org \
--to=ebiederm@xmission.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox