From: Mario Limonciello <superm1@kernel.org>
To: mario.limonciello@amd.com, rafael@kernel.org, pavel@kernel.org,
len.brown@intel.com
Cc: linux-pm@vger.kernel.org
Subject: [PATCH v2] PM: hibernate: Explicitly set `PM_SUSPEND_MAX` at hibernate entry
Date: Thu, 8 May 2025 16:17:46 -0500 [thread overview]
Message-ID: <20250508211822.2698678-1-superm1@kernel.org> (raw)
From: Mario Limonciello <mario.limonciello@amd.com>
`pm_debug_messages` only works at suspend time, not hibernate. This is
because during hibernate the `pm_suspend_target_state` is not set.
Explicitly set pm_suspend_target_state at hibernate time. Since the symbol
is only enabled under `CONFIG_SUSPEND`, adjust symbol location and allow it
under `CONFIG_HIBERNATION` too.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v2:
* Fix for lkp robot failure where no CONFIG_SUSPEND
---
include/linux/suspend.h | 9 ++++++---
kernel/power/hibernate.c | 2 ++
kernel/power/main.c | 3 +++
kernel/power/suspend.c | 2 --
4 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index da6ebca3ff774..b66be47ef5282 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -142,8 +142,13 @@ struct platform_s2idle_ops {
void (*end)(void);
};
-#ifdef CONFIG_SUSPEND
+#if defined(CONFIG_SUSPEND) || defined(CONFIG_HIBERNATION)
extern suspend_state_t pm_suspend_target_state;
+#else
+#define pm_suspend_target_state (PM_SUSPEND_ON)
+#endif
+
+#ifdef CONFIG_SUSPEND
extern suspend_state_t mem_sleep_current;
extern suspend_state_t mem_sleep_default;
@@ -279,8 +284,6 @@ extern bool sync_on_suspend_enabled;
#else /* !CONFIG_SUSPEND */
#define suspend_valid_only_mem NULL
-#define pm_suspend_target_state (PM_SUSPEND_ON)
-
static inline void pm_suspend_clear_flags(void) {}
static inline void pm_set_suspend_via_firmware(void) {}
static inline void pm_set_resume_via_firmware(void) {}
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index f0db9d1896e80..8fb82a62b85f1 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -772,6 +772,7 @@ int hibernate(void)
}
pr_info("hibernation entry\n");
+ pm_suspend_target_state = PM_SUSPEND_MAX;
pm_prepare_console();
error = pm_notifier_call_chain_robust(PM_HIBERNATION_PREPARE, PM_POST_HIBERNATION);
if (error)
@@ -852,6 +853,7 @@ int hibernate(void)
hibernate_release();
Unlock:
unlock_system_sleep(sleep_flags);
+ pm_suspend_target_state = PM_SUSPEND_ON;
pr_info("hibernation exit\n");
return error;
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 97746f08b762b..0440644695c76 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -20,6 +20,9 @@
#include "power.h"
+suspend_state_t pm_suspend_target_state;
+EXPORT_SYMBOL_GPL(pm_suspend_target_state);
+
#ifdef CONFIG_PM_SLEEP
/*
* The following functions are used by the suspend/hibernate code to temporarily
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 8eaec4ab121d4..08cb71991795d 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -48,8 +48,6 @@ const char *mem_sleep_states[PM_SUSPEND_MAX];
suspend_state_t mem_sleep_current = PM_SUSPEND_TO_IDLE;
suspend_state_t mem_sleep_default = PM_SUSPEND_MAX;
-suspend_state_t pm_suspend_target_state;
-EXPORT_SYMBOL_GPL(pm_suspend_target_state);
unsigned int pm_suspend_global_flags;
EXPORT_SYMBOL_GPL(pm_suspend_global_flags);
--
2.43.0
next reply other threads:[~2025-05-08 21:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-08 21:17 Mario Limonciello [this message]
2025-05-09 8:22 ` [PATCH v2] PM: hibernate: Explicitly set `PM_SUSPEND_MAX` at hibernate entry kernel test robot
2025-05-09 12:43 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250508211822.2698678-1-superm1@kernel.org \
--to=superm1@kernel.org \
--cc=len.brown@intel.com \
--cc=linux-pm@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox