STRUCT PLATFORM_HIBERNATION_OPS(9)
π¦ STRUCT PLATFORM_HIBERNATION_OPS(9) π¦
okay so this is the struct platform_hibernation_ops page from the Kernel API Manual, and bestie, it's literally the blueprint for how a platform gets to do its own special little rituals during hibernation. think of it as the platform's backstage pass for the whole sleep-and-wakeup tour π
β¨ NAME β¨
struct platform_hibernation_ops β hibernation platform support. that's it, that's the vibe. it's the struct that hands a platform its moment to shine during a hibernation transition π«Ά
π SYNOPSIS π
struct platform_hibernation_ops {
int (*begin)(pm_message_t stage);
void (*end)(void);
int (*pre_snapshot)(void);
void (*finish)(void);
int (*prepare)(void);
int (*enter)(void);
void (*leave)(void);
int (*pre_restore)(void);
void (*restore_cleanup)(void);
void (*recover)(void);
};
π Members π
ten function pointers, ten little moments, and every single one of them is doing the most. let's go down the list π
beginβ tells the platform driver that we're starting hibernation. called right after shrinking memory and before freezing devices. it's the "hey bestie, we're doing the thing" of callbacks β¨endβ called by the PM core right after resuming devices, to indicate to the platform that the system has returned to the working state. welcome back, icon πpre_snapshotβ prepares the platform for creating the hibernation image. called right after devices have been frozen and before the nonboot CPUs are disabled (runs with IRQs on). picture day prep, but for an image πΈfinishβ restores the previous state of the platform after the hibernation image has been created or puts the platform into the normal operation mode after the hibernation (the same method is executed in both cases). called right after the nonboot CPUs have been enabled and before thawing devices (runs with IRQs on). yes, one method, two jobs β she contains multitudes πprepareβ prepares the platform for entering the low power state. called right after the hibernation image has been saved and before devices are prepared for entering the low power state. lowkey the "we're about to nap for real" heads-up π΄enterβ puts the system into the low power state after the hibernation image has been saved to disk. called after the nonboot CPUs have been disabled and all of the low level devices have been shut down (runs with IRQs off). no going back from here, fr fr π₯leaveβ performs the first stage of the cleanup after the system sleep state indicated byset_targethas been left. called right after the control has been passed from the boot kernel to the image kernel, before the nonboot CPUs are enabled and before devices are resumed. executed with interrupts disabled. πpre_restoreβ prepares system for the restoration from a hibernation image. called right after devices have been frozen and before the nonboot CPUs are disabled (runs with IRQs on). the glow-up back to full power starts here πrestore_cleanupβ cleans up after a failing image restoration. called right after the nonboot CPUs have been enabled and before thawing devices (runs with IRQs on). not me tidying up after things went sideways πrecoverβ recovers the platform from a failure to suspend devices. called by the PM core if the suspending of devices during hibernation fails. this callback is optional and should only be implemented by platforms which require special recovery actions in that situation. she's the one optional member of the group chat, and honestly? respect π«Ά
π Description π
the methods in this structure allow a platform to carry out special operations required by it during a hibernation transition. so basically: the platform has extra needs, and this struct is where it says them out loud π
all the methods below, except forrecover, must be implemented. like, no skips.recoveris the only one allowed to be absent β the rest are mandatory, no cap π
π SEE ALSO π
- Kernel file
./include/linux/suspend.h struct platform_suspend_ops(9)suspend_set_ops(9)pm_suspend_via_firmware(9)pm_resume_via_firmware(9)pm_suspend_no_platform(9)arch_suspend_disable_irqs(9)arch_suspend_enable_irqs(9)pm_pr_dbg(9)
and that's the whole page, bestie! this lil masterpiece lives at ./include/linux, dated October 2026, and it's giving β¨essential kernel readingβ¨. go forth and hibernate responsibly β periodt π
π₯π
π¦ 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