@@ -57,93 +57,99 @@ the following:
5757
5858 4. Bus type of the device, if both dev->bus and dev->bus->pm are present.
5959
60+ If the subsystem chosen by applying the above rules doesn't provide the relevant
61+ callback, the PM core will invoke the corresponding driver callback stored in
62+ dev->driver->pm directly (if present).
63+
6064The PM core always checks which callback to use in the order given above, so the
6165priority order of callbacks from high to low is: PM domain, device type, class
6266and bus type. Moreover, the high-priority one will always take precedence over
6367a low-priority one. The PM domain, bus type, device type and class callbacks
6468are referred to as subsystem-level callbacks in what follows.
6569
6670By default, the callbacks are always invoked in process context with interrupts
67- enabled. However, subsystems can use the pm_runtime_irq_safe() helper function
68- to tell the PM core that their ->runtime_suspend(), ->runtime_resume() and
69- ->runtime_idle() callbacks may be invoked in atomic context with interrupts
70- disabled for a given device . This implies that the callback routines in
71- question must not block or sleep, but it also means that the synchronous helper
72- functions listed at the end of Section 4 may be used for that device within an
73- interrupt handler or generally in an atomic context.
74-
75- The subsystem-level suspend callback is _entirely_ _responsible_ for handling
76- the suspend of the device as appropriate, which may, but need not include
77- executing the device driver's own ->runtime_suspend() callback (from the
71+ enabled. However, the pm_runtime_irq_safe() helper function can be used to tell
72+ the PM core that it is safe to run the ->runtime_suspend(), ->runtime_resume()
73+ and ->runtime_idle() callbacks for the given device in atomic context with
74+ interrupts disabled . This implies that the callback routines in question must
75+ not block or sleep, but it also means that the synchronous helper functions
76+ listed at the end of Section 4 may be used for that device within an interrupt
77+ handler or generally in an atomic context.
78+
79+ The subsystem-level suspend callback, if present, is _entirely_ _responsible_
80+ for handling the suspend of the device as appropriate, which may, but need not
81+ include executing the device driver's own ->runtime_suspend() callback (from the
7882PM core's point of view it is not necessary to implement a ->runtime_suspend()
7983callback in a device driver as long as the subsystem-level suspend callback
8084knows what to do to handle the device).
8185
82- * Once the subsystem-level suspend callback has completed successfully
83- for given device, the PM core regards the device as suspended, which need
84- not mean that the device has been put into a low power state. It is
85- supposed to mean, however, that the device will not process data and will
86- not communicate with the CPU(s) and RAM until the subsystem-level resume
87- callback is executed for it. The runtime PM status of a device after
88- successful execution of the subsystem-level suspend callback is 'suspended'.
89-
90- * If the subsystem-level suspend callback returns -EBUSY or -EAGAIN,
91- the device's runtime PM status is 'active', which means that the device
92- _must_ be fully operational afterwards.
93-
94- * If the subsystem-level suspend callback returns an error code different
95- from -EBUSY or -EAGAIN, the PM core regards this as a fatal error and will
96- refuse to run the helper functions described in Section 4 for the device,
97- until the status of it is directly set either to 'active', or to 'suspended'
98- (the PM core provides special helper functions for this purpose).
99-
100- In particular, if the driver requires remote wake-up capability (i.e. hardware
86+ * Once the subsystem-level suspend callback (or the driver suspend callback,
87+ if invoked directly) has completed successfully for the given device, the PM
88+ core regards the device as suspended, which need not mean that it has been
89+ put into a low power state. It is supposed to mean, however, that the
90+ device will not process data and will not communicate with the CPU(s) and
91+ RAM until the appropriate resume callback is executed for it. The runtime
92+ PM status of a device after successful execution of the suspend callback is
93+ 'suspended'.
94+
95+ * If the suspend callback returns -EBUSY or -EAGAIN, the device's runtime PM
96+ status remains 'active', which means that the device _must_ be fully
97+ operational afterwards.
98+
99+ * If the suspend callback returns an error code different from -EBUSY and
100+ -EAGAIN, the PM core regards this as a fatal error and will refuse to run
101+ the helper functions described in Section 4 for the device until its status
102+ is directly set to either'active', or 'suspended' (the PM core provides
103+ special helper functions for this purpose).
104+
105+ In particular, if the driver requires remote wakeup capability (i.e. hardware
101106mechanism allowing the device to request a change of its power state, such as
102107PCI PME) for proper functioning and device_run_wake() returns 'false' for the
103108device, then ->runtime_suspend() should return -EBUSY. On the other hand, if
104- device_run_wake() returns 'true' for the device and the device is put into a low
105- power state during the execution of the subsystem-level suspend callback, it is
106- expected that remote wake-up will be enabled for the device. Generally, remote
107- wake-up should be enabled for all input devices put into a low power state at
108- run time.
109-
110- The subsystem-level resume callback is _entirely_ _responsible_ for handling the
111- resume of the device as appropriate, which may, but need not include executing
112- the device driver's own ->runtime_resume() callback (from the PM core's point of
113- view it is not necessary to implement a ->runtime_resume() callback in a device
114- driver as long as the subsystem-level resume callback knows what to do to handle
115- the device).
116-
117- * Once the subsystem-level resume callback has completed successfully, the PM
118- core regards the device as fully operational, which means that the device
119- _must_ be able to complete I/O operations as needed. The runtime PM status
120- of the device is then 'active'.
121-
122- * If the subsystem-level resume callback returns an error code, the PM core
123- regards this as a fatal error and will refuse to run the helper functions
124- described in Section 4 for the device, until its status is directly set
125- either to 'active' or to 'suspended' (the PM core provides special helper
126- functions for this purpose).
127-
128- The subsystem-level idle callback is executed by the PM core whenever the device
129- appears to be idle, which is indicated to the PM core by two counters, the
130- device's usage counter and the counter of 'active' children of the device.
109+ device_run_wake() returns 'true' for the device and the device is put into a
110+ low-power state during the execution of the suspend callback, it is expected
111+ that remote wakeup will be enabled for the device. Generally, remote wakeup
112+ should be enabled for all input devices put into low-power states at run time.
113+
114+ The subsystem-level resume callback, if present, is _entirely_ _responsible_ for
115+ handling the resume of the device as appropriate, which may, but need not
116+ include executing the device driver's own ->runtime_resume() callback (from the
117+ PM core's point of view it is not necessary to implement a ->runtime_resume()
118+ callback in a device driver as long as the subsystem-level resume callback knows
119+ what to do to handle the device).
120+
121+ * Once the subsystem-level resume callback (or the driver resume callback, if
122+ invoked directly) has completed successfully, the PM core regards the device
123+ as fully operational, which means that the device _must_ be able to complete
124+ I/O operations as needed. The runtime PM status of the device is then
125+ 'active'.
126+
127+ * If the resume callback returns an error code, the PM core regards this as a
128+ fatal error and will refuse to run the helper functions described in Section
129+ 4 for the device, until its status is directly set to either 'active', or
130+ 'suspended' (by means of special helper functions provided by the PM core
131+ for this purpose).
132+
133+ The idle callback (a subsystem-level one, if present, or the driver one) is
134+ executed by the PM core whenever the device appears to be idle, which is
135+ indicated to the PM core by two counters, the device's usage counter and the
136+ counter of 'active' children of the device.
131137
132138 * If any of these counters is decreased using a helper function provided by
133139 the PM core and it turns out to be equal to zero, the other counter is
134140 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.
136142
137- The action performed by a subsystem-level idle callback is totally dependent on
138- the subsystem in question, but the expected and recommended action is to check
143+ The action performed by the idle callback is totally dependent on the subsystem
144+ (or driver) in question, but the expected and recommended action is to check
139145if the device can be suspended (i.e. if all of the conditions necessary for
140146suspending the device are satisfied) and to queue up a suspend request for the
141147device in that case. The value returned by this callback is ignored by the PM
142148core.
143149
144150The helper functions provided by the PM core, described in Section 4, guarantee
145- that the following constraints are met with respect to the bus type's runtime
146- PM callbacks :
151+ that the following constraints are met with respect to runtime PM callbacks for
152+ one device :
147153
148154(1) The callbacks are mutually exclusive (e.g. it is forbidden to execute
149155 ->runtime_suspend() in parallel with ->runtime_resume() or with another
0 commit comments