From: Muhammad Usama Anjum <usama.anjum@collabora.com>
To: Mario Limonciello <mario.limonciello@amd.com>,
amd-gfx@lists.freedesktop.org, corbet@lwn.net, rafael@kernel.org,
gregkh@linuxfoundation.org, dakr@kernel.org
Cc: usama.anjum@collabora.com,
"Mario Limonciello (AMD)" <superm1@kernel.org>,
linux-doc@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH 1/2] PM: Allow device drivers to manage the frozen state of a device
Date: Thu, 23 Oct 2025 13:36:14 +0500 [thread overview]
Message-ID: <217840b8-2a44-4788-8e2e-e5525f32ca8f@collabora.com> (raw)
In-Reply-To: <20251022155114.48418-2-mario.limonciello@amd.com>
On 10/22/25 8:50 PM, Mario Limonciello wrote:
> 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>
Tested-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
> 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;
--
---
Thanks,
Usama
next prev parent reply other threads:[~2025-10-23 12:58 UTC|newest]
Thread overview: 8+ 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 ` [PATCH 1/2] PM: Allow device drivers to manage the frozen state of a device Mario Limonciello
2025-10-23 8:21 ` kernel test robot
2025-10-23 8:36 ` Muhammad Usama Anjum [this message]
2025-10-23 11:23 ` kernel test robot
2025-10-22 15:50 ` [PATCH 2/2] drm/amd: Manage frozen state internally Mario Limonciello
2025-10-22 16:00 ` Mario Limonciello
2025-10-23 8:37 ` Muhammad Usama Anjum
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=217840b8-2a44-4788-8e2e-e5525f32ca8f@collabora.com \
--to=usama.anjum@collabora.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=mario.limonciello@amd.com \
--cc=rafael@kernel.org \
--cc=superm1@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