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

Configure Feed

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

PM: hibernate: add new api pm_hibernate_is_recovering()

dev_pm_ops.thaw() is called in following cases:
* normal case: after hibernation image has been created.
* error case 1: creation of a hibernation image has failed.
* error case 2: restoration from a hibernation image has failed.

For normal case, it is called mainly for resume storage devices for
saving the hibernation image. Other devices that are not involved
in the image saving do not need to resume the device. But since there's
no api to know which case thaw() is called, device drivers can't
conditionally resume device in thaw().

The new pm_hibernate_is_recovering() is such a api to query if thaw() is
called in normal case.

Signed-off-by: Samuel Zhang <guoqing.zhang@amd.com>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Link: https://lore.kernel.org/r/20250710062313.3226149-5-guoqing.zhang@amd.com
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

authored by

Samuel Zhang and committed by
Mario Limonciello
c2aaddbd 2640e819

+16
+14
drivers/base/power/main.c
··· 66 66 static DEFINE_MUTEX(async_wip_mtx); 67 67 static int async_error; 68 68 69 + /** 70 + * pm_hibernate_is_recovering - if recovering from hibernate due to error. 71 + * 72 + * Used to query if dev_pm_ops.thaw() is called for normal hibernation case or 73 + * recovering from some error. 74 + * 75 + * Return: true for error case, false for normal case. 76 + */ 77 + bool pm_hibernate_is_recovering(void) 78 + { 79 + return pm_transition.event == PM_EVENT_RECOVER; 80 + } 81 + EXPORT_SYMBOL_GPL(pm_hibernate_is_recovering); 82 + 69 83 static const char *pm_verb(int event) 70 84 { 71 85 switch (event) {
+2
include/linux/suspend.h
··· 426 426 static inline int is_hibernate_resume_dev(dev_t dev) { return 0; } 427 427 #endif 428 428 429 + bool pm_hibernate_is_recovering(void); 430 + 429 431 /* Hibernation and suspend events */ 430 432 #define PM_HIBERNATION_PREPARE 0x0001 /* Going to hibernate */ 431 433 #define PM_POST_HIBERNATION 0x0002 /* Hibernation finished */