aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/power/runtime_pm.txt
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2011-12-17 18:34:13 -0500
committerRafael J. Wysocki <rjw@sisk.pl>2011-12-21 16:01:05 -0500
commit35cd133c6130c1eb52806808abee9d62e6854a27 (patch)
tree2f06e7f0288b9d4a3785a202f6480928113d8d5c /Documentation/power/runtime_pm.txt
parent9cf519d1c15fa05a538c2b3963c5f3903daf765a (diff)
PM: Run the driver callback directly if the subsystem one is not there
Make the PM core execute driver PM callbacks directly if the corresponding subsystem callbacks are not present. There are three reasons for doing that. First, it reflects the behavior of drivers/base/dd.c:really_probe() that runs the driver's .probe() callback directly if the bus type's one is not defined, so this change will remove one arbitrary difference between the PM core and the remaining parts of the driver core. Second, it will allow some subsystems, whose PM callbacks don't do anything except for executing driver callbacks, to be simplified quite a bit by removing those "forward-only" callbacks. Finally, it will allow us to remove one level of indirection in the system suspend and resume code paths where it is not necessary, which is going to lead to less debug noise with initcall_debug passed in the kernel command line (messages won't be printed for driverless devices whose subsystems don't provide PM callbacks among other things). Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'Documentation/power/runtime_pm.txt')
-rw-r--r--Documentation/power/runtime_pm.txt130
1 files changed, 68 insertions, 62 deletions
diff --git a/Documentation/power/runtime_pm.txt b/Documentation/power/runtime_pm.txt
index c2ae8bf77d46..4abe83e1045a 100644
--- a/Documentation/power/runtime_pm.txt
+++ b/Documentation/power/runtime_pm.txt
@@ -57,6 +57,10 @@ the following:
57 57
58 4. Bus type of the device, if both dev->bus and dev->bus->pm are present. 58 4. Bus type of the device, if both dev->bus and dev->bus->pm are present.
59 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
60The PM core always checks which callback to use in the order given above, so the 64The PM core always checks which callback to use in the order given above, so the
61priority order of callbacks from high to low is: PM domain, device type, class 65priority order of callbacks from high to low is: PM domain, device type, class
62and bus type. Moreover, the high-priority one will always take precedence over 66and bus type. Moreover, the high-priority one will always take precedence over
@@ -64,86 +68,88 @@ a low-priority one. The PM domain, bus type, device type and class callbacks
64are referred to as subsystem-level callbacks in what follows. 68are referred to as subsystem-level callbacks in what follows.
65 69
66By default, the callbacks are always invoked in process context with interrupts 70By default, the callbacks are always invoked in process context with interrupts
67enabled. 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
68to tell the PM core that their ->runtime_suspend(), ->runtime_resume() and 72the PM core that it is safe to run the ->runtime_suspend(), ->runtime_resume()
69->runtime_idle() callbacks may be invoked in atomic context with interrupts 73and ->runtime_idle() callbacks for the given device in atomic context with
70disabled for a given device. This implies that the callback routines in 74interrupts disabled. This implies that the callback routines in question must
71question must not block or sleep, but it also means that the synchronous helper 75not block or sleep, but it also means that the synchronous helper functions
72functions listed at the end of Section 4 may be used for that device within an 76listed at the end of Section 4 may be used for that device within an interrupt
73interrupt handler or generally in an atomic context. 77handler or generally in an atomic context.
74 78
75The subsystem-level suspend callback is _entirely_ _responsible_ for handling 79The subsystem-level suspend callback, if present, is _entirely_ _responsible_
76the suspend of the device as appropriate, which may, but need not include 80for handling the suspend of the device as appropriate, which may, but need not
77executing the device driver's own ->runtime_suspend() callback (from the 81include executing the device driver's own ->runtime_suspend() callback (from the
78PM 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()
79callback 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
80knows what to do to handle the device). 84knows what to do to handle the device).
81 85
82 * Once the subsystem-level suspend callback has completed successfully 86 * Once the subsystem-level suspend callback (or the driver suspend callback,
83 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
84 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
85 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
86 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
87 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
88 successful execution of the subsystem-level suspend callback is 'suspended'. 92 PM status of a device after successful execution of the suspend callback is
89 93 'suspended'.
90 * If the subsystem-level suspend callback returns -EBUSY or -EAGAIN, 94
91 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
92 _must_ be fully operational afterwards. 96 status remains 'active', which means that the device _must_ be fully
93 97 operational afterwards.
94 * If the subsystem-level suspend callback returns an error code different 98
95 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
96 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
97 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
98 (the PM core provides special helper functions for this purpose). 102 is directly set to either'active', or 'suspended' (the PM core provides
99 103 special helper functions for this purpose).
100In 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
101mechanism 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
102PCI 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
103device, then ->runtime_suspend() should return -EBUSY. On the other hand, if 108device, then ->runtime_suspend() should return -EBUSY. On the other hand, if
104device_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
105power 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
106expected that remote wake-up will be enabled for the device. Generally, remote 111that remote wakeup will be enabled for the device. Generally, remote wakeup
107wake-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.
108run time. 113
109 114The subsystem-level resume callback, if present, is _entirely_ _responsible_ for
110The subsystem-level resume callback is _entirely_ _responsible_ for handling the 115handling the resume of the device as appropriate, which may, but need not
111resume of the device as appropriate, which may, but need not include executing 116include executing the device driver's own ->runtime_resume() callback (from the
112the 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()
113view 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
114driver as long as the subsystem-level resume callback knows what to do to handle 119what to do to handle the device).
115the device). 120
116 121 * Once the subsystem-level resume callback (or the driver resume callback, if
117 * Once the subsystem-level resume callback has completed successfully, the PM 122 invoked directly) has completed successfully, the PM core regards the device
118 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
119 _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
120 of the device is then 'active'. 125 'active'.
121 126
122 * 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
123 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
124 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
125 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
126 functions for this purpose). 131 for this purpose).
127 132
128The 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
129appears 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
130device'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.
131 137
132 * 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
133 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
134 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
135 subsystem-level idle callback with the device as an argument. 141 idle callback with the device as its argument.
136 142
137The 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
138the 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
139if 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
140suspending 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
141device 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
142core. 148core.
143 149
144The 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
145that 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
146PM callbacks: 152one device:
147 153
148(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
149 ->runtime_suspend() in parallel with ->runtime_resume() or with another 155 ->runtime_suspend() in parallel with ->runtime_resume() or with another