diff options
Diffstat (limited to 'Documentation/power/runtime_pm.txt')
| -rw-r--r-- | Documentation/power/runtime_pm.txt | 158 |
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 | ||
| 46 | The ->runtime_suspend(), ->runtime_resume() and ->runtime_idle() callbacks | 46 | The ->runtime_suspend(), ->runtime_resume() and ->runtime_idle() callbacks |
| 47 | are executed by the PM core for either the power domain, or the device type | 47 | are 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 | 48 | the following: |
| 49 | (if the device power domain's and type's struct dev_pm_ops object does not | 49 | |
| 50 | exist), 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, |
| 51 | struct dev_pm_ops objects do not exist) of the given device, so the priority | 51 | is present. |
| 52 | order of callbacks from high to low is that power domain callbacks, device | 52 | |
| 53 | type 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. |
| 54 | one will take precedence over low priority one. The bus type, device type and | 54 | |
| 55 | class 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 |
| 56 | and generally speaking, the power domain callbacks are used for representing | 56 | present. |
| 57 | power domains within a SoC. | 57 | |
| 58 | 4. Bus type of the device, if both dev->bus and dev->bus->pm are present. | ||
| 59 | |||
| 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 | |||
| 64 | The PM core always checks which callback to use in the order given above, so the | ||
| 65 | priority order of callbacks from high to low is: PM domain, device type, class | ||
| 66 | and bus type. Moreover, the high-priority one will always take precedence over | ||
| 67 | a low-priority one. The PM domain, bus type, device type and class callbacks | ||
| 68 | are referred to as subsystem-level callbacks in what follows. | ||
| 58 | 69 | ||
| 59 | By default, the callbacks are always invoked in process context with interrupts | 70 | By default, the callbacks are always invoked in process context with interrupts |
| 60 | enabled. However, subsystems can use the pm_runtime_irq_safe() helper function | 71 | enabled. However, the pm_runtime_irq_safe() helper function can be used to tell |
| 61 | to tell the PM core that a device's ->runtime_suspend() and ->runtime_resume() | 72 | the PM core that it is safe to run the ->runtime_suspend(), ->runtime_resume() |
| 62 | callbacks should be invoked in atomic context with interrupts disabled. | 73 | and ->runtime_idle() callbacks for the given device in atomic context with |
| 63 | This implies that these callback routines must not block or sleep, but it also | 74 | interrupts disabled. This implies that the callback routines in question must |
| 64 | means that the synchronous helper functions listed at the end of Section 4 can | 75 | not block or sleep, but it also means that the synchronous helper functions |
| 65 | be used within an interrupt handler or in an atomic context. | 76 | listed at the end of Section 4 may be used for that device within an interrupt |
| 66 | 77 | handler or generally in an atomic context. | |
| 67 | The subsystem-level suspend callback is _entirely_ _responsible_ for handling | 78 | |
| 68 | the suspend of the device as appropriate, which may, but need not include | 79 | The subsystem-level suspend callback, if present, is _entirely_ _responsible_ |
| 69 | executing the device driver's own ->runtime_suspend() callback (from the | 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 | ||
| 70 | PM core's point of view it is not necessary to implement a ->runtime_suspend() | 82 | PM core's point of view it is not necessary to implement a ->runtime_suspend() |
| 71 | callback in a device driver as long as the subsystem-level suspend callback | 83 | callback in a device driver as long as the subsystem-level suspend callback |
| 72 | knows what to do to handle the device). | 84 | knows 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). | |
| 92 | In particular, if the driver requires remote wake-up capability (i.e. hardware | 104 | |
| 105 | In particular, if the driver requires remote wakeup capability (i.e. hardware | ||
| 93 | mechanism allowing the device to request a change of its power state, such as | 106 | mechanism allowing the device to request a change of its power state, such as |
| 94 | PCI PME) for proper functioning and device_run_wake() returns 'false' for the | 107 | PCI PME) for proper functioning and device_run_wake() returns 'false' for the |
| 95 | device, then ->runtime_suspend() should return -EBUSY. On the other hand, if | 108 | device, then ->runtime_suspend() should return -EBUSY. On the other hand, if |
| 96 | device_run_wake() returns 'true' for the device and the device is put into a low | 109 | device_run_wake() returns 'true' for the device and the device is put into a |
| 97 | power state during the execution of the subsystem-level suspend callback, it is | 110 | low-power state during the execution of the suspend callback, it is expected |
| 98 | expected that remote wake-up will be enabled for the device. Generally, remote | 111 | that remote wakeup will be enabled for the device. Generally, remote wakeup |
| 99 | wake-up should be enabled for all input devices put into a low power state at | 112 | should be enabled for all input devices put into low-power states at run time. |
| 100 | run time. | 113 | |
| 101 | 114 | The subsystem-level resume callback, if present, is _entirely_ _responsible_ for | |
| 102 | The subsystem-level resume callback is _entirely_ _responsible_ for handling the | 115 | handling the resume of the device as appropriate, which may, but need not |
| 103 | resume of the device as appropriate, which may, but need not include executing | 116 | include executing the device driver's own ->runtime_resume() callback (from the |
| 104 | the device driver's own ->runtime_resume() callback (from the PM core's point of | 117 | PM core's point of view it is not necessary to implement a ->runtime_resume() |
| 105 | view it is not necessary to implement a ->runtime_resume() callback in a device | 118 | callback in a device driver as long as the subsystem-level resume callback knows |
| 106 | driver as long as the subsystem-level resume callback knows what to do to handle | 119 | what to do to handle the device). |
| 107 | the 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 | ||
| 120 | The subsystem-level idle callback is executed by the PM core whenever the device | 133 | The idle callback (a subsystem-level one, if present, or the driver one) is |
| 121 | appears to be idle, which is indicated to the PM core by two counters, the | 134 | executed by the PM core whenever the device appears to be idle, which is |
| 122 | device's usage counter and the counter of 'active' children of the device. | 135 | indicated to the PM core by two counters, the device's usage counter and the |
| 136 | counter 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 | ||
| 129 | The action performed by a subsystem-level idle callback is totally dependent on | 143 | The action performed by the idle callback is totally dependent on the subsystem |
| 130 | the 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 |
| 131 | if the device can be suspended (i.e. if all of the conditions necessary for | 145 | if the device can be suspended (i.e. if all of the conditions necessary for |
| 132 | suspending the device are satisfied) and to queue up a suspend request for the | 146 | suspending the device are satisfied) and to queue up a suspend request for the |
| 133 | device in that case. The value returned by this callback is ignored by the PM | 147 | device in that case. The value returned by this callback is ignored by the PM |
| 134 | core. | 148 | core. |
| 135 | 149 | ||
| 136 | The helper functions provided by the PM core, described in Section 4, guarantee | 150 | The helper functions provided by the PM core, described in Section 4, guarantee |
| 137 | that the following constraints are met with respect to the bus type's runtime | 151 | that the following constraints are met with respect to runtime PM callbacks for |
| 138 | PM callbacks: | 152 | one 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 |
