aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/power/runtime_pm.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/power/runtime_pm.txt')
-rw-r--r--Documentation/power/runtime_pm.txt158
1 files changed, 86 insertions, 72 deletions
diff --git a/Documentation/power/runtime_pm.txt b/Documentation/power/runtime_pm.txt
index 5336149f831b..4abe83e1045a 100644
--- a/Documentation/power/runtime_pm.txt
+++ b/Documentation/power/runtime_pm.txt
@@ -44,98 +44,112 @@ struct dev_pm_ops {
44}; 44};
45 45
46The ->runtime_suspend(), ->runtime_resume() and ->runtime_idle() callbacks 46The ->runtime_suspend(), ->runtime_resume() and ->runtime_idle() callbacks
47are executed by the PM core for either the power domain, or the device type 47are executed by the PM core for the device's subsystem that may be either of
48(if the device power domain's struct dev_pm_ops does not exist), or the class 48the following:
49(if the device power domain's and type's struct dev_pm_ops object does not 49
50exist), or the bus type (if the device power domain's, type's and class' 50 1. PM domain of the device, if the device's PM domain object, dev->pm_domain,
51struct dev_pm_ops objects do not exist) of the given device, so the priority 51 is present.
52order of callbacks from high to low is that power domain callbacks, device 52
53type callbacks, class callbacks and bus type callbacks, and the high priority 53 2. Device type of the device, if both dev->type and dev->type->pm are present.
54one will take precedence over low priority one. The bus type, device type and 54
55class callbacks are referred to as subsystem-level callbacks in what follows, 55 3. Device class of the device, if both dev->class and dev->class->pm are
56and generally speaking, the power domain callbacks are used for representing 56 present.
57power domains within a SoC. 57
58 4. Bus type of the device, if both dev->bus and dev->bus->pm are present.
59
60If the subsystem chosen by applying the above rules doesn't provide the relevant
61callback, the PM core will invoke the corresponding driver callback stored in
62dev->driver->pm directly (if present).
63
64The PM core always checks which callback to use in the order given above, so the
65priority order of callbacks from high to low is: PM domain, device type, class
66and bus type. Moreover, the high-priority one will always take precedence over
67a low-priority one. The PM domain, bus type, device type and class callbacks
68are referred to as subsystem-level callbacks in what follows.
58 69
59By default, the callbacks are always invoked in process context with interrupts 70By default, the callbacks are always invoked in process context with interrupts
60enabled. However, subsystems can use the pm_runtime_irq_safe() helper function 71enabled. However, the pm_runtime_irq_safe() helper function can be used to tell
61to tell the PM core that a device's ->runtime_suspend() and ->runtime_resume() 72the PM core that it is safe to run the ->runtime_suspend(), ->runtime_resume()
62callbacks should be invoked in atomic context with interrupts disabled. 73and ->runtime_idle() callbacks for the given device in atomic context with
63This implies that these callback routines must not block or sleep, but it also 74interrupts disabled. This implies that the callback routines in question must
64means that the synchronous helper functions listed at the end of Section 4 can 75not block or sleep, but it also means that the synchronous helper functions
65be used within an interrupt handler or in an atomic context. 76listed at the end of Section 4 may be used for that device within an interrupt
66 77handler or generally in an atomic context.
67The subsystem-level suspend callback is _entirely_ _responsible_ for handling 78
68the suspend of the device as appropriate, which may, but need not include 79The subsystem-level suspend callback, if present, is _entirely_ _responsible_
69executing the device driver's own ->runtime_suspend() callback (from the 80for handling the suspend of the device as appropriate, which may, but need not
81include executing the device driver's own ->runtime_suspend() callback (from the
70PM core's point of view it is not necessary to implement a ->runtime_suspend() 82PM core's point of view it is not necessary to implement a ->runtime_suspend()
71callback in a device driver as long as the subsystem-level suspend callback 83callback in a device driver as long as the subsystem-level suspend callback
72knows what to do to handle the device). 84knows what to do to handle the device).
73 85
74 * Once the subsystem-level suspend callback has completed successfully 86 * Once the subsystem-level suspend callback (or the driver suspend callback,
75 for given device, the PM core regards the device as suspended, which need 87 if invoked directly) has completed successfully for the given device, the PM
76 not mean that the device has been put into a low power state. It is 88 core regards the device as suspended, which need not mean that it has been
77 supposed to mean, however, that the device will not process data and will 89 put into a low power state. It is supposed to mean, however, that the
78 not communicate with the CPU(s) and RAM until the subsystem-level resume 90 device will not process data and will not communicate with the CPU(s) and
79 callback is executed for it. The runtime PM status of a device after 91 RAM until the appropriate resume callback is executed for it. The runtime
80 successful execution of the subsystem-level suspend callback is 'suspended'. 92 PM status of a device after successful execution of the suspend callback is
81 93 'suspended'.
82 * If the subsystem-level suspend callback returns -EBUSY or -EAGAIN, 94
83 the device's runtime PM status is 'active', which means that the device 95 * If the suspend callback returns -EBUSY or -EAGAIN, the device's runtime PM
84 _must_ be fully operational afterwards. 96 status remains 'active', which means that the device _must_ be fully
85 97 operational afterwards.
86 * If the subsystem-level suspend callback returns an error code different 98
87 from -EBUSY or -EAGAIN, the PM core regards this as a fatal error and will 99 * If the suspend callback returns an error code different from -EBUSY and
88 refuse to run the helper functions described in Section 4 for the device, 100 -EAGAIN, the PM core regards this as a fatal error and will refuse to run
89 until the status of it is directly set either to 'active', or to 'suspended' 101 the helper functions described in Section 4 for the device until its status
90 (the PM core provides special helper functions for this purpose). 102 is directly set to either'active', or 'suspended' (the PM core provides
91 103 special helper functions for this purpose).
92In particular, if the driver requires remote wake-up capability (i.e. hardware 104
105In particular, if the driver requires remote wakeup capability (i.e. hardware
93mechanism allowing the device to request a change of its power state, such as 106mechanism allowing the device to request a change of its power state, such as
94PCI PME) for proper functioning and device_run_wake() returns 'false' for the 107PCI PME) for proper functioning and device_run_wake() returns 'false' for the
95device, then ->runtime_suspend() should return -EBUSY. On the other hand, if 108device, then ->runtime_suspend() should return -EBUSY. On the other hand, if
96device_run_wake() returns 'true' for the device and the device is put into a low 109device_run_wake() returns 'true' for the device and the device is put into a
97power state during the execution of the subsystem-level suspend callback, it is 110low-power state during the execution of the suspend callback, it is expected
98expected that remote wake-up will be enabled for the device. Generally, remote 111that remote wakeup will be enabled for the device. Generally, remote wakeup
99wake-up should be enabled for all input devices put into a low power state at 112should be enabled for all input devices put into low-power states at run time.
100run time. 113
101 114The subsystem-level resume callback, if present, is _entirely_ _responsible_ for
102The subsystem-level resume callback is _entirely_ _responsible_ for handling the 115handling the resume of the device as appropriate, which may, but need not
103resume of the device as appropriate, which may, but need not include executing 116include executing the device driver's own ->runtime_resume() callback (from the
104the device driver's own ->runtime_resume() callback (from the PM core's point of 117PM core's point of view it is not necessary to implement a ->runtime_resume()
105view it is not necessary to implement a ->runtime_resume() callback in a device 118callback in a device driver as long as the subsystem-level resume callback knows
106driver as long as the subsystem-level resume callback knows what to do to handle 119what to do to handle the device).
107the device). 120
108 121 * Once the subsystem-level resume callback (or the driver resume callback, if
109 * Once the subsystem-level resume callback has completed successfully, the PM 122 invoked directly) has completed successfully, the PM core regards the device
110 core regards the device as fully operational, which means that the device 123 as fully operational, which means that the device _must_ be able to complete
111 _must_ be able to complete I/O operations as needed. The runtime PM status 124 I/O operations as needed. The runtime PM status of the device is then
112 of the device is then 'active'. 125 'active'.
113 126
114 * If the subsystem-level resume callback returns an error code, the PM core 127 * If the resume callback returns an error code, the PM core regards this as a
115 regards this as a fatal error and will refuse to run the helper functions 128 fatal error and will refuse to run the helper functions described in Section
116 described in Section 4 for the device, until its status is directly set 129 4 for the device, until its status is directly set to either 'active', or
117 either to 'active' or to 'suspended' (the PM core provides special helper 130 'suspended' (by means of special helper functions provided by the PM core
118 functions for this purpose). 131 for this purpose).
119 132
120The subsystem-level idle callback is executed by the PM core whenever the device 133The idle callback (a subsystem-level one, if present, or the driver one) is
121appears to be idle, which is indicated to the PM core by two counters, the 134executed by the PM core whenever the device appears to be idle, which is
122device's usage counter and the counter of 'active' children of the device. 135indicated to the PM core by two counters, the device's usage counter and the
136counter of 'active' children of the device.
123 137
124 * If any of these counters is decreased using a helper function provided by 138 * If any of these counters is decreased using a helper function provided by
125 the PM core and it turns out to be equal to zero, the other counter is 139 the PM core and it turns out to be equal to zero, the other counter is
126 checked. If that counter also is equal to zero, the PM core executes the 140 checked. If that counter also is equal to zero, the PM core executes the
127 subsystem-level idle callback with the device as an argument. 141 idle callback with the device as its argument.
128 142
129The action performed by a subsystem-level idle callback is totally dependent on 143The action performed by the idle callback is totally dependent on the subsystem
130the subsystem in question, but the expected and recommended action is to check 144(or driver) in question, but the expected and recommended action is to check
131if the device can be suspended (i.e. if all of the conditions necessary for 145if the device can be suspended (i.e. if all of the conditions necessary for
132suspending the device are satisfied) and to queue up a suspend request for the 146suspending the device are satisfied) and to queue up a suspend request for the
133device in that case. The value returned by this callback is ignored by the PM 147device in that case. The value returned by this callback is ignored by the PM
134core. 148core.
135 149
136The helper functions provided by the PM core, described in Section 4, guarantee 150The helper functions provided by the PM core, described in Section 4, guarantee
137that the following constraints are met with respect to the bus type's runtime 151that the following constraints are met with respect to runtime PM callbacks for
138PM callbacks: 152one device:
139 153
140(1) The callbacks are mutually exclusive (e.g. it is forbidden to execute 154(1) The callbacks are mutually exclusive (e.g. it is forbidden to execute
141 ->runtime_suspend() in parallel with ->runtime_resume() or with another 155 ->runtime_suspend() in parallel with ->runtime_resume() or with another