STRUCT DEV_PM_OPS(9)
π struct dev_pm_ops β Kernel API Manual π
This is the struct dev_pm_ops(9) page, bestie β it's all about device PM callbacks and the callback slots inside this struct. β¨
π NAME π
struct dev_pm_ops β device PM callbacks. That's the whole name situation. π«Ά
β¨ SYNOPSIS β¨
Here's the struct in all its glory β copy the fields exactly, do not freestyle them:
struct dev_pm_ops {
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);
};
π¦ Members π¦
Okay so now we go member by member. Every callback has main character energy, but they do different jobs. No cap. π
prepareβ 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 theprobemethod from being made too oncepreparehas succeeded. Ifpreparedetects 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:suspend,freeze, orpoweroff. If the transition is a suspend to memory or standby (that is, not related to hibernation), the return value ofpreparemay be used to indicate to the PM core to leave the device in runtime suspend if applicable. Namely, ifpreparereturns a positive number, the PM core will understand that as a declaration that the device appears to be runtime-suspended and it may be left in that state during the entire transition and during the subsequent resume if all of its descendants are left in runtime suspend too. If that happens,completewill be executed directly afterprepareand it must ensure the proper functioning of the device after the system resume. The PM core executes subsystem-levelpreparefor all devices before starting to invokesuspendcallbacks for any of them, so generally devices may be assumed to be functional or to respond to runtime resume requests whileprepareis 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 withinprepare(it's too late to do that). It also is NOT valid to allocate substantial amounts of memory frompreparein theGFP_KERNELmode. [To work around these limitations, drivers may register suspend and hibernation notifiers to be executed before the freezing of tasks.]completeβ Undo the changes made byprepare. This method is executed for all kinds of resume transitions, following one of the resume callbacks:resume,thaw,restore. Also called if the state transition fails before the driver'ssuspendcallback:suspend,freezeorpoweroff, can be executed (e.g. if thesuspendcallback fails for one of the other devices that the PM core has unsuccessfully attempted to suspend earlier). The PM core executes subsystem-levelcompleteafter it has executed the appropriate resume callbacks for all devices. If the correspondingprepareat the beginning of the suspend transition returned a positive number and the device was left in runtime suspend (without executing any suspend and resume callbacks for it),completewill be the only callback executed for the device during resume. In that case,completemust be prepared to do whatever is necessary to ensure the proper functioning of the device after the system resume. To this end,completecan check thepower.direct_completeflag of the device to learn whether (unset) or not (set) the previous suspend and resume callbacks have been executed for it.suspendβ 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-levelsuspendhas returned, so that it doesn't do any I/O or DMA. Subsystem-levelsuspendis executed for all devices after invoking subsystem-levelpreparefor all of them.resumeβ 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'sresumecallback 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 duringresume. Subsystem-levelresumeis executed for all devices after invoking subsystem-levelresume_noirqfor all of them.freezeβ Hibernation-specific, executed before creating a hibernation image. Analogous tosuspend, 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-levelfreezeto save the device settings in memory to be used byrestoreduring the subsequent resume from hibernation. Subsystem-levelfreezeis executed for all devices after invoking subsystem-levelpreparefor all of them.thawβ 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 precedingfreeze, so the device can be operated in the same way as immediately before the call tofreeze. Subsystem-levelthawis executed for all devices after invoking subsystem-levelthaw_noirqfor all of them. It also may be executed directly afterfreezein case of a transition error.poweroffβ Hibernation-specific, executed after saving a hibernation image. Analogous tosuspend, but it need not save the device's settings in memory. Subsystem-levelpoweroffis executed for all devices after invoking subsystem-levelpreparefor all of them.restoreβ Hibernation-specific, executed after restoring the contents of main memory from a hibernation image, analogous toresume.suspend_lateβ Continue operations started bysuspend. For a number of devicessuspend_latemay point to the same callback routine as the runtime suspend callback.resume_earlyβ Prepare to executeresume. For a number of devicesresume_earlymay point to the same callback routine as the runtime resume callback.freeze_lateβ Continue operations started byfreeze. Analogous tosuspend_late, but it should not enable the device to signal wakeup events or change its power state.thaw_earlyβ Prepare to executethaw. Undo the changes made by the precedingfreeze_late.poweroff_lateβ Continue operations started bypoweroff. Analogous tosuspend_late, but it need not save the device's settings in memory.restore_earlyβ Prepare to executerestore, analogous toresume_early.suspend_noirqβ Complete the actions started bysuspend. 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 whilesuspend_noirqis 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-levelsuspend_noirqhas 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,suspendorsuspend_latemay 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 definesuspend_noirq.resume_noirqβ Prepare for the execution ofresumeby 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 whileresume_noirqis being executed.freeze_noirqβ okay bestie, finish up the stufffreezestarted β¨. Carry out any additional operations required for freezing the device that might be racing with its driver's interrupt handler β and that handler is guaranteed not to run whilefreeze_noirqis being executed. Also, the device's power state should not be changed byfreeze,freeze_late, orfreeze_noirq, and it should not be configured to signal system wakeup by any of these callbacks. Periodt. πthaw_noirqβ prep for the execution ofthawby 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 whilethaw_noirqis being executed. π«Άpoweroff_noirqβ complete the actions started bypoweroff. Analogous tosuspend_noirq, but it need not save the device's settings in memory. πΎβrestore_noirqβ prep for the execution ofrestoreby 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 whilerestore_noirqis being executed. Analogous toresume_noirq. πΈruntime_suspendβ prepare the device for a condition in which it won't be able to communicate with theCPU(s)and RAM due to power management. This need not mean 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. π₯runtime_resumeβ 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. β‘runtime_idleβ 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 return0if it's appropriate to let the PM core queue a suspend request for the device. π¦
π Description π
Okay so several device power state transitions are externally visible β they affect 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, typically, 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 expected 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. π§
All of the above callbacks, except for complete, return error codes. However, the error codes returned by resume, thaw, restore, resume_noirq, thaw_noirq, and restore_noirq, 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 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 the PM core to be modified 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). π¨
bestie, that MUST NOT is doing a lot of heavy lifting β do not unregister the device your callback was called for. Children? Maybe. The device itself? Absolutely not. π
There also are callbacks related to runtime power management of devices. Again, as a rule these callbacks are executed by the PM core for subsystems (PM domains, device types, classes and bus types) and the subsystem-level callbacks are expected 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. π
Refer to Documentation/power/runtime_pm.rst for more information about the role of the runtime_suspend, runtime_resume and runtime_idle callbacks in device runtime power management. π
π SEE ALSO π
- Kernel file
./include/linux/pm.h struct dev_pm_domain(9)
That's the whole vibe β¨ β this page's source is ./include/linux, its date is October 2026, and it's serving struct dev_pm_ops(9). Bye bestie, go freeze something responsibly π
π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms