Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'pm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

* 'pm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
PM: Update comments describing device power management callbacks
PM / Sleep: Update documentation related to system wakeup
PM / Runtime: Make documentation follow the new behavior of irq_safe
PM / Sleep: Correct inaccurate information in devices.txt
PM / Domains: Document how PM domains are used by the PM core
PM / Hibernate: Do not leak memory in error/test code paths

+227 -149
+66 -39
Documentation/power/devices.txt
··· 123 123 Subsystem-Level Methods 124 124 ----------------------- 125 125 The core methods to suspend and resume devices reside in struct dev_pm_ops 126 - pointed to by the pm member of struct bus_type, struct device_type and 127 - struct class. They are mostly of interest to the people writing infrastructure 128 - for buses, like PCI or USB, or device type and device class drivers. 126 + pointed to by the ops member of struct dev_pm_domain, or by the pm member of 127 + struct bus_type, struct device_type and struct class. They are mostly of 128 + interest to the people writing infrastructure for platforms and buses, like PCI 129 + or USB, or device type and device class drivers. 129 130 130 131 Bus drivers implement these methods as appropriate for the hardware and the 131 132 drivers using it; PCI works differently from USB, and so on. Not many people ··· 140 139 141 140 /sys/devices/.../power/wakeup files 142 141 ----------------------------------- 143 - All devices in the driver model have two flags to control handling of wakeup 144 - events (hardware signals that can force the device and/or system out of a low 145 - power state). These flags are initialized by bus or device driver code using 142 + All device objects in the driver model contain fields that control the handling 143 + of system wakeup events (hardware signals that can force the system out of a 144 + sleep state). These fields are initialized by bus or device driver code using 146 145 device_set_wakeup_capable() and device_set_wakeup_enable(), defined in 147 146 include/linux/pm_wakeup.h. 148 147 149 - The "can_wakeup" flag just records whether the device (and its driver) can 148 + The "power.can_wakeup" flag just records whether the device (and its driver) can 150 149 physically support wakeup events. The device_set_wakeup_capable() routine 151 - affects this flag. The "should_wakeup" flag controls whether the device should 152 - try to use its wakeup mechanism. device_set_wakeup_enable() affects this flag; 153 - for the most part drivers should not change its value. The initial value of 154 - should_wakeup is supposed to be false for the majority of devices; the major 155 - exceptions are power buttons, keyboards, and Ethernet adapters whose WoL 156 - (wake-on-LAN) feature has been set up with ethtool. It should also default 157 - to true for devices that don't generate wakeup requests on their own but merely 158 - forward wakeup requests from one bus to another (like PCI bridges). 150 + affects this flag. The "power.wakeup" field is a pointer to an object of type 151 + struct wakeup_source used for controlling whether or not the device should use 152 + its system wakeup mechanism and for notifying the PM core of system wakeup 153 + events signaled by the device. This object is only present for wakeup-capable 154 + devices (i.e. devices whose "can_wakeup" flags are set) and is created (or 155 + removed) by device_set_wakeup_capable(). 159 156 160 157 Whether or not a device is capable of issuing wakeup events is a hardware 161 158 matter, and the kernel is responsible for keeping track of it. By contrast, 162 159 whether or not a wakeup-capable device should issue wakeup events is a policy 163 160 decision, and it is managed by user space through a sysfs attribute: the 164 - power/wakeup file. User space can write the strings "enabled" or "disabled" to 165 - set or clear the "should_wakeup" flag, respectively. This file is only present 166 - for wakeup-capable devices (i.e. devices whose "can_wakeup" flags are set) 167 - and is created (or removed) by device_set_wakeup_capable(). Reads from the 168 - file will return the corresponding string. 161 + "power/wakeup" file. User space can write the strings "enabled" or "disabled" 162 + to it to indicate whether or not, respectively, the device is supposed to signal 163 + system wakeup. This file is only present if the "power.wakeup" object exists 164 + for the given device and is created (or removed) along with that object, by 165 + device_set_wakeup_capable(). Reads from the file will return the corresponding 166 + string. 169 167 170 - The device_may_wakeup() routine returns true only if both flags are set. 168 + The "power/wakeup" file is supposed to contain the "disabled" string initially 169 + for the majority of devices; the major exceptions are power buttons, keyboards, 170 + and Ethernet adapters whose WoL (wake-on-LAN) feature has been set up with 171 + ethtool. It should also default to "enabled" for devices that don't generate 172 + wakeup requests on their own but merely forward wakeup requests from one bus to 173 + another (like PCI Express ports). 174 + 175 + The device_may_wakeup() routine returns true only if the "power.wakeup" object 176 + exists and the corresponding "power/wakeup" file contains the string "enabled". 171 177 This information is used by subsystems, like the PCI bus type code, to see 172 178 whether or not to enable the devices' wakeup mechanisms. If device wakeup 173 179 mechanisms are enabled or disabled directly by drivers, they also should use 174 180 device_may_wakeup() to decide what to do during a system sleep transition. 175 - However for runtime power management, wakeup events should be enabled whenever 176 - the device and driver both support them, regardless of the should_wakeup flag. 181 + Device drivers, however, are not supposed to call device_set_wakeup_enable() 182 + directly in any case. 177 183 184 + It ought to be noted that system wakeup is conceptually different from "remote 185 + wakeup" used by runtime power management, although it may be supported by the 186 + same physical mechanism. Remote wakeup is a feature allowing devices in 187 + low-power states to trigger specific interrupts to signal conditions in which 188 + they should be put into the full-power state. Those interrupts may or may not 189 + be used to signal system wakeup events, depending on the hardware design. On 190 + some systems it is impossible to trigger them from system sleep states. In any 191 + case, remote wakeup should always be enabled for runtime power management for 192 + all devices and drivers that support it. 178 193 179 194 /sys/devices/.../power/control files 180 195 ------------------------------------ ··· 266 249 support all these callbacks and not all drivers use all the callbacks. The 267 250 various phases always run after tasks have been frozen and before they are 268 251 unfrozen. Furthermore, the *_noirq phases run at a time when IRQ handlers have 269 - been disabled (except for those marked with the IRQ_WAKEUP flag). 252 + been disabled (except for those marked with the IRQF_NO_SUSPEND flag). 270 253 271 - All phases use bus, type, or class callbacks (that is, methods defined in 272 - dev->bus->pm, dev->type->pm, or dev->class->pm). These callbacks are mutually 273 - exclusive, so if the device type provides a struct dev_pm_ops object pointed to 274 - by its pm field (i.e. both dev->type and dev->type->pm are defined), the 275 - callbacks included in that object (i.e. dev->type->pm) will be used. Otherwise, 276 - if the class provides a struct dev_pm_ops object pointed to by its pm field 277 - (i.e. both dev->class and dev->class->pm are defined), the PM core will use the 278 - callbacks from that object (i.e. dev->class->pm). Finally, if the pm fields of 279 - both the device type and class objects are NULL (or those objects do not exist), 280 - the callbacks provided by the bus (that is, the callbacks from dev->bus->pm) 281 - will be used (this allows device types to override callbacks provided by bus 282 - types or classes if necessary). 254 + All phases use PM domain, bus, type, or class callbacks (that is, methods 255 + defined in dev->pm_domain->ops, dev->bus->pm, dev->type->pm, or dev->class->pm). 256 + These callbacks are regarded by the PM core as mutually exclusive. Moreover, 257 + PM domain callbacks always take precedence over bus, type and class callbacks, 258 + while type callbacks take precedence over bus and class callbacks, and class 259 + callbacks take precedence over bus callbacks. To be precise, the following 260 + rules are used to determine which callback to execute in the given phase: 261 + 262 + 1. If dev->pm_domain is present, the PM core will attempt to execute the 263 + callback included in dev->pm_domain->ops. If that callback is not 264 + present, no action will be carried out for the given device. 265 + 266 + 2. Otherwise, if both dev->type and dev->type->pm are present, the callback 267 + included in dev->type->pm will be executed. 268 + 269 + 3. Otherwise, if both dev->class and dev->class->pm are present, the 270 + callback included in dev->class->pm will be executed. 271 + 272 + 4. Otherwise, if both dev->bus and dev->bus->pm are present, the callback 273 + included in dev->bus->pm will be executed. 274 + 275 + This allows PM domains and device types to override callbacks provided by bus 276 + types or device classes if necessary. 283 277 284 278 These callbacks may in turn invoke device- or driver-specific methods stored in 285 279 dev->driver->pm, but they don't have to. ··· 311 283 312 284 After the prepare callback method returns, no new children may be 313 285 registered below the device. The method may also prepare the device or 314 - driver in some way for the upcoming system power transition (for 315 - example, by allocating additional memory required for this purpose), but 316 - it should not put the device into a low-power state. 286 + driver in some way for the upcoming system power transition, but it 287 + should not put the device into a low-power state. 317 288 318 289 2. The suspend methods should quiesce the device to stop it from performing 319 290 I/O. They also may save the device registers and put it into the
+24 -16
Documentation/power/runtime_pm.txt
··· 44 44 }; 45 45 46 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 48 - (if the device power domain's struct dev_pm_ops does not exist), or the class 49 - (if the device power domain's and type's struct dev_pm_ops object does not 50 - exist), or the bus type (if the device power domain's, type's and class' 51 - struct dev_pm_ops objects do not exist) of the given device, so the priority 52 - order of callbacks from high to low is that power domain callbacks, device 53 - type callbacks, class callbacks and bus type callbacks, and the high priority 54 - one will take precedence over low priority one. The bus type, device type and 55 - class callbacks are referred to as subsystem-level callbacks in what follows, 56 - and generally speaking, the power domain callbacks are used for representing 57 - power domains within a SoC. 47 + are executed by the PM core for the device's subsystem that may be either of 48 + the following: 49 + 50 + 1. PM domain of the device, if the device's PM domain object, dev->pm_domain, 51 + is present. 52 + 53 + 2. Device type of the device, if both dev->type and dev->type->pm are present. 54 + 55 + 3. Device class of the device, if both dev->class and dev->class->pm are 56 + present. 57 + 58 + 4. Bus type of the device, if both dev->bus and dev->bus->pm are present. 59 + 60 + The PM core always checks which callback to use in the order given above, so the 61 + priority order of callbacks from high to low is: PM domain, device type, class 62 + and bus type. Moreover, the high-priority one will always take precedence over 63 + a low-priority one. The PM domain, bus type, device type and class callbacks 64 + are referred to as subsystem-level callbacks in what follows. 58 65 59 66 By default, the callbacks are always invoked in process context with interrupts 60 67 enabled. However, subsystems can use the pm_runtime_irq_safe() helper function 61 - to tell the PM core that a device's ->runtime_suspend() and ->runtime_resume() 62 - callbacks should be invoked in atomic context with interrupts disabled. 63 - This implies that these callback routines must not block or sleep, but it also 64 - means that the synchronous helper functions listed at the end of Section 4 can 65 - be used within an interrupt handler or in an atomic context. 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. 66 74 67 75 The subsystem-level suspend callback is _entirely_ _responsible_ for handling 68 76 the suspend of the device as appropriate, which may, but need not include
+127 -88
include/linux/pm.h
··· 54 54 /** 55 55 * struct dev_pm_ops - device PM callbacks 56 56 * 57 - * Several driver power state transitions are externally visible, affecting 57 + * Several device power state transitions are externally visible, affecting 58 58 * the state of pending I/O queues and (for drivers that touch hardware) 59 59 * interrupts, wakeups, DMA, and other hardware state. There may also be 60 - * internal transitions to various low power modes, which are transparent 60 + * internal transitions to various low-power modes which are transparent 61 61 * to the rest of the driver stack (such as a driver that's ON gating off 62 62 * clocks which are not in active use). 63 63 * 64 - * The externally visible transitions are handled with the help of the following 65 - * callbacks included in this structure: 64 + * The externally visible transitions are handled with the help of callbacks 65 + * included in this structure in such a way that two levels of callbacks are 66 + * involved. First, the PM core executes callbacks provided by PM domains, 67 + * device types, classes and bus types. They are the subsystem-level callbacks 68 + * supposed to execute callbacks provided by device drivers, although they may 69 + * choose not to do that. If the driver callbacks are executed, they have to 70 + * collaborate with the subsystem-level callbacks to achieve the goals 71 + * appropriate for the given system transition, given transition phase and the 72 + * subsystem the device belongs to. 66 73 * 67 - * @prepare: Prepare the device for the upcoming transition, but do NOT change 68 - * its hardware state. Prevent new children of the device from being 69 - * registered after @prepare() returns (the driver's subsystem and 70 - * generally the rest of the kernel is supposed to prevent new calls to the 71 - * probe method from being made too once @prepare() has succeeded). If 72 - * @prepare() detects a situation it cannot handle (e.g. registration of a 73 - * child already in progress), it may return -EAGAIN, so that the PM core 74 - * can execute it once again (e.g. after the new child has been registered) 75 - * to recover from the race condition. This method is executed for all 76 - * kinds of suspend transitions and is followed by one of the suspend 77 - * callbacks: @suspend(), @freeze(), or @poweroff(). 78 - * The PM core executes @prepare() for all devices before starting to 79 - * execute suspend callbacks for any of them, so drivers may assume all of 80 - * the other devices to be present and functional while @prepare() is being 81 - * executed. In particular, it is safe to make GFP_KERNEL memory 82 - * allocations from within @prepare(). However, drivers may NOT assume 83 - * anything about the availability of the user space at that time and it 84 - * is not correct to request firmware from within @prepare() (it's too 85 - * late to do that). [To work around this limitation, drivers may 86 - * register suspend and hibernation notifiers that are executed before the 87 - * freezing of tasks.] 74 + * @prepare: The principal role of this callback is to prevent new children of 75 + * the device from being registered after it has returned (the driver's 76 + * subsystem and generally the rest of the kernel is supposed to prevent 77 + * new calls to the probe method from being made too once @prepare() has 78 + * succeeded). If @prepare() detects a situation it cannot handle (e.g. 79 + * registration of a child already in progress), it may return -EAGAIN, so 80 + * that the PM core can execute it once again (e.g. after a new child has 81 + * been registered) to recover from the race condition. 82 + * This method is executed for all kinds of suspend transitions and is 83 + * followed by one of the suspend callbacks: @suspend(), @freeze(), or 84 + * @poweroff(). The PM core executes subsystem-level @prepare() for all 85 + * devices before starting to invoke suspend callbacks for any of them, so 86 + * generally devices may be assumed to be functional or to respond to 87 + * runtime resume requests while @prepare() is being executed. However, 88 + * device drivers may NOT assume anything about the availability of user 89 + * space at that time and it is NOT valid to request firmware from within 90 + * @prepare() (it's too late to do that). It also is NOT valid to allocate 91 + * substantial amounts of memory from @prepare() in the GFP_KERNEL mode. 92 + * [To work around these limitations, drivers may register suspend and 93 + * hibernation notifiers to be executed before the freezing of tasks.] 88 94 * 89 95 * @complete: Undo the changes made by @prepare(). This method is executed for 90 96 * all kinds of resume transitions, following one of the resume callbacks: 91 97 * @resume(), @thaw(), @restore(). Also called if the state transition 92 - * fails before the driver's suspend callback (@suspend(), @freeze(), 93 - * @poweroff()) can be executed (e.g. if the suspend callback fails for one 98 + * fails before the driver's suspend callback: @suspend(), @freeze() or 99 + * @poweroff(), can be executed (e.g. if the suspend callback fails for one 94 100 * of the other devices that the PM core has unsuccessfully attempted to 95 101 * suspend earlier). 96 - * The PM core executes @complete() after it has executed the appropriate 97 - * resume callback for all devices. 102 + * The PM core executes subsystem-level @complete() after it has executed 103 + * the appropriate resume callbacks for all devices. 98 104 * 99 105 * @suspend: Executed before putting the system into a sleep state in which the 100 - * contents of main memory are preserved. Quiesce the device, put it into 101 - * a low power state appropriate for the upcoming system state (such as 102 - * PCI_D3hot), and enable wakeup events as appropriate. 106 + * contents of main memory are preserved. The exact action to perform 107 + * depends on the device's subsystem (PM domain, device type, class or bus 108 + * type), but generally the device must be quiescent after subsystem-level 109 + * @suspend() has returned, so that it doesn't do any I/O or DMA. 110 + * Subsystem-level @suspend() is executed for all devices after invoking 111 + * subsystem-level @prepare() for all of them. 103 112 * 104 113 * @resume: Executed after waking the system up from a sleep state in which the 105 - * contents of main memory were preserved. Put the device into the 106 - * appropriate state, according to the information saved in memory by the 107 - * preceding @suspend(). The driver starts working again, responding to 108 - * hardware events and software requests. The hardware may have gone 109 - * through a power-off reset, or it may have maintained state from the 110 - * previous suspend() which the driver may rely on while resuming. On most 111 - * platforms, there are no restrictions on availability of resources like 112 - * clocks during @resume(). 114 + * contents of main memory were preserved. The exact action to perform 115 + * depends on the device's subsystem, but generally the driver is expected 116 + * to start working again, responding to hardware events and software 117 + * requests (the device itself may be left in a low-power state, waiting 118 + * for a runtime resume to occur). The state of the device at the time its 119 + * driver's @resume() callback is run depends on the platform and subsystem 120 + * the device belongs to. On most platforms, there are no restrictions on 121 + * availability of resources like clocks during @resume(). 122 + * Subsystem-level @resume() is executed for all devices after invoking 123 + * subsystem-level @resume_noirq() for all of them. 113 124 * 114 125 * @freeze: Hibernation-specific, executed before creating a hibernation image. 115 - * Quiesce operations so that a consistent image can be created, but do NOT 116 - * otherwise put the device into a low power device state and do NOT emit 117 - * system wakeup events. Save in main memory the device settings to be 118 - * used by @restore() during the subsequent resume from hibernation or by 119 - * the subsequent @thaw(), if the creation of the image or the restoration 120 - * of main memory contents from it fails. 126 + * Analogous to @suspend(), but it should not enable the device to signal 127 + * wakeup events or change its power state. The majority of subsystems 128 + * (with the notable exception of the PCI bus type) expect the driver-level 129 + * @freeze() to save the device settings in memory to be used by @restore() 130 + * during the subsequent resume from hibernation. 131 + * Subsystem-level @freeze() is executed for all devices after invoking 132 + * subsystem-level @prepare() for all of them. 121 133 * 122 134 * @thaw: Hibernation-specific, executed after creating a hibernation image OR 123 - * if the creation of the image fails. Also executed after a failing 135 + * if the creation of an image has failed. Also executed after a failing 124 136 * attempt to restore the contents of main memory from such an image. 125 137 * Undo the changes made by the preceding @freeze(), so the device can be 126 138 * operated in the same way as immediately before the call to @freeze(). 139 + * Subsystem-level @thaw() is executed for all devices after invoking 140 + * subsystem-level @thaw_noirq() for all of them. It also may be executed 141 + * directly after @freeze() in case of a transition error. 127 142 * 128 143 * @poweroff: Hibernation-specific, executed after saving a hibernation image. 129 - * Quiesce the device, put it into a low power state appropriate for the 130 - * upcoming system state (such as PCI_D3hot), and enable wakeup events as 131 - * appropriate. 144 + * Analogous to @suspend(), but it need not save the device's settings in 145 + * memory. 146 + * Subsystem-level @poweroff() is executed for all devices after invoking 147 + * subsystem-level @prepare() for all of them. 132 148 * 133 149 * @restore: Hibernation-specific, executed after restoring the contents of main 134 - * memory from a hibernation image. Driver starts working again, 135 - * responding to hardware events and software requests. Drivers may NOT 136 - * make ANY assumptions about the hardware state right prior to @restore(). 137 - * On most platforms, there are no restrictions on availability of 138 - * resources like clocks during @restore(). 150 + * memory from a hibernation image, analogous to @resume(). 139 151 * 140 - * @suspend_noirq: Complete the operations of ->suspend() by carrying out any 141 - * actions required for suspending the device that need interrupts to be 142 - * disabled 152 + * @suspend_noirq: Complete the actions started by @suspend(). Carry out any 153 + * additional operations required for suspending the device that might be 154 + * racing with its driver's interrupt handler, which is guaranteed not to 155 + * run while @suspend_noirq() is being executed. 156 + * It generally is expected that the device will be in a low-power state 157 + * (appropriate for the target system sleep state) after subsystem-level 158 + * @suspend_noirq() has returned successfully. If the device can generate 159 + * system wakeup signals and is enabled to wake up the system, it should be 160 + * configured to do so at that time. However, depending on the platform 161 + * and device's subsystem, @suspend() may be allowed to put the device into 162 + * the low-power state and configure it to generate wakeup signals, in 163 + * which case it generally is not necessary to define @suspend_noirq(). 143 164 * 144 - * @resume_noirq: Prepare for the execution of ->resume() by carrying out any 145 - * actions required for resuming the device that need interrupts to be 146 - * disabled 165 + * @resume_noirq: Prepare for the execution of @resume() by carrying out any 166 + * operations required for resuming the device that might be racing with 167 + * its driver's interrupt handler, which is guaranteed not to run while 168 + * @resume_noirq() is being executed. 147 169 * 148 - * @freeze_noirq: Complete the operations of ->freeze() by carrying out any 149 - * actions required for freezing the device that need interrupts to be 150 - * disabled 170 + * @freeze_noirq: Complete the actions started by @freeze(). Carry out any 171 + * additional operations required for freezing the device that might be 172 + * racing with its driver's interrupt handler, which is guaranteed not to 173 + * run while @freeze_noirq() is being executed. 174 + * The power state of the device should not be changed by either @freeze() 175 + * or @freeze_noirq() and it should not be configured to signal system 176 + * wakeup by any of these callbacks. 151 177 * 152 - * @thaw_noirq: Prepare for the execution of ->thaw() by carrying out any 153 - * actions required for thawing the device that need interrupts to be 154 - * disabled 178 + * @thaw_noirq: Prepare for the execution of @thaw() by carrying out any 179 + * operations required for thawing the device that might be racing with its 180 + * driver's interrupt handler, which is guaranteed not to run while 181 + * @thaw_noirq() is being executed. 155 182 * 156 - * @poweroff_noirq: Complete the operations of ->poweroff() by carrying out any 157 - * actions required for handling the device that need interrupts to be 158 - * disabled 183 + * @poweroff_noirq: Complete the actions started by @poweroff(). Analogous to 184 + * @suspend_noirq(), but it need not save the device's settings in memory. 159 185 * 160 - * @restore_noirq: Prepare for the execution of ->restore() by carrying out any 161 - * actions required for restoring the operations of the device that need 162 - * interrupts to be disabled 186 + * @restore_noirq: Prepare for the execution of @restore() by carrying out any 187 + * operations required for thawing the device that might be racing with its 188 + * driver's interrupt handler, which is guaranteed not to run while 189 + * @restore_noirq() is being executed. Analogous to @resume_noirq(). 163 190 * 164 191 * All of the above callbacks, except for @complete(), return error codes. 165 192 * However, the error codes returned by the resume operations, @resume(), 166 - * @thaw(), @restore(), @resume_noirq(), @thaw_noirq(), and @restore_noirq() do 193 + * @thaw(), @restore(), @resume_noirq(), @thaw_noirq(), and @restore_noirq(), do 167 194 * not cause the PM core to abort the resume transition during which they are 168 - * returned. The error codes returned in that cases are only printed by the PM 195 + * returned. The error codes returned in those cases are only printed by the PM 169 196 * core to the system logs for debugging purposes. Still, it is recommended 170 197 * that drivers only return error codes from their resume methods in case of an 171 198 * unrecoverable failure (i.e. when the device being handled refuses to resume ··· 201 174 * their children. 202 175 * 203 176 * It is allowed to unregister devices while the above callbacks are being 204 - * executed. However, it is not allowed to unregister a device from within any 205 - * of its own callbacks. 177 + * executed. However, a callback routine must NOT try to unregister the device 178 + * it was called for, although it may unregister children of that device (for 179 + * example, if it detects that a child was unplugged while the system was 180 + * asleep). 206 181 * 207 - * There also are the following callbacks related to run-time power management 208 - * of devices: 182 + * Refer to Documentation/power/devices.txt for more information about the role 183 + * of the above callbacks in the system suspend process. 184 + * 185 + * There also are callbacks related to runtime power management of devices. 186 + * Again, these callbacks are executed by the PM core only for subsystems 187 + * (PM domains, device types, classes and bus types) and the subsystem-level 188 + * callbacks are supposed to invoke the driver callbacks. Moreover, the exact 189 + * actions to be performed by a device driver's callbacks generally depend on 190 + * the platform and subsystem the device belongs to. 209 191 * 210 192 * @runtime_suspend: Prepare the device for a condition in which it won't be 211 193 * able to communicate with the CPU(s) and RAM due to power management. 212 - * This need not mean that the device should be put into a low power state. 194 + * This need not mean that the device should be put into a low-power state. 213 195 * For example, if the device is behind a link which is about to be turned 214 196 * off, the device may remain at full power. If the device does go to low 215 - * power and is capable of generating run-time wake-up events, remote 216 - * wake-up (i.e., a hardware mechanism allowing the device to request a 217 - * change of its power state via a wake-up event, such as PCI PME) should 218 - * be enabled for it. 197 + * power and is capable of generating runtime wakeup events, remote wakeup 198 + * (i.e., a hardware mechanism allowing the device to request a change of 199 + * its power state via an interrupt) should be enabled for it. 219 200 * 220 201 * @runtime_resume: Put the device into the fully active state in response to a 221 - * wake-up event generated by hardware or at the request of software. If 222 - * necessary, put the device into the full power state and restore its 202 + * wakeup event generated by hardware or at the request of software. If 203 + * necessary, put the device into the full-power state and restore its 223 204 * registers, so that it is fully operational. 224 205 * 225 - * @runtime_idle: Device appears to be inactive and it might be put into a low 226 - * power state if all of the necessary conditions are satisfied. Check 206 + * @runtime_idle: Device appears to be inactive and it might be put into a 207 + * low-power state if all of the necessary conditions are satisfied. Check 227 208 * these conditions and handle the device as appropriate, possibly queueing 228 209 * a suspend request for it. The return value is ignored by the PM core. 210 + * 211 + * Refer to Documentation/power/runtime_pm.txt for more information about the 212 + * role of the above callbacks in device runtime power management. 213 + * 229 214 */ 230 215 231 216 struct dev_pm_ops {
+10 -6
kernel/power/hibernate.c
··· 347 347 348 348 error = freeze_kernel_threads(); 349 349 if (error) 350 - goto Close; 350 + goto Cleanup; 351 351 352 352 if (hibernation_test(TEST_FREEZER) || 353 353 hibernation_testmode(HIBERNATION_TESTPROC)) { ··· 357 357 * successful freezer test. 358 358 */ 359 359 freezer_test_done = true; 360 - goto Close; 360 + goto Cleanup; 361 361 } 362 362 363 363 error = dpm_prepare(PMSG_FREEZE); 364 - if (error) 365 - goto Complete_devices; 364 + if (error) { 365 + dpm_complete(msg); 366 + goto Cleanup; 367 + } 366 368 367 369 suspend_console(); 368 370 pm_restrict_gfp_mask(); ··· 393 391 pm_restore_gfp_mask(); 394 392 395 393 resume_console(); 396 - 397 - Complete_devices: 398 394 dpm_complete(msg); 399 395 400 396 Close: ··· 402 402 Recover_platform: 403 403 platform_recover(platform_mode); 404 404 goto Resume_devices; 405 + 406 + Cleanup: 407 + swsusp_free(); 408 + goto Close; 405 409 } 406 410 407 411 /**