[PATCH v2] PM: hibernate: Log hibernation mode at S4 entry

From: Yongxin Yang

Date: Mon Oct 12 2026 - 00:18:33 EST


The S4 path is the only place where the kernel decides whether a
completed image write ends in poweroff or reboot, but it leaves no
trace of that decision in the log. If the resume path later fails or
hangs, the tester cannot tell which outcome was requested, so a report
of "S4 rebooted instead of powering off" cannot be attributed to
configuration or to platform behavior.

Append the mode name to the existing "hibernation entry" message, so
that line reads "hibernation entry (reboot)", "hibernation entry
(shutdown)" or "hibernation entry (suspend)" instead of a bare
"hibernation entry". The name comes from hibernation_mode, the same
value power_down() later switches on (1 = platform, 2 = shutdown,
3 = reboot, 4 = suspend).

No functional change.

Signed-off-by: Yongxin Yang <yangyongxin@xxxxxxxxxx>
---
kernel/power/hibernate.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index e365e440cd52..2a285d29cbe3 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -794,7 +794,14 @@ int hibernate(void)
goto Unlock;
}

- pr_info("hibernation entry\n");
+ pr_info("hibernation entry (%s)\n",
+ hibernation_mode == HIBERNATION_REBOOT ? "reboot" :
+ hibernation_mode == HIBERNATION_PLATFORM ? "platform" :
+#ifdef CONFIG_SUSPEND
+ hibernation_mode == HIBERNATION_SUSPEND ? "suspend" :
+#endif
+ hibernation_mode == HIBERNATION_TEST_RESUME ? "test_resume" :
+ "shutdown");
pm_prepare_console();
error = pm_notifier_call_chain_robust(PM_HIBERNATION_PREPARE, PM_POST_HIBERNATION);
if (error)
--
2.25.1