[PATCH] call drv->shutdown at rmmod

From: Eric W. Biederman (ebiederm_at_xmission.com)
Date: 08/14/03

  • Next message: Matt Mackall: "Re: [PATCH] cryptoapi: Fix sleeping"
    To: Pavel Machek <pavel@suse.cz>, Greg KH <greg@kroah.com>, <linux-kernel@vger.kernel.org>
    Date:	14 Aug 2003 01:06:45 -0600
    
    

    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/


  • Next message: Matt Mackall: "Re: [PATCH] cryptoapi: Fix sleeping"

    Relevant Pages

    • (Work-around) Cannot normally logoff, reboot, or shutdown remotely with ATI Radeon driver
      ... cannot normally logoff, reboot, or shutdown remotely with ATI Radeon ... The attempt to unknown %SYSTEMNAME% failed ... Roll back your video driver to 6.13.10.6153, ...
      (microsoft.public.windowsxp.work_remotely)
    • Re: [PATCH] call drv->shutdown at rmmod
      ... |>> At the kexec BOF at OSDL there was some discussion on calling the ... |>> device shutdown method at module remove time, in addition to calling ... The driver was the observation that the primary ... |> whether or not to call shutdown for that particular device. ...
      (Linux-Kernel)
    • Re: Machine reboot
      ... I'm facing troubles with machine restart. ... While sysrq-b restarts machine, reboot ... I'm unsure my BIOS version will be the same as it's a devel system for our drivers, but still I have never heard of anyone requiring the full unload of the NIC driver to be able to shutdown. ...
      (Linux-Kernel)
    • Re: Unable to update Linksys driver
      ... Nic, Uninstall Driver, Shutdown, Remove Card, Registry - Remove ... Shutdown, re-install card, Reboot. ...
      (microsoft.public.windowsxp.general)
    • Re: System A.M. shut downs
      ... I opened a weather program which records data every 5 minutes to see ... NOD32 was loaded on the C ... when I had to reboot. ... If I shutdown my system gracefully, I do get things in the Event Log ...
      (microsoft.public.windowsxp.general)