From: Mario Limonciello <mario.limonciello@amd.com>
To: <mario.limonciello@amd.com>, <amd-gfx@lists.freedesktop.org>,
<corbet@lwn.net>, <rafael@kernel.org>,
<gregkh@linuxfoundation.org>, <dakr@kernel.org>
Cc: "Mario Limonciello (AMD)" <superm1@kernel.org>,
Muhammad Usama Anjum <usama.anjum@collabora.com>,
<linux-doc@vger.kernel.org>, <linux-pm@vger.kernel.org>
Subject: [PATCH 1/2] PM: Allow device drivers to manage the frozen state of a device
Date: Wed, 22 Oct 2025 10:50:28 -0500 [thread overview]
Message-ID: <20251022155114.48418-2-mario.limonciello@amd.com> (raw)
In-Reply-To: <20251022155114.48418-1-mario.limonciello@amd.com>
From: "Mario Limonciello (AMD)" <superm1@kernel.org>
During a normal successful hibernate sequence devices will go through
the freeze() callbacks create an image, go through the thaw() callbacks,
and poweroff() callbacks.
During a successful hibernate sequence some device drivers may want to
skip the thaw() callbacks. This confuses the PM core though because it
thinks the device is no longer suspended.
To accommodate drivers that want to do this, introduce a new is_frozen
bit that the driver can set and manage. From the driver perspective
any thaw() or restore() callbacks that are being skipped should set
is_frozen and return an error code. The PM core will then put the
device back into the list of devices to resume for any aborted hibernate.
Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
Documentation/driver-api/pm/devices.rst | 8 ++++++++
drivers/base/power/main.c | 5 +++++
include/linux/pm.h | 3 +++
3 files changed, 16 insertions(+)
diff --git a/Documentation/driver-api/pm/devices.rst b/Documentation/driver-api/pm/devices.rst
index 36d5c9c9fd11..55c633727108 100644
--- a/Documentation/driver-api/pm/devices.rst
+++ b/Documentation/driver-api/pm/devices.rst
@@ -578,6 +578,14 @@ should already have been stored during the ``freeze``, ``freeze_late`` or
the entire system, so it is not necessary for the callback to put the device in
a low-power state.
+Skipping thaw phase
+-------------------
+In some rare situations, it may be desirable to skip the thaw phases
+(``thaw_noirq``, ``thaw_early``, ``thaw``) of a device entirely. This can be
+achieved by a device driver returning an error code from any of it's thaw
+callbacks but also setting dev->power.is_frozen to true. This indicates to the
+PM core that the device is still in the frozen state. The PM core will consider
+this when resuming the device in later phases such as `restore` or `poweroff`.
Leaving Hibernation
-------------------
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index e83503bdc1fd..451d54486645 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1100,6 +1100,11 @@ static void device_resume(struct device *dev, pm_message_t state, bool async)
End:
error = dpm_run_callback(callback, dev, state, info);
+ /* device manages frozen state */
+ if (error && dev->power.is_frozen) {
+ dev->power.is_suspended = true;
+ error = 0;
+ }
device_unlock(dev);
dpm_watchdog_clear(&wd);
diff --git a/include/linux/pm.h b/include/linux/pm.h
index cc7b2dc28574..52ee38d72aa2 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -688,6 +688,9 @@ struct dev_pm_info {
#else
bool should_wakeup:1;
#endif
+#ifdef CONFIG_HIBERNATE_CALLBACKS
+ bool is_frozen:1; /* Owned by the driver */
+#endif
#ifdef CONFIG_PM
struct hrtimer suspend_timer;
u64 timer_expires;
--
2.51.0
next prev parent reply other threads:[~2025-10-22 15:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-22 15:50 [PATCH 0/2] Fixups for cancelled hibernate Mario Limonciello
2025-10-22 15:50 ` Mario Limonciello [this message]
2025-10-23 8:21 ` [PATCH 1/2] PM: Allow device drivers to manage the frozen state of a device kernel test robot
2025-10-23 8:36 ` Muhammad Usama Anjum
2025-10-23 11:23 ` kernel test robot
[not found] ` <20251022155114.48418-3-mario.limonciello@amd.com>
2025-10-22 16:00 ` [PATCH 2/2] drm/amd: Manage frozen state internally Mario Limonciello
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=20251022155114.48418-2-mario.limonciello@amd.com \
--to=mario.limonciello@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=corbet@lwn.net \
--cc=dakr@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=superm1@kernel.org \
--cc=usama.anjum@collabora.com \
/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