From: "Mario Limonciello (AMD)" <superm1@kernel.org>
To: mario.limonciello@amd.com, airlied@gmail.com,
alexander.deucher@amd.com, christian.koenig@amd.com,
dakr@kernel.org, gregkh@linuxfoundation.org, lenb@kernel.org,
pavel@kernel.org, rafael@kernel.org, simona@ffwll.ch
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-pm@vger.kernel.org
Subject: [RFC PATCH 1/3] PM: hibernate: Nominally skip thaw sequence for all devices
Date: Mon, 13 Oct 2025 12:47:09 -0500 [thread overview]
Message-ID: <20251013174729.1101186-2-superm1@kernel.org> (raw)
In-Reply-To: <20251013174729.1101186-1-superm1@kernel.org>
From: Mario Limonciello <mario.limonciello@amd.com>
After the hibernation snapshot is created all devices will have
their thaw() callback called before the next stage. For the most
common scenarios of hibernation this is not necessary because the
device will be powered off anyway.
If the hibernation snapshot was successfully created skip thawing
devices until it's needed for userspace created hibernation image
or hybrid sleep. To accomplish this use PMSG_INVALID in
hibernation_snapshot() and set the dpm functions to skip running.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/base/power/main.c | 6 ++++++
kernel/power/hibernate.c | 13 ++++++++++---
kernel/power/user.c | 3 +++
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 8179fd53171dc..58f5270a173e8 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1143,6 +1143,9 @@ void dpm_resume(pm_message_t state)
struct device *dev;
ktime_t starttime = ktime_get();
+ if (state.event == PM_EVENT_INVALID)
+ return;
+
trace_suspend_resume(TPS("dpm_resume"), state.event, true);
pm_transition = state;
@@ -1245,6 +1248,9 @@ void dpm_complete(pm_message_t state)
{
struct list_head list;
+ if (state.event == PM_EVENT_INVALID)
+ return;
+
trace_suspend_resume(TPS("dpm_complete"), state.event, true);
INIT_LIST_HEAD(&list);
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index aadf82f57e868..7af2e392c574a 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -480,13 +480,14 @@ int hibernation_snapshot(int platform_mode)
if (error || !in_suspend)
swsusp_free();
- msg = in_suspend ? (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE;
+ msg = in_suspend ? (error ? PMSG_RECOVER : PMSG_INVALID) : PMSG_RESTORE;
dpm_resume(msg);
- if (error || !in_suspend)
+ if (error || !in_suspend) {
pm_restore_gfp_mask();
+ console_resume_all();
+ }
- console_resume_all();
dpm_complete(msg);
Close:
@@ -707,7 +708,13 @@ static void power_down(void)
#ifdef CONFIG_SUSPEND
if (hibernation_mode == HIBERNATION_SUSPEND) {
+ /* recover from hibernation_snapshot() */
+ dpm_resume(PMSG_THAW);
+ console_resume_all();
+ dpm_complete(PMSG_THAW);
pm_restore_gfp_mask();
+
+ /* run suspend sequence */
error = suspend_devices_and_enter(mem_sleep_current);
if (!error)
goto exit;
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 3f9e3efb9f6e7..d70c963b1ba88 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -310,6 +310,9 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
pm_restore_gfp_mask();
error = hibernation_snapshot(data->platform_support);
if (!error) {
+ dpm_resume(PMSG_THAW);
+ console_resume_all();
+ dpm_complete(PMSG_THAW);
error = put_user(in_suspend, (int __user *)arg);
data->ready = !freezer_test_done && !error;
freezer_test_done = false;
--
2.43.0
next prev parent reply other threads:[~2025-10-13 17:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-13 17:47 [RFC PATCH 0/3] Skip thaw sequence for all devices, not just amdgpu Mario Limonciello (AMD)
2025-10-13 17:47 ` Mario Limonciello (AMD) [this message]
2025-10-13 17:58 ` [RFC PATCH 1/3] PM: hibernate: Nominally skip thaw sequence for all devices Rafael J. Wysocki
2025-10-13 18:27 ` Mario Limonciello
2025-10-13 18:29 ` Rafael J. Wysocki
2025-10-13 17:47 ` [RFC PATCH 2/3] drm/amd: Drop special cases for thaw() callback Mario Limonciello (AMD)
2025-10-13 17:47 ` [RFC PATCH 3/3] PM: Drop pm_hibernate_is_recovering() and pm_hibernation_mode_is_suspend() Mario Limonciello (AMD)
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=20251013174729.1101186-2-superm1@kernel.org \
--to=superm1@kernel.org \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=lenb@kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
--cc=simona@ffwll.ch \
/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