Linux Power Management development
 help / color / mirror / Atom feed
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: Sebastien WALD <contact@sebastien-wald.fr>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Cc: linux-pm@vger.kernel.org
Subject: Re: [PATCH] powercap: intel_rapl: Restore power limits after hibernation
Date: Fri, 20 Nov 2026 07:36:47 -0800	[thread overview]
Message-ID: <cf4dd030efaa05939904042d211af7b564881ba8.camel@linux.intel.com> (raw)
In-Reply-To: <20261120153039.33744-1-contact@sebastien-wald.fr>

On Fri, 2026-11-20 at 16:30 +0100, Sebastien WALD wrote:
> rapl_pm_callback() saves the package power limits on
> PM_SUSPEND_PREPARE
> and restores them on PM_POST_SUSPEND, but does nothing for
> hibernation.
> 
> When the system resumes from hibernation, the boot that loads the
> image
> goes through the firmware again, which reprograms its default power
> limits. The values set from user space before hibernating are lost.
> 
> On an MSI GS76 Stealth 11UH (Core i9-11900H), thermald sets PL1/PL2
> to
> 45 W/64 W. After resume from hibernation, PL2 reads 120 W, the
> firmware
> default, and stays there; thermald does not re-apply an unchanged
> target. Suspend-to-RAM is not affected, because of the existing
> save/restore.
> 
> Handle PM_HIBERNATION_PREPARE and PM_POST_HIBERNATION in the same way
> as
> their suspend counterparts. The saved values live in kernel memory,
> so
> they are part of the hibernation image and available when
> PM_POST_HIBERNATION is delivered after the image has been restored.
> 
> The problem was analysed, and this change written, with the help of
> an
> AI coding assistant (Claude); the analysis was checked against the
> driver source and against the behaviour of the machine above.
> 
> Fixes: 52b3672c1354 ("powercap: add suspend and resume mechanism for
> SOC power limit")
> Signed-off-by: Sebastien WALD <contact@sebastien-wald.fr>


Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

> ---
> Notes (not for the changelog):
> 
> Reported first to thermald, where Srinivas asked to take it to the
> kernel:
> https://github.com/intel/thermal_daemon/issues/621
> 
> Testing, on 7.3.5 (CachyOS build, clang/ThinLTO):
> 
> - Without the patch, PL2 of intel-rapl:0 reads 120 W after resume
> from
>   hibernation instead of 64 W (observed with thermald running; it
> does
>   not re-apply an unchanged target).
> - With the patch applied to the 7.3.5 driver, built out of tree (no
>   warnings with W=1) and loaded in place of the stock module,
> thermald
>   stopped and the limits written by hand:
>     before hibernation: intel-rapl:0 PL1=45 W PL2=64 W
>     after resume:       intel-rapl:0 PL1=45 W PL2=64 W
>   The intel-rapl-mmio:0 limits were also unchanged across the cycle.
> - I have not run a control with the stock module and thermald
> stopped;
>   the "without" case above comes from the original thermald report.
> - checkpatch.pl reports no problem (apart from an unknown commit id,
>   since it was run outside a kernel tree).
> 
> The machine runs an ACPI SSDT override for an unrelated firmware bug
> (\_SB.IETM._OSC references an undefined \_TZ.ETMD) and the out-of-
> tree
> nvidia and msi-ec modules, so the kernel is tainted (A, O, E). None
> of
> these touches the RAPL MSRs as far as I can tell.
> 
>  drivers/powercap/intel_rapl_common.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/powercap/intel_rapl_common.c
> b/drivers/powercap/intel_rapl_common.c
> index f58649f..eb8c02a 100644
> --- a/drivers/powercap/intel_rapl_common.c
> +++ b/drivers/powercap/intel_rapl_common.c
> @@ -1878,9 +1878,11 @@ static int rapl_pm_callback(struct
> notifier_block *nb,
>  {
>  	switch (mode) {
>  	case PM_SUSPEND_PREPARE:
> +	case PM_HIBERNATION_PREPARE:
>  		power_limit_state_save();
>  		break;
>  	case PM_POST_SUSPEND:
> +	case PM_POST_HIBERNATION:
>  		power_limit_state_restore();
>  		break;
>  	}

      reply	other threads:[~2026-11-20 15:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 15:30 [PATCH] powercap: intel_rapl: Restore power limits after hibernation Sebastien WALD
2026-11-20 15:36 ` Srinivas Pandruvada [this message]

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=cf4dd030efaa05939904042d211af7b564881ba8.camel@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=contact@sebastien-wald.fr \
    --cc=linux-pm@vger.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