Linux Power Management development
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: Samuel Zhang <guoqing.zhang@amd.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Cc: lijo.lazar@amd.com, victor.zhao@amd.com, haijun.chang@amd.com,
	Qing.Ma@amd.com, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, alexander.deucher@amd.com,
	christian.koenig@amd.com, rafael@kernel.org, len.brown@intel.com,
	pavel@kernel.org, gregkh@linuxfoundation.org, dakr@kernel.org,
	airlied@gmail.com, simona@ffwll.ch, ray.huang@amd.com,
	matthew.auld@intel.com, matthew.brost@intel.com,
	maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	tzimmermann@suse.de
Subject: Re: [PATCH v2 4/5] PM: hibernate: export variable pm_transition
Date: Sun, 6 Jul 2025 16:40:09 -0400	[thread overview]
Message-ID: <2c609512-ebe8-4a61-a666-44b308975d72@amd.com> (raw)
In-Reply-To: <20250704101233.347506-5-guoqing.zhang@amd.com>

On 7/4/2025 6:12 AM, Samuel Zhang wrote:
> https://github.com/torvalds/linux/blob/v6.14/Documentation/power/pci.rst?plain=1#L588
> Per this kernel doc, dev_pm_ops.thaw() is called mainly for resume

Proper way to do this is to put the URL in a 'Link' tag above your SoB. 
That being said I don't think we need to reference the rst file.  Just 
reference the html file.

Something like this:

Per the PCI power management documentation [1] dev_pm_ops.thaw() is 
called mainly for resume.

.
.
.

Link: https://docs.kernel.org/power/pci.html [1]
S-o-b: Foo bar <foo@bar.com>

> storage devices for saving the hibernation image. Other devices that not

that are not

> involved in the image saving do not need to resume the device.
> 
> But dev_pm_ops.thaw() is also called to restore devices when hibernation
> is aborted due to some error in hibernation image creation stage.
> 
> So there need to be a way to query in thaw() to know if hibernation is
> aborted or not and conditionally resume devices. Exported pm_transition
> is such a way. When thaw() is called, the value is:
> - PM_EVENT_THAW: normal hibernate, no need to resume non-storage devices.
> - PM_EVENT_RECOVER: cancelled hibernation, need to resume devices.

If these events are being exported out for driver use I think that we 
also need matching kernel doc exported too.

That is the comments in include/linux/pm.h need to be converted into 
kernel doc.

Before you make any changes like that though let's see what Rafael 
thinks of this approach.

He might not want to export this symbol out and would prefer a new 
helper for drivers to use like:

inline bool pm_aborted_hibernate();

If that's the direction he prefers you'll need to make kernel doc for 
that instead.

> 
> Signed-off-by: Samuel Zhang <guoqing.zhang@amd.com>
> ---
>   drivers/base/power/main.c | 3 ++-
>   include/linux/pm.h        | 2 ++
>   2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index 40e1d8d8a589..d50f58c0121b 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -61,7 +61,8 @@ static LIST_HEAD(dpm_late_early_list);
>   static LIST_HEAD(dpm_noirq_list);
>   
>   static DEFINE_MUTEX(dpm_list_mtx);
> -static pm_message_t pm_transition;
> +pm_message_t pm_transition;
> +EXPORT_SYMBOL_GPL(pm_transition);
>   
>   static int async_error;
>   
> diff --git a/include/linux/pm.h b/include/linux/pm.h
> index 78855d794342..f01846852a90 100644
> --- a/include/linux/pm.h
> +++ b/include/linux/pm.h
> @@ -657,6 +657,8 @@ struct pm_subsys_data {
>   #define DPM_FLAG_SMART_SUSPEND		BIT(2)
>   #define DPM_FLAG_MAY_SKIP_RESUME	BIT(3)
>   
> +extern pm_message_t pm_transition;
> +
>   struct dev_pm_info {
>   	pm_message_t		power_state;
>   	bool			can_wakeup:1;


  reply	other threads:[~2025-07-06 20:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-04 10:12 [PATCH v2 0/5] reduce system memory requirement for hibernation Samuel Zhang
2025-07-04 10:12 ` [PATCH v2 1/5] drm/ttm: add ttm_device_prepare_hibernation() api Samuel Zhang
2025-07-06 20:44   ` Mario Limonciello
2025-07-07  0:48     ` Matthew Brost
2025-07-07  9:13   ` Christian König
2025-07-04 10:12 ` [PATCH v2 2/5] drm/amdgpu: move GTT to shmem after eviction for hibernation Samuel Zhang
2025-07-06 20:41   ` Mario Limonciello
2025-07-07  9:16   ` Christian König
2025-07-04 10:12 ` [PATCH v2 3/5] PM: hibernate: shrink shmem pages after dev_pm_ops.prepare() Samuel Zhang
2025-07-07 18:45   ` Rafael J. Wysocki
2025-07-04 10:12 ` [PATCH v2 4/5] PM: hibernate: export variable pm_transition Samuel Zhang
2025-07-06 20:40   ` Mario Limonciello [this message]
2025-07-07 19:17     ` Rafael J. Wysocki
2025-07-04 10:12 ` [PATCH v2 5/5] drm/amdgpu: do not resume device in thaw for normal hibernation Samuel Zhang
2025-07-06 20:34   ` Mario Limonciello
2025-07-07  2:28     ` Lazar, Lijo
2025-07-07  2:29       ` 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=2c609512-ebe8-4a61-a666-44b308975d72@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=Qing.Ma@amd.com \
    --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=guoqing.zhang@amd.com \
    --cc=haijun.chang@amd.com \
    --cc=len.brown@intel.com \
    --cc=lijo.lazar@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=mripard@kernel.org \
    --cc=pavel@kernel.org \
    --cc=rafael@kernel.org \
    --cc=ray.huang@amd.com \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    --cc=victor.zhao@amd.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