Re: [PATCH v2] PM: hibernate: Log hibernation mode at S4 entry
From: Rafael J. Wysocki (Intel)
Date: Mon Oct 12 2026 - 14:33:46 EST
On Mon, Oct 12, 2026 at 6:18 AM Yongxin Yang <yangyongxin@xxxxxxxxxx> wrote:
>
> The S4 path is the only place where the kernel decides whether a
Note that it is only S4 if the "platform" mode is used, otherwise it
is just hibernation.
> 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");
Please add a separate "switch" function for this that will return a
matching string for the given "mode" value.
> pm_prepare_console();
> error = pm_notifier_call_chain_robust(PM_HIBERNATION_PREPARE, PM_POST_HIBERNATION);
> if (error)
> --