Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Fields
dev_pm_ops Struct Reference

#include <pm.h>

Data Fields

int(* prepare )(struct device *dev)
 
void(* complete )(struct device *dev)
 
int(* suspend )(struct device *dev)
 
int(* resume )(struct device *dev)
 
int(* freeze )(struct device *dev)
 
int(* thaw )(struct device *dev)
 
int(* poweroff )(struct device *dev)
 
int(* restore )(struct device *dev)
 
int(* suspend_late )(struct device *dev)
 
int(* resume_early )(struct device *dev)
 
int(* freeze_late )(struct device *dev)
 
int(* thaw_early )(struct device *dev)
 
int(* poweroff_late )(struct device *dev)
 
int(* restore_early )(struct device *dev)
 
int(* suspend_noirq )(struct device *dev)
 
int(* resume_noirq )(struct device *dev)
 
int(* freeze_noirq )(struct device *dev)
 
int(* thaw_noirq )(struct device *dev)
 
int(* poweroff_noirq )(struct device *dev)
 
int(* restore_noirq )(struct device *dev)
 
int(* runtime_suspend )(struct device *dev)
 
int(* runtime_resume )(struct device *dev)
 
int(* runtime_idle )(struct device *dev)
 

Detailed Description

struct dev_pm_ops - device PM callbacks

Several device power state transitions are externally visible, affecting the state of pending I/O queues and (for drivers that touch hardware) interrupts, wakeups, DMA, and other hardware state. There may also be internal transitions to various low-power modes which are transparent to the rest of the driver stack (such as a driver that's ON gating off clocks which are not in active use).

The externally visible transitions are handled with the help of callbacks included in this structure in such a way that two levels of callbacks are involved. First, the PM core executes callbacks provided by PM domains, device types, classes and bus types. They are the subsystem-level callbacks supposed to execute callbacks provided by device drivers, although they may choose not to do that. If the driver callbacks are executed, they have to collaborate with the subsystem-level callbacks to achieve the goals appropriate for the given system transition, given transition phase and the subsystem the device belongs to.

: The principal role of this callback is to prevent new children of the device from being registered after it has returned (the driver's subsystem and generally the rest of the kernel is supposed to prevent new calls to the probe method from being made too once () has succeeded). If () detects a situation it cannot handle (e.g. registration of a child already in progress), it may return -EAGAIN, so that the PM core can execute it once again (e.g. after a new child has been registered) to recover from the race condition. This method is executed for all kinds of suspend transitions and is followed by one of the suspend callbacks: (), (), or (). The PM core executes subsystem-level () for all devices before starting to invoke suspend callbacks for any of them, so generally devices may be assumed to be functional or to respond to runtime resume requests while () is being executed. However, device drivers may NOT assume anything about the availability of user space at that time and it is NOT valid to request firmware from within () (it's too late to do that). It also is NOT valid to allocate substantial amounts of memory from () in the GFP_KERNEL mode. [To work around these limitations, drivers may register suspend and hibernation notifiers to be executed before the freezing of tasks.]

: Undo the changes made by (). This method is executed for all kinds of resume transitions, following one of the resume callbacks: (), (), (). Also called if the state transition fails before the driver's suspend callback: (), () or (), can be executed (e.g. if the suspend callback fails for one of the other devices that the PM core has unsuccessfully attempted to suspend earlier). The PM core executes subsystem-level () after it has executed the appropriate resume callbacks for all devices.

: Executed before putting the system into a sleep state in which the contents of main memory are preserved. The exact action to perform depends on the device's subsystem (PM domain, device type, class or bus type), but generally the device must be quiescent after subsystem-level () has returned, so that it doesn't do any I/O or DMA. Subsystem-level () is executed for all devices after invoking subsystem-level () for all of them.

: Continue operations started by (). For a number of devices () may point to the same callback routine as the runtime suspend callback.

: Executed after waking the system up from a sleep state in which the contents of main memory were preserved. The exact action to perform depends on the device's subsystem, but generally the driver is expected to start working again, responding to hardware events and software requests (the device itself may be left in a low-power state, waiting for a runtime resume to occur). The state of the device at the time its driver's () callback is run depends on the platform and subsystem the device belongs to. On most platforms, there are no restrictions on availability of resources like clocks during (). Subsystem-level () is executed for all devices after invoking subsystem-level () for all of them.

: Prepare to execute (). For a number of devices () may point to the same callback routine as the runtime resume callback.

: Hibernation-specific, executed before creating a hibernation image. Analogous to (), but it should not enable the device to signal wakeup events or change its power state. The majority of subsystems (with the notable exception of the PCI bus type) expect the driver-level () to save the device settings in memory to be used by () during the subsequent resume from hibernation. Subsystem-level () is executed for all devices after invoking subsystem-level () for all of them.

: Continue operations started by (). Analogous to (), but it should not enable the device to signal wakeup events or change its power state.

: Hibernation-specific, executed after creating a hibernation image OR if the creation of an image has failed. Also executed after a failing attempt to restore the contents of main memory from such an image. Undo the changes made by the preceding (), so the device can be operated in the same way as immediately before the call to (). Subsystem-level () is executed for all devices after invoking subsystem-level () for all of them. It also may be executed directly after () in case of a transition error.

: Prepare to execute (). Undo the changes made by the preceding ().

: Hibernation-specific, executed after saving a hibernation image. Analogous to (), but it need not save the device's settings in memory. Subsystem-level () is executed for all devices after invoking subsystem-level () for all of them.

: Continue operations started by (). Analogous to (), but it need not save the device's settings in memory.

: Hibernation-specific, executed after restoring the contents of main memory from a hibernation image, analogous to ().

: Prepare to execute (), analogous to ().

: Complete the actions started by (). Carry out any additional operations required for suspending the device that might be racing with its driver's interrupt handler, which is guaranteed not to run while () is being executed. It generally is expected that the device will be in a low-power state (appropriate for the target system sleep state) after subsystem-level () has returned successfully. If the device can generate system wakeup signals and is enabled to wake up the system, it should be configured to do so at that time. However, depending on the platform and device's subsystem, () or () may be allowed to put the device into the low-power state and configure it to generate wakeup signals, in which case it generally is not necessary to define ().

: Prepare for the execution of () by carrying out any operations required for resuming the device that might be racing with its driver's interrupt handler, which is guaranteed not to run while () is being executed.

: Complete the actions started by (). Carry out any additional operations required for freezing the device that might be racing with its driver's interrupt handler, which is guaranteed not to run while () is being executed. The power state of the device should not be changed by either (), or (), or () and it should not be configured to signal system wakeup by any of these callbacks.

: Prepare for the execution of () by carrying out any operations required for thawing the device that might be racing with its driver's interrupt handler, which is guaranteed not to run while () is being executed.

: Complete the actions started by (). Analogous to (), but it need not save the device's settings in memory.

: Prepare for the execution of () by carrying out any operations required for thawing the device that might be racing with its driver's interrupt handler, which is guaranteed not to run while () is being executed. Analogous to ().

All of the above callbacks, except for (), return error codes. However, the error codes returned by the resume operations, (), (), (), (), (), and (), do not cause the PM core to abort the resume transition during which they are returned. The error codes returned in those cases are only printed by the PM core to the system logs for debugging purposes. Still, it is recommended that drivers only return error codes from their resume methods in case of an unrecoverable failure (i.e. when the device being handled refuses to resume and becomes unusable) to allow us to modify the PM core in the future, so that it can avoid attempting to handle devices that failed to resume and their children.

It is allowed to unregister devices while the above callbacks are being executed. However, a callback routine must NOT try to unregister the device it was called for, although it may unregister children of that device (for example, if it detects that a child was unplugged while the system was asleep).

Refer to Documentation/power/devices.txt for more information about the role of the above callbacks in the system suspend process.

There also are callbacks related to runtime power management of devices. Again, these callbacks are executed by the PM core only for subsystems (PM domains, device types, classes and bus types) and the subsystem-level callbacks are supposed to invoke the driver callbacks. Moreover, the exact actions to be performed by a device driver's callbacks generally depend on the platform and subsystem the device belongs to.

: Prepare the device for a condition in which it won't be able to communicate with the CPU(s) and RAM due to power management. This need not mean that the device should be put into a low-power state. For example, if the device is behind a link which is about to be turned off, the device may remain at full power. If the device does go to low power and is capable of generating runtime wakeup events, remote wakeup (i.e., a hardware mechanism allowing the device to request a change of its power state via an interrupt) should be enabled for it.

: Put the device into the fully active state in response to a wakeup event generated by hardware or at the request of software. If necessary, put the device into the full-power state and restore its registers, so that it is fully operational.

: Device appears to be inactive and it might be put into a low-power state if all of the necessary conditions are satisfied. Check these conditions and handle the device as appropriate, possibly queueing a suspend request for it. The return value is ignored by the PM core.

Refer to Documentation/power/runtime_pm.txt for more information about the role of the above callbacks in device runtime power management.

Definition at line 264 of file pm.h.

Field Documentation

void(* complete)(struct device *dev)

Definition at line 266 of file pm.h.

int(* freeze)(struct device *dev)

Definition at line 269 of file pm.h.

int(* freeze_late)(struct device *dev)

Definition at line 275 of file pm.h.

int(* freeze_noirq)(struct device *dev)

Definition at line 281 of file pm.h.

int(* poweroff)(struct device *dev)

Definition at line 271 of file pm.h.

int(* poweroff_late)(struct device *dev)

Definition at line 277 of file pm.h.

int(* poweroff_noirq)(struct device *dev)

Definition at line 283 of file pm.h.

int(* prepare)(struct device *dev)

Definition at line 265 of file pm.h.

int(* restore)(struct device *dev)

Definition at line 272 of file pm.h.

int(* restore_early)(struct device *dev)

Definition at line 278 of file pm.h.

int(* restore_noirq)(struct device *dev)

Definition at line 284 of file pm.h.

int(* resume)(struct device *dev)

Definition at line 268 of file pm.h.

int(* resume_early)(struct device *dev)

Definition at line 274 of file pm.h.

int(* resume_noirq)(struct device *dev)

Definition at line 280 of file pm.h.

int(* runtime_idle)(struct device *dev)

Definition at line 287 of file pm.h.

int(* runtime_resume)(struct device *dev)

Definition at line 286 of file pm.h.

int(* runtime_suspend)(struct device *dev)

Definition at line 285 of file pm.h.

int(* suspend)(struct device *dev)

Definition at line 267 of file pm.h.

int(* suspend_late)(struct device *dev)

Definition at line 273 of file pm.h.

int(* suspend_noirq)(struct device *dev)

Definition at line 279 of file pm.h.

int(* thaw)(struct device *dev)

Definition at line 270 of file pm.h.

int(* thaw_early)(struct device *dev)

Definition at line 276 of file pm.h.

int(* thaw_noirq)(struct device *dev)

Definition at line 282 of file pm.h.


The documentation for this struct was generated from the following file: