]> rtime.felk.cvut.cz Git - linux-imx.git/commit
Driver core: Add offline/online device operations
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 2 May 2013 20:15:29 +0000 (22:15 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sun, 12 May 2013 12:14:09 +0000 (14:14 +0200)
commit4f3549d72d1b5c90ecc7e673402f38f4486d22c2
treebec88e98010e129f4105cab3ff0e490166e1cbe3
parentdd3652ed1a5328a91352409fe81af3e7d629e44b
Driver core: Add offline/online device operations

In some cases, graceful hot-removal of devices is not possible,
although in principle the devices in question support hotplug.
For example, that may happen for the last CPU in the system or
for memory modules holding kernel memory.

In those cases it is nice to be able to check if the given device
can be gracefully hot-removed before triggering a removal procedure
that cannot be aborted or reversed.  Unfortunately, however, the
kernel currently doesn't provide any support for that.

To address that deficiency, introduce support for offline and
online operations that can be performed on devices, respectively,
before a hot-removal and in case when it is necessary (or convenient)
to put a device back online after a successful offline (that has not
been followed by removal).  The idea is that the offline will fail
whenever the given device cannot be gracefully removed from the
system and it will not be allowed to use the device after a
successful offline (until a subsequent online) in analogy with the
existing CPU offline/online mechanism.

For now, the offline and online operations are introduced at the
bus type level, as that should be sufficient for the most urgent use
cases (CPUs and memory modules).  In the future, however, the
approach may be extended to cover some more complicated device
offline/online scenarios involving device drivers etc.

The lock_device_hotplug() and unlock_device_hotplug() functions are
introduced because subsequent patches need to put larger pieces of
code under device_hotplug_lock to prevent race conditions between
device offline and removal from happening.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Toshi Kani <toshi.kani@hp.com>
Documentation/ABI/testing/sysfs-devices-online [new file with mode: 0644]
drivers/base/core.c
include/linux/device.h