Commit 2728b2d2 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Jonathan Corbet

PM / core / docs: Convert sleep states API document to reST

Move the document describing the system sleep state transitions API
for devices to Documentation/driver-api/pm/, convert it to reST and
update it to use current terminology.  Also remove the remaining
reference to the old version of it from pm.h.

The new document still contains references to some documents in the
.txt format that will be converted later.
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 4d29b2e5
...@@ -16,6 +16,7 @@ available subsections can be seen below. ...@@ -16,6 +16,7 @@ available subsections can be seen below.
basics basics
infrastructure infrastructure
pm/index
device-io device-io
dma-buf dma-buf
device_link device_link
......
# -*- coding: utf-8; mode: python -*-
project = "Device Power Management"
tags.add("subproject")
latex_documents = [
('index', 'pm.tex', project,
'The kernel development community', 'manual'),
]
Device Power Management .. |struct| replace:: :c:type:`struct`
Copyright (c) 2010-2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc. ==============================
Copyright (c) 2010 Alan Stern <stern@rowland.harvard.edu> Device Power Management Basics
Copyright (c) 2014 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com> ==============================
::
Copyright (c) 2010-2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc.
Copyright (c) 2010 Alan Stern <stern@rowland.harvard.edu>
Copyright (c) 2016 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Most of the code in Linux is device drivers, so most of the Linux power Most of the code in Linux is device drivers, so most of the Linux power
management (PM) code is also driver-specific. Most drivers will do very management (PM) code is also driver-specific. Most drivers will do very
...@@ -18,10 +23,12 @@ background for the domain-specific work you'd do with any specific driver. ...@@ -18,10 +23,12 @@ background for the domain-specific work you'd do with any specific driver.
Two Models for Device Power Management Two Models for Device Power Management
====================================== ======================================
Drivers will use one or both of these models to put devices into low-power Drivers will use one or both of these models to put devices into low-power
states: states:
System Sleep model: System Sleep model:
Drivers can enter low-power states as part of entering system-wide Drivers can enter low-power states as part of entering system-wide
low-power states like "suspend" (also known as "suspend-to-RAM"), or low-power states like "suspend" (also known as "suspend-to-RAM"), or
(mostly for systems with disks) "hibernation" (also known as (mostly for systems with disks) "hibernation" (also known as
...@@ -34,12 +41,13 @@ states: ...@@ -34,12 +41,13 @@ states:
Some drivers can manage hardware wakeup events, which make the system Some drivers can manage hardware wakeup events, which make the system
leave the low-power state. This feature may be enabled or disabled leave the low-power state. This feature may be enabled or disabled
using the relevant /sys/devices/.../power/wakeup file (for Ethernet using the relevant :file:`/sys/devices/.../power/wakeup` file (for
drivers the ioctl interface used by ethtool may also be used for this Ethernet drivers the ioctl interface used by ethtool may also be used
purpose); enabling it may cost some power usage, but let the whole for this purpose); enabling it may cost some power usage, but let the
system enter low-power states more often. whole system enter low-power states more often.
Runtime Power Management model: Runtime Power Management model:
Devices may also be put into low-power states while the system is Devices may also be put into low-power states while the system is
running, independently of other power management activity in principle. running, independently of other power management activity in principle.
However, devices are not generally independent of each other (for However, devices are not generally independent of each other (for
...@@ -73,9 +81,9 @@ Examples of hardware wakeup events include an alarm from a real time clock, ...@@ -73,9 +81,9 @@ Examples of hardware wakeup events include an alarm from a real time clock,
network wake-on-LAN packets, keyboard or mouse activity, and media insertion network wake-on-LAN packets, keyboard or mouse activity, and media insertion
or removal (for PCMCIA, MMC/SD, USB, and so on). or removal (for PCMCIA, MMC/SD, USB, and so on).
Interfaces for Entering System Sleep States Interfaces for Entering System Sleep States
=========================================== ===========================================
There are programming interfaces provided for subsystems (bus type, device type, There are programming interfaces provided for subsystems (bus type, device type,
device class) and device drivers to allow them to participate in the power device class) and device drivers to allow them to participate in the power
management of devices they are concerned with. These interfaces cover both management of devices they are concerned with. These interfaces cover both
...@@ -84,58 +92,35 @@ system sleep and runtime power management. ...@@ -84,58 +92,35 @@ system sleep and runtime power management.
Device Power Management Operations Device Power Management Operations
---------------------------------- ----------------------------------
Device power management operations, at the subsystem level as well as at the Device power management operations, at the subsystem level as well as at the
device driver level, are implemented by defining and populating objects of type device driver level, are implemented by defining and populating objects of type
struct dev_pm_ops: |struct| :c:type:`dev_pm_ops` defined in :file:`include/linux/pm.h`.
The roles of the methods included in it will be explained in what follows. For
struct dev_pm_ops { now, it should be sufficient to remember that the last three methods are
int (*prepare)(struct device *dev);
void (*complete)(struct device *dev);
int (*suspend)(struct device *dev);
int (*resume)(struct device *dev);
int (*freeze)(struct device *dev);
int (*thaw)(struct device *dev);
int (*poweroff)(struct device *dev);
int (*restore)(struct device *dev);
int (*suspend_late)(struct device *dev);
int (*resume_early)(struct device *dev);
int (*freeze_late)(struct device *dev);
int (*thaw_early)(struct device *dev);
int (*poweroff_late)(struct device *dev);
int (*restore_early)(struct device *dev);
int (*suspend_noirq)(struct device *dev);
int (*resume_noirq)(struct device *dev);
int (*freeze_noirq)(struct device *dev);
int (*thaw_noirq)(struct device *dev);
int (*poweroff_noirq)(struct device *dev);
int (*restore_noirq)(struct device *dev);
int (*runtime_suspend)(struct device *dev);
int (*runtime_resume)(struct device *dev);
int (*runtime_idle)(struct device *dev);
};
This structure is defined in include/linux/pm.h and the methods included in it
are also described in that file. Their roles will be explained in what follows.
For now, it should be sufficient to remember that the last three methods are
specific to runtime power management while the remaining ones are used during specific to runtime power management while the remaining ones are used during
system-wide power transitions. system-wide power transitions.
There also is a deprecated "old" or "legacy" interface for power management There also is a deprecated "old" or "legacy" interface for power management
operations available at least for some subsystems. This approach does not use operations available at least for some subsystems. This approach does not use
struct dev_pm_ops objects and it is suitable only for implementing system sleep |struct| :c:type:`dev_pm_ops` objects and it is suitable only for implementing
power management methods. Therefore it is not described in this document, so system sleep power management methods in a limited way. Therefore it is not
please refer directly to the source code for more information about it. described in this document, so please refer directly to the source code for more
information about it.
Subsystem-Level Methods Subsystem-Level Methods
----------------------- -----------------------
The core methods to suspend and resume devices reside in struct dev_pm_ops
pointed to by the ops member of struct dev_pm_domain, or by the pm member of The core methods to suspend and resume devices reside in
struct bus_type, struct device_type and struct class. They are mostly of |struct| :c:type:`dev_pm_ops` pointed to by the :c:member:`ops`
interest to the people writing infrastructure for platforms and buses, like PCI member of |struct| :c:type:`dev_pm_domain`, or by the :c:member:`pm`
or USB, or device type and device class drivers. They also are relevant to the member of |struct| :c:type:`bus_type`, |struct| :c:type:`device_type` and
writers of device drivers whose subsystems (PM domains, device types, device |struct| :c:type:`class`. They are mostly of interest to the people writing
classes and bus types) don't provide all power management methods. infrastructure for platforms and buses, like PCI or USB, or device type and
device class drivers. They also are relevant to the writers of device drivers
whose subsystems (PM domains, device types, device classes and bus types) don't
provide all power management methods.
Bus drivers implement these methods as appropriate for the hardware and the Bus drivers implement these methods as appropriate for the hardware and the
drivers using it; PCI works differently from USB, and so on. Not many people drivers using it; PCI works differently from USB, and so on. Not many people
...@@ -147,49 +132,52 @@ they are called in phases for every device, respecting the parent-child ...@@ -147,49 +132,52 @@ they are called in phases for every device, respecting the parent-child
sequencing in the driver model tree. sequencing in the driver model tree.
/sys/devices/.../power/wakeup files :file:`/sys/devices/.../power/wakeup` files
----------------------------------- -------------------------------------------
All device objects in the driver model contain fields that control the handling All device objects in the driver model contain fields that control the handling
of system wakeup events (hardware signals that can force the system out of a of system wakeup events (hardware signals that can force the system out of a
sleep state). These fields are initialized by bus or device driver code using sleep state). These fields are initialized by bus or device driver code using
device_set_wakeup_capable() and device_set_wakeup_enable(), defined in :c:func:`device_set_wakeup_capable()` and :c:func:`device_set_wakeup_enable()`,
include/linux/pm_wakeup.h. defined in :file:`include/linux/pm_wakeup.h`.
The "power.can_wakeup" flag just records whether the device (and its driver) can The :c:member:`power.can_wakeup` flag just records whether the device (and its
physically support wakeup events. The device_set_wakeup_capable() routine driver) can physically support wakeup events. The
affects this flag. The "power.wakeup" field is a pointer to an object of type :c:func:`device_set_wakeup_capable()` routine affects this flag. The
struct wakeup_source used for controlling whether or not the device should use :c:member:`power.wakeup` field is a pointer to an object of type
its system wakeup mechanism and for notifying the PM core of system wakeup |struct| :c:type:`wakeup_source` used for controlling whether or not
events signaled by the device. This object is only present for wakeup-capable the device should use its system wakeup mechanism and for notifying the
devices (i.e. devices whose "can_wakeup" flags are set) and is created (or PM core of system wakeup events signaled by the device. This object is only
removed) by device_set_wakeup_capable(). present for wakeup-capable devices (i.e. devices whose
:c:member:`can_wakeup` flags are set) and is created (or removed) by
:c:func:`device_set_wakeup_capable()`.
Whether or not a device is capable of issuing wakeup events is a hardware Whether or not a device is capable of issuing wakeup events is a hardware
matter, and the kernel is responsible for keeping track of it. By contrast, matter, and the kernel is responsible for keeping track of it. By contrast,
whether or not a wakeup-capable device should issue wakeup events is a policy whether or not a wakeup-capable device should issue wakeup events is a policy
decision, and it is managed by user space through a sysfs attribute: the decision, and it is managed by user space through a sysfs attribute: the
"power/wakeup" file. User space can write the strings "enabled" or "disabled" :file:`power/wakeup` file. User space can write the "enabled" or "disabled"
to it to indicate whether or not, respectively, the device is supposed to signal strings to it to indicate whether or not, respectively, the device is supposed
system wakeup. This file is only present if the "power.wakeup" object exists to signal system wakeup. This file is only present if the
for the given device and is created (or removed) along with that object, by :c:member:`power.wakeup` object exists for the given device and is created (or
device_set_wakeup_capable(). Reads from the file will return the corresponding removed) along with that object, by :c:func:`device_set_wakeup_capable()`.
string. Reads from the file will return the corresponding string.
The "power/wakeup" file is supposed to contain the "disabled" string initially The initial value in the :file:`power/wakeup` file is "disabled" for the
for the majority of devices; the major exceptions are power buttons, keyboards, majority of devices; the major exceptions are power buttons, keyboards, and
and Ethernet adapters whose WoL (wake-on-LAN) feature has been set up with Ethernet adapters whose WoL (wake-on-LAN) feature has been set up with ethtool.
ethtool. It should also default to "enabled" for devices that don't generate It should also default to "enabled" for devices that don't generate wakeup
wakeup requests on their own but merely forward wakeup requests from one bus to requests on their own but merely forward wakeup requests from one bus to another
another (like PCI Express ports). (like PCI Express ports).
The device_may_wakeup() routine returns true only if the "power.wakeup" object The :c:func:`device_may_wakeup()` routine returns true only if the
exists and the corresponding "power/wakeup" file contains the string "enabled". :c:member:`power.wakeup` object exists and the corresponding :file:`power/wakeup`
This information is used by subsystems, like the PCI bus type code, to see file contains the "enabled" string. This information is used by subsystems,
whether or not to enable the devices' wakeup mechanisms. If device wakeup like the PCI bus type code, to see whether or not to enable the devices' wakeup
mechanisms are enabled or disabled directly by drivers, they also should use mechanisms. If device wakeup mechanisms are enabled or disabled directly by
device_may_wakeup() to decide what to do during a system sleep transition. drivers, they also should use :c:func:`device_may_wakeup()` to decide what to do
Device drivers, however, are not supposed to call device_set_wakeup_enable() during a system sleep transition. Device drivers, however, are not expected to
directly in any case. call :c:func:`device_set_wakeup_enable()` directly in any case.
It ought to be noted that system wakeup is conceptually different from "remote It ought to be noted that system wakeup is conceptually different from "remote
wakeup" used by runtime power management, although it may be supported by the wakeup" used by runtime power management, although it may be supported by the
...@@ -201,32 +189,38 @@ some systems it is impossible to trigger them from system sleep states. In any ...@@ -201,32 +189,38 @@ some systems it is impossible to trigger them from system sleep states. In any
case, remote wakeup should always be enabled for runtime power management for case, remote wakeup should always be enabled for runtime power management for
all devices and drivers that support it. all devices and drivers that support it.
/sys/devices/.../power/control files
------------------------------------ :file:`/sys/devices/.../power/control` files
--------------------------------------------
Each device in the driver model has a flag to control whether it is subject to Each device in the driver model has a flag to control whether it is subject to
runtime power management. This flag, called runtime_auto, is initialized by the runtime power management. This flag, :c:member:`runtime_auto`, is initialized
bus type (or generally subsystem) code using pm_runtime_allow() or by the bus type (or generally subsystem) code using :c:func:`pm_runtime_allow()`
pm_runtime_forbid(); the default is to allow runtime power management. or :c:func:`pm_runtime_forbid()`; the default is to allow runtime power
management.
The setting can be adjusted by user space by writing either "on" or "auto" to The setting can be adjusted by user space by writing either "on" or "auto" to
the device's power/control sysfs file. Writing "auto" calls pm_runtime_allow(), the device's :file:`power/control` sysfs file. Writing "auto" calls
setting the flag and allowing the device to be runtime power-managed by its :c:func:`pm_runtime_allow()`, setting the flag and allowing the device to be
driver. Writing "on" calls pm_runtime_forbid(), clearing the flag, returning runtime power-managed by its driver. Writing "on" calls
the device to full power if it was in a low-power state, and preventing the :c:func:`pm_runtime_forbid()`, clearing the flag, returning the device to full
power if it was in a low-power state, and preventing the
device from being runtime power-managed. User space can check the current value device from being runtime power-managed. User space can check the current value
of the runtime_auto flag by reading the file. of the :c:member:`runtime_auto` flag by reading that file.
The device's runtime_auto flag has no effect on the handling of system-wide The device's :c:member:`runtime_auto` flag has no effect on the handling of
power transitions. In particular, the device can (and in the majority of cases system-wide power transitions. In particular, the device can (and in the
should and will) be put into a low-power state during a system-wide transition majority of cases should and will) be put into a low-power state during a
to a sleep state even though its runtime_auto flag is clear. system-wide transition to a sleep state even though its :c:member:`runtime_auto`
flag is clear.
For more information about the runtime power management framework, refer to For more information about the runtime power management framework, refer to
Documentation/power/runtime_pm.txt. :file:`Documentation/power/runtime_pm.txt`.
Calling Drivers to Enter and Leave System Sleep States Calling Drivers to Enter and Leave System Sleep States
====================================================== ======================================================
When the system goes into a sleep state, each device's driver is asked to When the system goes into a sleep state, each device's driver is asked to
suspend the device by putting it into a state compatible with the target suspend the device by putting it into a state compatible with the target
system state. That's usually some version of "off", but the details are system state. That's usually some version of "off", but the details are
...@@ -248,17 +242,18 @@ events. ...@@ -248,17 +242,18 @@ events.
Call Sequence Guarantees Call Sequence Guarantees
------------------------ ------------------------
To ensure that bridges and similar links needing to talk to a device are To ensure that bridges and similar links needing to talk to a device are
available when the device is suspended or resumed, the device tree is available when the device is suspended or resumed, the device hierarchy is
walked in a bottom-up order to suspend devices. A top-down order is walked in a bottom-up order to suspend devices. A top-down order is
used to resume those devices. used to resume those devices.
The ordering of the device tree is defined by the order in which devices The ordering of the device hierarchy is defined by the order in which devices
get registered: a child can never be registered, probed or resumed before get registered: a child can never be registered, probed or resumed before
its parent; and can't be removed or suspended after that parent. its parent; and can't be removed or suspended after that parent.
The policy is that the device tree should match hardware bus topology. The policy is that the device hierarchy should match hardware bus topology.
(Or at least the control bus, for devices which use multiple busses.) [Or at least the control bus, for devices which use multiple busses.]
In particular, this means that a device registration may fail if the parent of In particular, this means that a device registration may fail if the parent of
the device is suspending (i.e. has been chosen by the PM core as the next the device is suspending (i.e. has been chosen by the PM core as the next
device to suspend) or has already suspended, as well as after all of the other device to suspend) or has already suspended, as well as after all of the other
...@@ -268,61 +263,65 @@ situations. ...@@ -268,61 +263,65 @@ situations.
System Power Management Phases System Power Management Phases
------------------------------ ------------------------------
Suspending or resuming the system is done in several phases. Different phases Suspending or resuming the system is done in several phases. Different phases
are used for freeze, standby, and memory sleep states ("suspend-to-RAM") and the are used for suspend-to-idle, shallow (standby), and deep ("suspend-to-RAM")
hibernation state ("suspend-to-disk"). Each phase involves executing callbacks sleep states and the hibernation state ("suspend-to-disk"). Each phase involves
for every device before the next phase begins. Not all busses or classes executing callbacks for every device before the next phase begins. Not all
support all these callbacks and not all drivers use all the callbacks. The buses or classes support all these callbacks and not all drivers use all the
various phases always run after tasks have been frozen and before they are callbacks. The various phases always run after tasks have been frozen and
unfrozen. Furthermore, the *_noirq phases run at a time when IRQ handlers have before they are unfrozen. Furthermore, the ``*_noirq phases`` run at a time
been disabled (except for those marked with the IRQF_NO_SUSPEND flag). when IRQ handlers have been disabled (except for those marked with the
IRQF_NO_SUSPEND flag).
All phases use PM domain, bus, type, class or driver callbacks (that is, methods All phases use PM domain, bus, type, class or driver callbacks (that is, methods
defined in dev->pm_domain->ops, dev->bus->pm, dev->type->pm, dev->class->pm or defined in ``dev->pm_domain->ops``, ``dev->bus->pm``, ``dev->type->pm``,
dev->driver->pm). These callbacks are regarded by the PM core as mutually ``dev->class->pm`` or ``dev->driver->pm``). These callbacks are regarded by the
exclusive. Moreover, PM domain callbacks always take precedence over all of the PM core as mutually exclusive. Moreover, PM domain callbacks always take
other callbacks and, for example, type callbacks take precedence over bus, class precedence over all of the other callbacks and, for example, type callbacks take
and driver callbacks. To be precise, the following rules are used to determine precedence over bus, class and driver callbacks. To be precise, the following
which callback to execute in the given phase: rules are used to determine which callback to execute in the given phase:
1. If dev->pm_domain is present, the PM core will choose the callback 1. If ``dev->pm_domain`` is present, the PM core will choose the callback
included in dev->pm_domain->ops for execution provided by ``dev->pm_domain->ops`` for execution.
2. Otherwise, if both dev->type and dev->type->pm are present, the callback 2. Otherwise, if both ``dev->type`` and ``dev->type->pm`` are present, the
included in dev->type->pm will be chosen for execution. callback provided by ``dev->type->pm`` will be chosen for execution.
3. Otherwise, if both dev->class and dev->class->pm are present, the 3. Otherwise, if both ``dev->class`` and ``dev->class->pm`` are present,
callback included in dev->class->pm will be chosen for execution. the callback provided by ``dev->class->pm`` will be chosen for
execution.
4. Otherwise, if both dev->bus and dev->bus->pm are present, the callback 4. Otherwise, if both ``dev->bus`` and ``dev->bus->pm`` are present, the
included in dev->bus->pm will be chosen for execution. callback provided by ``dev->bus->pm`` will be chosen for execution.
This allows PM domains and device types to override callbacks provided by bus This allows PM domains and device types to override callbacks provided by bus
types or device classes if necessary. types or device classes if necessary.
The PM domain, type, class and bus callbacks may in turn invoke device- or The PM domain, type, class and bus callbacks may in turn invoke device- or
driver-specific methods stored in dev->driver->pm, but they don't have to do driver-specific methods stored in ``dev->driver->pm``, but they don't have to do
that. that.
If the subsystem callback chosen for execution is not present, the PM core will If the subsystem callback chosen for execution is not present, the PM core will
execute the corresponding method from dev->driver->pm instead if there is one. execute the corresponding method from the ``dev->driver->pm`` set instead if
there is one.
Entering System Suspend Entering System Suspend
----------------------- -----------------------
When the system goes into the freeze, standby or memory sleep state,
the phases are:
prepare, suspend, suspend_late, suspend_noirq. When the system goes into the freeze, standby or memory sleep state,
the phases are: ``prepare``, ``suspend``, ``suspend_late``, ``suspend_noirq``.
1. The prepare phase is meant to prevent races by preventing new devices 1. The ``prepare`` phase is meant to prevent races by preventing new
from being registered; the PM core would never know that all the devices from being registered; the PM core would never know that all the
children of a device had been suspended if new children could be children of a device had been suspended if new children could be
registered at will. (By contrast, devices may be unregistered at any registered at will. [By contrast, from the PM core's perspective,
time.) Unlike the other suspend-related phases, during the prepare devices may be unregistered at any time.] Unlike the other
phase the device tree is traversed top-down. suspend-related phases, during the ``prepare`` phase the device
hierarchy is traversed top-down.
After the prepare callback method returns, no new children may be After the ``->prepare`` callback method returns, no new children may be
registered below the device. The method may also prepare the device or registered below the device. The method may also prepare the device or
driver in some way for the upcoming system power transition, but it driver in some way for the upcoming system power transition, but it
should not put the device into a low-power state. should not put the device into a low-power state.
...@@ -334,35 +333,35 @@ the phases are: ...@@ -334,35 +333,35 @@ the phases are:
runtime suspend. Namely, if the prepare callback returns a positive runtime suspend. Namely, if the prepare callback returns a positive
number and that happens for all of the descendants of the device too, number and that happens for all of the descendants of the device too,
and all of them (including the device itself) are runtime-suspended, the and all of them (including the device itself) are runtime-suspended, the
PM core will skip the suspend, suspend_late and suspend_noirq suspend PM core will skip the ``suspend``, ``suspend_late`` and
phases as well as the resume_noirq, resume_early and resume phases of ``suspend_noirq`` phases as well as all of the corresponding phases of
the following system resume for all of these devices. In that case, the subsequent device resume for all of these devices. In that case,
the complete callback will be called directly after the prepare callback the ``->complete`` callback will be invoked directly after the
and is entirely responsible for bringing the device back to the ``->prepare`` callback and is entirely responsible for putting the
functional state as appropriate. device into a consistent state as appropriate.
Note that this direct-complete procedure applies even if the device is Note that this direct-complete procedure applies even if the device is
disabled for runtime PM; only the runtime-PM status matters. It follows disabled for runtime PM; only the runtime-PM status matters. It follows
that if a device has system-sleep callbacks but does not support runtime that if a device has system-sleep callbacks but does not support runtime
PM, then its prepare callback must never return a positive value. This PM, then its prepare callback must never return a positive value. This
is because all devices are initially set to runtime-suspended with is because all such devices are initially set to runtime-suspended with
runtime PM disabled. runtime PM disabled.
2. The suspend methods should quiesce the device to stop it from performing 2. The ``->suspend`` methods should quiesce the device to stop it from
I/O. They also may save the device registers and put it into the performing I/O. They also may save the device registers and put it into
appropriate low-power state, depending on the bus type the device is on, the appropriate low-power state, depending on the bus type the device is
and they may enable wakeup events. on, and they may enable wakeup events.
3 For a number of devices it is convenient to split suspend into the 3. For a number of devices it is convenient to split suspend into the
"quiesce device" and "save device state" phases, in which cases "quiesce device" and "save device state" phases, in which cases
suspend_late is meant to do the latter. It is always executed after ``suspend_late`` is meant to do the latter. It is always executed after
runtime power management has been disabled for all devices. runtime power management has been disabled for the device in question.
4. The suspend_noirq phase occurs after IRQ handlers have been disabled, 4. The ``suspend_noirq`` phase occurs after IRQ handlers have been disabled,
which means that the driver's interrupt handler will not be called while which means that the driver's interrupt handler will not be called while
the callback method is running. The methods should save the values of the callback method is running. The ``->suspend_noirq`` methods should
the device's registers that weren't saved previously and finally put the save the values of the device's registers that weren't saved previously
device into the appropriate low-power state. and finally put the device into the appropriate low-power state.
The majority of subsystems and device drivers need not implement this The majority of subsystems and device drivers need not implement this
callback. However, bus types allowing devices to share interrupt callback. However, bus types allowing devices to share interrupt
...@@ -375,65 +374,69 @@ At the end of these phases, drivers should have stopped all I/O transactions ...@@ -375,65 +374,69 @@ At the end of these phases, drivers should have stopped all I/O transactions
(DMA, IRQs), saved enough state that they can re-initialize or restore previous (DMA, IRQs), saved enough state that they can re-initialize or restore previous
state (as needed by the hardware), and placed the device into a low-power state. state (as needed by the hardware), and placed the device into a low-power state.
On many platforms they will gate off one or more clock sources; sometimes they On many platforms they will gate off one or more clock sources; sometimes they
will also switch off power supplies or reduce voltages. (Drivers supporting will also switch off power supplies or reduce voltages. [Drivers supporting
runtime PM may already have performed some or all of these steps.) runtime PM may already have performed some or all of these steps.]
If device_may_wakeup(dev) returns true, the device should be prepared for If :c:func:`device_may_wakeup(dev)` returns ``true``, the device should be
generating hardware wakeup signals to trigger a system wakeup event when the prepared for generating hardware wakeup signals to trigger a system wakeup event
system is in the sleep state. For example, enable_irq_wake() might identify when the system is in the sleep state. For example, :c:func:`enable_irq_wake()`
GPIO signals hooked up to a switch or other external hardware, and might identify GPIO signals hooked up to a switch or other external hardware,
pci_enable_wake() does something similar for the PCI PME signal. and :c:func:`pci_enable_wake()` does something similar for the PCI PME signal.
If any of these callbacks returns an error, the system won't enter the desired If any of these callbacks returns an error, the system won't enter the desired
low-power state. Instead the PM core will unwind its actions by resuming all low-power state. Instead, the PM core will unwind its actions by resuming all
the devices that were suspended. the devices that were suspended.
Leaving System Suspend Leaving System Suspend
---------------------- ----------------------
When resuming from freeze, standby or memory sleep, the phases are:
resume_noirq, resume_early, resume, complete.
1. The resume_noirq callback methods should perform any actions needed When resuming from freeze, standby or memory sleep, the phases are:
before the driver's interrupt handlers are invoked. This generally ``resume_noirq``, ``resume_early``, ``resume``, ``complete``.
means undoing the actions of the suspend_noirq phase. If the bus type
permits devices to share interrupt vectors, like PCI, the method should 1. The ``->resume_noirq`` callback methods should perform any actions
bring the device and its driver into a state in which the driver can needed before the driver's interrupt handlers are invoked. This
recognize if the device is the source of incoming interrupts, if any, generally means undoing the actions of the ``suspend_noirq`` phase. If
and handle them correctly. the bus type permits devices to share interrupt vectors, like PCI, the
method should bring the device and its driver into a state in which the
For example, the PCI bus type's ->pm.resume_noirq() puts the device into driver can recognize if the device is the source of incoming interrupts,
the full-power state (D0 in the PCI terminology) and restores the if any, and handle them correctly.
For example, the PCI bus type's ``->pm.resume_noirq()`` puts the device
into the full-power state (D0 in the PCI terminology) and restores the
standard configuration registers of the device. Then it calls the standard configuration registers of the device. Then it calls the
device driver's ->pm.resume_noirq() method to perform device-specific device driver's ``->pm.resume_noirq()`` method to perform device-specific
actions. actions.
2. The resume_early methods should prepare devices for the execution of 2. The ``->resume_early`` methods should prepare devices for the execution
the resume methods. This generally involves undoing the actions of the of the resume methods. This generally involves undoing the actions of
preceding suspend_late phase. the preceding ``suspend_late`` phase.
3 The resume methods should bring the device back to its operating 3. The ``->resume`` methods should bring the device back to its operating
state, so that it can perform normal I/O. This generally involves state, so that it can perform normal I/O. This generally involves
undoing the actions of the suspend phase. undoing the actions of the ``suspend`` phase.
4. The complete phase should undo the actions of the prepare phase. Note, 4. The ``complete`` phase should undo the actions of the ``prepare`` phase.
however, that new children may be registered below the device as soon as For this reason, unlike the other resume-related phases, during the
the resume callbacks occur; it's not necessary to wait until the ``complete`` phase the device hierarchy is traversed bottom-up.
complete phase.
Note, however, that new children may be registered below the device as
Moreover, if the preceding prepare callback returned a positive number, soon as the ``->resume`` callbacks occur; it's not necessary to wait
the device may have been left in runtime suspend throughout the whole until the ``complete`` phase with that.
system suspend and resume (the suspend, suspend_late, suspend_noirq
phases of system suspend and the resume_noirq, resume_early, resume Moreover, if the preceding ``->prepare`` callback returned a positive
phases of system resume may have been skipped for it). In that case, number, the device may have been left in runtime suspend throughout the
the complete callback is entirely responsible for bringing the device whole system suspend and resume (the ``suspend``, ``suspend_late``,
back to the functional state after system suspend if necessary. [For ``suspend_noirq`` phases of system suspend and the ``resume_noirq``,
example, it may need to queue up a runtime resume request for the device ``resume_early``, ``resume`` phases of system resume may have been
for this purpose.] To check if that is the case, the complete callback skipped for it). In that case, the ``->complete`` callback is entirely
can consult the device's power.direct_complete flag. Namely, if that responsible for putting the device into a consistent state after system
flag is set when the complete callback is being run, it has been called suspend if necessary. [For example, it may need to queue up a runtime
directly after the preceding prepare and special action may be required resume request for the device for this purpose.] To check if that is
the case, the ``->complete`` callback can consult the device's
``power.direct_complete`` flag. Namely, if that flag is set when the
``->complete`` callback is being run, it has been called directly after
the preceding ``->prepare`` and special actions may be required
to make the device work correctly afterward. to make the device work correctly afterward.
At the end of these phases, drivers should be as functional as they were before At the end of these phases, drivers should be as functional as they were before
...@@ -446,12 +449,14 @@ the end of resume might not be the one which preceded suspension. ...@@ -446,12 +449,14 @@ the end of resume might not be the one which preceded suspension.
That means availability of certain clocks or power supplies changed, That means availability of certain clocks or power supplies changed,
which could easily affect how a driver works. which could easily affect how a driver works.
Drivers need to be able to handle hardware which has been reset since the Drivers need to be able to handle hardware which has been reset since all of the
suspend methods were called, for example by complete reinitialization. suspend methods were called, for example by complete reinitialization.
This may be the hardest part, and the one most protected by NDA'd documents This may be the hardest part, and the one most protected by NDA'd documents
and chip errata. It's simplest if the hardware state hasn't changed since and chip errata. It's simplest if the hardware state hasn't changed since
the suspend was carried out, but that can't be guaranteed (in fact, it usually the suspend was carried out, but that can only be guaranteed if the target
is not the case). system sleep entered was suspend-to-idle. For the other system sleep states
that may not be the case (and usually isn't for ACPI-defined system sleep
states, like S3).
Drivers must also be prepared to notice that the device has been removed Drivers must also be prepared to notice that the device has been removed
while the system was powered down, whenever that's physically possible. while the system was powered down, whenever that's physically possible.
...@@ -467,197 +472,174 @@ the system log. ...@@ -467,197 +472,174 @@ the system log.
Entering Hibernation Entering Hibernation
-------------------- --------------------
Hibernating the system is more complicated than putting it into the other
sleep states, because it involves creating and saving a system image.
Therefore there are more phases for hibernation, with a different set of
callbacks. These phases always run after tasks have been frozen and memory has
been freed.
The general procedure for hibernation is to quiesce all devices (freeze), create Hibernating the system is more complicated than putting it into sleep states,
an image of the system memory while everything is stable, reactivate all because it involves creating and saving a system image. Therefore there are
devices (thaw), write the image to permanent storage, and finally shut down the more phases for hibernation, with a different set of callbacks. These phases
system (poweroff). The phases used to accomplish this are: always run after tasks have been frozen and enough memory has been freed.
prepare, freeze, freeze_late, freeze_noirq, thaw_noirq, thaw_early, The general procedure for hibernation is to quiesce all devices ("freeze"),
thaw, complete, prepare, poweroff, poweroff_late, poweroff_noirq create an image of the system memory while everything is stable, reactivate all
devices ("thaw"), write the image to permanent storage, and finally shut down
the system ("power off"). The phases used to accomplish this are: ``prepare``,
``freeze``, ``freeze_late``, ``freeze_noirq``, ``thaw_noirq``, ``thaw_early``,
``thaw``, ``complete``, ``prepare``, ``poweroff``, ``poweroff_late``,
``poweroff_noirq``.
1. The prepare phase is discussed in the "Entering System Suspend" section 1. The ``prepare`` phase is discussed in the "Entering System Suspend"
above. section above.
2. The freeze methods should quiesce the device so that it doesn't generate 2. The ``->freeze`` methods should quiesce the device so that it doesn't
IRQs or DMA, and they may need to save the values of device registers. generate IRQs or DMA, and they may need to save the values of device
However the device does not have to be put in a low-power state, and to registers. However the device does not have to be put in a low-power
save time it's best not to do so. Also, the device should not be state, and to save time it's best not to do so. Also, the device should
prepared to generate wakeup events. not be prepared to generate wakeup events.
3. The freeze_late phase is analogous to the suspend_late phase described 3. The ``freeze_late`` phase is analogous to the ``suspend_late`` phase
above, except that the device should not be put in a low-power state and described earlier, except that the device should not be put into a
should not be allowed to generate wakeup events by it. low-power state and should not be allowed to generate wakeup events.
4. The freeze_noirq phase is analogous to the suspend_noirq phase discussed 4. The ``freeze_noirq`` phase is analogous to the ``suspend_noirq`` phase
above, except again that the device should not be put in a low-power discussed earlier, except again that the device should not be put into
state and should not be allowed to generate wakeup events. a low-power state and should not be allowed to generate wakeup events.
At this point the system image is created. All devices should be inactive and At this point the system image is created. All devices should be inactive and
the contents of memory should remain undisturbed while this happens, so that the the contents of memory should remain undisturbed while this happens, so that the
image forms an atomic snapshot of the system state. image forms an atomic snapshot of the system state.
5. The thaw_noirq phase is analogous to the resume_noirq phase discussed 5. The ``thaw_noirq`` phase is analogous to the ``resume_noirq`` phase
above. The main difference is that its methods can assume the device is discussed earlier. The main difference is that its methods can assume
in the same state as at the end of the freeze_noirq phase. the device is in the same state as at the end of the ``freeze_noirq``
phase.
6. The thaw_early phase is analogous to the resume_early phase described 6. The ``thaw_early`` phase is analogous to the ``resume_early`` phase
above. Its methods should undo the actions of the preceding described above. Its methods should undo the actions of the preceding
freeze_late, if necessary. ``freeze_late``, if necessary.
7. The thaw phase is analogous to the resume phase discussed above. Its 7. The ``thaw`` phase is analogous to the ``resume`` phase discussed
methods should bring the device back to an operating state, so that it earlier. Its methods should bring the device back to an operating
can be used for saving the image if necessary. state, so that it can be used for saving the image if necessary.
8. The complete phase is discussed in the "Leaving System Suspend" section 8. The ``complete`` phase is discussed in the "Leaving System Suspend"
above. section above.
At this point the system image is saved, and the devices then need to be At this point the system image is saved, and the devices then need to be
prepared for the upcoming system shutdown. This is much like suspending them prepared for the upcoming system shutdown. This is much like suspending them
before putting the system into the freeze, standby or memory sleep state, before putting the system into the suspend-to-idle, shallow or deep sleep state,
and the phases are similar. and the phases are similar.
9. The prepare phase is discussed above. 9. The ``prepare`` phase is discussed above.
10. The poweroff phase is analogous to the suspend phase. 10. The ``poweroff`` phase is analogous to the ``suspend`` phase.
11. The poweroff_late phase is analogous to the suspend_late phase. 11. The ``poweroff_late`` phase is analogous to the ``suspend_late`` phase.
12. The poweroff_noirq phase is analogous to the suspend_noirq phase. 12. The ``poweroff_noirq`` phase is analogous to the ``suspend_noirq`` phase.
The poweroff, poweroff_late and poweroff_noirq callbacks should do essentially The ``->poweroff``, ``->poweroff_late`` and ``->poweroff_noirq`` callbacks
the same things as the suspend, suspend_late and suspend_noirq callbacks, should do essentially the same things as the ``->suspend``, ``->suspend_late``
respectively. The only notable difference is that they need not store the and ``->suspend_noirq`` callbacks, respectively. The only notable difference is
device register values, because the registers should already have been stored that they need not store the device register values, because the registers
during the freeze, freeze_late or freeze_noirq phases. should already have been stored during the ``freeze``, ``freeze_late`` or
``freeze_noirq`` phases.
Leaving Hibernation Leaving Hibernation
------------------- -------------------
Resuming from hibernation is, again, more complicated than resuming from a sleep Resuming from hibernation is, again, more complicated than resuming from a sleep
state in which the contents of main memory are preserved, because it requires state in which the contents of main memory are preserved, because it requires
a system image to be loaded into memory and the pre-hibernation memory contents a system image to be loaded into memory and the pre-hibernation memory contents
to be restored before control can be passed back to the image kernel. to be restored before control can be passed back to the image kernel.
Although in principle, the image might be loaded into memory and the Although in principle the image might be loaded into memory and the
pre-hibernation memory contents restored by the boot loader, in practice this pre-hibernation memory contents restored by the boot loader, in practice this
can't be done because boot loaders aren't smart enough and there is no can't be done because boot loaders aren't smart enough and there is no
established protocol for passing the necessary information. So instead, the established protocol for passing the necessary information. So instead, the
boot loader loads a fresh instance of the kernel, called the boot kernel, into boot loader loads a fresh instance of the kernel, called "the restore kernel",
memory and passes control to it in the usual way. Then the boot kernel reads into memory and passes control to it in the usual way. Then the restore kernel
the system image, restores the pre-hibernation memory contents, and passes reads the system image, restores the pre-hibernation memory contents, and passes
control to the image kernel. Thus two different kernels are involved in control to the image kernel. Thus two different kernel instances are involved
resuming from hibernation. In fact, the boot kernel may be completely different in resuming from hibernation. In fact, the restore kernel may be completely
from the image kernel: a different configuration and even a different version. different from the image kernel: a different configuration and even a different
This has important consequences for device drivers and their subsystems. version. This has important consequences for device drivers and their
subsystems.
To be able to load the system image into memory, the boot kernel needs to
To be able to load the system image into memory, the restore kernel needs to
include at least a subset of device drivers allowing it to access the storage include at least a subset of device drivers allowing it to access the storage
medium containing the image, although it doesn't need to include all of the medium containing the image, although it doesn't need to include all of the
drivers present in the image kernel. After the image has been loaded, the drivers present in the image kernel. After the image has been loaded, the
devices managed by the boot kernel need to be prepared for passing control back devices managed by the boot kernel need to be prepared for passing control back
to the image kernel. This is very similar to the initial steps involved in to the image kernel. This is very similar to the initial steps involved in
creating a system image, and it is accomplished in the same way, using prepare, creating a system image, and it is accomplished in the same way, using
freeze, and freeze_noirq phases. However the devices affected by these phases ``prepare``, ``freeze``, and ``freeze_noirq`` phases. However, the devices
are only those having drivers in the boot kernel; other devices will still be in affected by these phases are only those having drivers in the restore kernel;
whatever state the boot loader left them. other devices will still be in whatever state the boot loader left them.
Should the restoration of the pre-hibernation memory contents fail, the boot Should the restoration of the pre-hibernation memory contents fail, the restore
kernel would go through the "thawing" procedure described above, using the kernel would go through the "thawing" procedure described above, using the
thaw_noirq, thaw, and complete phases, and then continue running normally. This ``thaw_noirq``, ``thaw_early``, ``thaw``, and ``complete`` phases, and then
happens only rarely. Most often the pre-hibernation memory contents are continue running normally. This happens only rarely. Most often the
restored successfully and control is passed to the image kernel, which then pre-hibernation memory contents are restored successfully and control is passed
becomes responsible for bringing the system back to the working state. to the image kernel, which then becomes responsible for bringing the system back
to the working state.
To achieve this, the image kernel must restore the devices' pre-hibernation To achieve this, the image kernel must restore the devices' pre-hibernation
functionality. The operation is much like waking up from the memory sleep functionality. The operation is much like waking up from a sleep state (with
state, although it involves different phases: the memory contents preserved), although it involves different phases:
``restore_noirq``, ``restore_early``, ``restore``, ``complete``.
restore_noirq, restore_early, restore, complete 1. The ``restore_noirq`` phase is analogous to the ``resume_noirq`` phase.
1. The restore_noirq phase is analogous to the resume_noirq phase. 2. The ``restore_early`` phase is analogous to the ``resume_early`` phase.
2. The restore_early phase is analogous to the resume_early phase. 3. The ``restore`` phase is analogous to the ``resume`` phase.
3. The restore phase is analogous to the resume phase. 4. The ``complete`` phase is discussed above.
4. The complete phase is discussed above. The main difference from ``resume[_early|_noirq]`` is that
``restore[_early|_noirq]`` must assume the device has been accessed and
reconfigured by the boot loader or the restore kernel. Consequently, the state
of the device may be different from the state remembered from the ``freeze``,
``freeze_late`` and ``freeze_noirq`` phases. The device may even need to be
reset and completely re-initialized. In many cases this difference doesn't
matter, so the ``->resume[_early|_noirq]`` and ``->restore[_early|_norq]``
method pointers can be set to the same routines. Nevertheless, different
callback pointers are used in case there is a situation where it actually does
matter.
The main difference from resume[_early|_noirq] is that restore[_early|_noirq]
must assume the device has been accessed and reconfigured by the boot loader or
the boot kernel. Consequently the state of the device may be different from the
state remembered from the freeze, freeze_late and freeze_noirq phases. The
device may even need to be reset and completely re-initialized. In many cases
this difference doesn't matter, so the resume[_early|_noirq] and
restore[_early|_norq] method pointers can be set to the same routines.
Nevertheless, different callback pointers are used in case there is a situation
where it actually does matter.
Power Management Notifiers
==========================
Device Power Management Domains There are some operations that cannot be carried out by the power management
------------------------------- callbacks discussed above, because the callbacks occur too late or too early.
Sometimes devices share reference clocks or other power resources. In those To handle these cases, subsystems and device drivers may register power
cases it generally is not possible to put devices into low-power states management notifiers that are called before tasks are frozen and after they have
individually. Instead, a set of devices sharing a power resource can be put been thawed. Generally speaking, the PM notifiers are suitable for performing
into a low-power state together at the same time by turning off the shared actions that either require user space to be available, or at least won't
power resource. Of course, they also need to be put into the full-power state interfere with user space.
together, by turning the shared power resource on. A set of devices with this
property is often referred to as a power domain. A power domain may also be
nested inside another power domain. The nested domain is referred to as the
sub-domain of the parent domain.
Support for power domains is provided through the pm_domain field of struct For details refer to :file:`Documentation/power/notifiers.txt`.
device. This field is a pointer to an object of type struct dev_pm_domain,
defined in include/linux/pm.h, providing a set of power management callbacks
analogous to the subsystem-level and device driver callbacks that are executed
for the given device during all power transitions, instead of the respective
subsystem-level callbacks. Specifically, if a device's pm_domain pointer is
not NULL, the ->suspend() callback from the object pointed to by it will be
executed instead of its subsystem's (e.g. bus type's) ->suspend() callback and
analogously for all of the remaining callbacks. In other words, power
management domain callbacks, if defined for the given device, always take
precedence over the callbacks provided by the device's subsystem (e.g. bus
type).
The support for device power management domains is only relevant to platforms
needing to use the same device driver power management callbacks in many
different power domain configurations and wanting to avoid incorporating the
support for power domains into subsystem-level callbacks, for example by
modifying the platform bus type. Other platforms need not implement it or take
it into account in any way.
Devices may be defined as IRQ-safe which indicates to the PM core that their Device Low-Power (suspend) States
runtime PM callbacks may be invoked with disabled interrupts (see =================================
Documentation/power/runtime_pm.txt for more information). If an IRQ-safe
device belongs to a PM domain, the runtime PM of the domain will be
disallowed, unless the domain itself is defined as IRQ-safe. However, it
makes sense to define a PM domain as IRQ-safe only if all the devices in it
are IRQ-safe. Moreover, if an IRQ-safe domain has a parent domain, the runtime
PM of the parent is only allowed if the parent itself is IRQ-safe too with the
additional restriction that all child domains of an IRQ-safe parent must also
be IRQ-safe.
Device Low Power (suspend) States
---------------------------------
Device low-power states aren't standard. One device might only handle Device low-power states aren't standard. One device might only handle
"on" and "off", while another might support a dozen different versions of "on" and "off", while another might support a dozen different versions of
"on" (how many engines are active?), plus a state that gets back to "on" "on" (how many engines are active?), plus a state that gets back to "on"
faster than from a full "off". faster than from a full "off".
Some busses define rules about what different suspend states mean. PCI Some buses define rules about what different suspend states mean. PCI
gives one example: after the suspend sequence completes, a non-legacy gives one example: after the suspend sequence completes, a non-legacy
PCI device may not perform DMA or issue IRQs, and any wakeup events it PCI device may not perform DMA or issue IRQs, and any wakeup events it
issues would be issued through the PME# bus signal. Plus, there are issues would be issued through the PME# bus signal. Plus, there are
several PCI-standard device states, some of which are optional. several PCI-standard device states, some of which are optional.
In contrast, integrated system-on-chip processors often use IRQs as the In contrast, integrated system-on-chip processors often use IRQs as the
wakeup event sources (so drivers would call enable_irq_wake) and might wakeup event sources (so drivers would call :c:func:`enable_irq_wake`) and
be able to treat DMA completion as a wakeup event (sometimes DMA can stay might be able to treat DMA completion as a wakeup event (sometimes DMA can stay
active too, it'd only be the CPU and some peripherals that sleep). active too, it'd only be the CPU and some peripherals that sleep).
Some details here may be platform-specific. Systems may have devices that Some details here may be platform-specific. Systems may have devices that
...@@ -674,21 +656,54 @@ ways; the aforementioned LCD might be active in one product's "standby", ...@@ -674,21 +656,54 @@ ways; the aforementioned LCD might be active in one product's "standby",
but a different product using the same SOC might work differently. but a different product using the same SOC might work differently.
Power Management Notifiers Device Power Management Domains
-------------------------- ===============================
There are some operations that cannot be carried out by the power management
callbacks discussed above, because the callbacks occur too late or too early. Sometimes devices share reference clocks or other power resources. In those
To handle these cases, subsystems and device drivers may register power cases it generally is not possible to put devices into low-power states
management notifiers that are called before tasks are frozen and after they have individually. Instead, a set of devices sharing a power resource can be put
been thawed. Generally speaking, the PM notifiers are suitable for performing into a low-power state together at the same time by turning off the shared
actions that either require user space to be available, or at least won't power resource. Of course, they also need to be put into the full-power state
interfere with user space. together, by turning the shared power resource on. A set of devices with this
property is often referred to as a power domain. A power domain may also be
nested inside another power domain. The nested domain is referred to as the
sub-domain of the parent domain.
For details refer to Documentation/power/notifiers.txt. Support for power domains is provided through the :c:member:`pm_domain` field of
|struct| :c:type:`device`. This field is a pointer to an object of
type |struct| :c:type:`dev_pm_domain`, defined in :file:`include/linux/pm.h``,
providing a set of power management callbacks analogous to the subsystem-level
and device driver callbacks that are executed for the given device during all
power transitions, instead of the respective subsystem-level callbacks.
Specifically, if a device's :c:member:`pm_domain` pointer is not NULL, the
``->suspend()`` callback from the object pointed to by it will be executed
instead of its subsystem's (e.g. bus type's) ``->suspend()`` callback and
analogously for all of the remaining callbacks. In other words, power
management domain callbacks, if defined for the given device, always take
precedence over the callbacks provided by the device's subsystem (e.g. bus type).
The support for device power management domains is only relevant to platforms
needing to use the same device driver power management callbacks in many
different power domain configurations and wanting to avoid incorporating the
support for power domains into subsystem-level callbacks, for example by
modifying the platform bus type. Other platforms need not implement it or take
it into account in any way.
Devices may be defined as IRQ-safe which indicates to the PM core that their
runtime PM callbacks may be invoked with disabled interrupts (see
:file:`Documentation/power/runtime_pm.txt` for more information). If an
IRQ-safe device belongs to a PM domain, the runtime PM of the domain will be
disallowed, unless the domain itself is defined as IRQ-safe. However, it
makes sense to define a PM domain as IRQ-safe only if all the devices in it
are IRQ-safe. Moreover, if an IRQ-safe domain has a parent domain, the runtime
PM of the parent is only allowed if the parent itself is IRQ-safe too with the
additional restriction that all child domains of an IRQ-safe parent must also
be IRQ-safe.
Runtime Power Management Runtime Power Management
======================== ========================
Many devices are able to dynamically power down while the system is still Many devices are able to dynamically power down while the system is still
running. This feature is useful for devices that are not being used, and running. This feature is useful for devices that are not being used, and
can offer significant power savings on a running system. These devices can offer significant power savings on a running system. These devices
...@@ -711,6 +726,7 @@ disabled. This all depends on the hardware and the design of the subsystem and ...@@ -711,6 +726,7 @@ disabled. This all depends on the hardware and the design of the subsystem and
device driver in question. device driver in question.
During system-wide resume from a sleep state it's easiest to put devices into During system-wide resume from a sleep state it's easiest to put devices into
the full-power state, as explained in Documentation/power/runtime_pm.txt. Refer the full-power state, as explained in :file:`Documentation/power/runtime_pm.txt`.
to that document for more information regarding this particular issue as well as Refer to that document for more information regarding this particular issue as
for information on the device runtime power management framework in general. well as for information on the device runtime power management framework in
general.
=======================
Device Power Management
=======================
.. toctree::
devices
types
.. only:: subproject and html
Indices
=======
* :ref:`genindex`
==================================
Device Power Management Data Types
==================================
.. kernel-doc:: include/linux/pm.h
...@@ -276,9 +276,6 @@ typedef struct pm_message { ...@@ -276,9 +276,6 @@ typedef struct pm_message {
* example, if it detects that a child was unplugged while the system was * example, if it detects that a child was unplugged while the system was
* asleep). * asleep).
* *
* Refer to Documentation/power/devices.txt for more information about the role
* of the above callbacks in the system suspend process.
*
* There also are callbacks related to runtime power management of devices. * There also are callbacks related to runtime power management of devices.
* Again, as a rule these callbacks are executed by the PM core for subsystems * Again, as a rule these callbacks are executed by the PM core for subsystems
* (PM domains, device types, classes and bus types) and the subsystem-level * (PM domains, device types, classes and bus types) and the subsystem-level
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment