mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: Farrukh Seyer Hasan <farrukh13hasan31@gmail.com>,
	Huang Rui <ray.huang@amd.com>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: Perry Yuan <perry.yuan@amd.com>,
	K Prateek Nayak <kprateek.nayak@amd.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cpufreq/amd-pstate: Do not cache bios_min_perf from populated CPPC_REQ
Date: Thu, 3 Dec 2026 14:38:00 -0600	[thread overview]
Message-ID: <1fbd5718-11db-42f0-89e2-6255afc3c5f4@amd.com> (raw)
In-Reply-To: <20261203130758.38506-1-farrukh13hasan31@gmail.com>



On 12/3/26 07:07, Farrukh Seyer Hasan wrote:
> Since commit 0e850278016e ("cpufreq/amd-pstate: Remove the defensive
> check for bios_min_perf"), msr_init_perf() unconditionally reads
> MIN_PERF from MSR_AMD_CPPC_REQ into perf.bios_min_perf.
> 
> That assumes MSR_AMD_CPPC_REQ only holds a BIOS-configured minimum on
> boot, which breaks on warm reboots or crashes because amd-pstate does
> not reset the MSR on reboot. On a Ryzen 7 4800H, warm rebooting after
> running performance policy leaves MAX_PERF and MIN_PERF at nominal_perf
> in MSR_AMD_CPPC_REQ, so msr_init_perf() treats the stale MIN_PERF as a
> BIOS minimum and amd_pstate_verify() sets policy->min to nominal_freq
> (2901000 kHz) instead of lowest_nonlinear_freq.
> 
> Only cache perf.bios_min_perf when MAX_PERF and DES_PERF are both zero
> in MSR_AMD_CPPC_REQ. Checking only those fields instead of the whole
> register rejects stale limits from previous boots while still accepting
> firmware that sets a default EPP alongside the BIOS min option.
> 
> Fixes: 0e850278016e ("cpufreq/amd-pstate: Remove the defensive check for bios_min_perf")
> Signed-off-by: Farrukh Seyer Hasan <farrukh13hasan31@gmail.com>
> ---
>   drivers/cpufreq/amd-pstate.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 4bedfbfc18b6..69bfeb923a53 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -533,7 +533,8 @@ static int msr_init_perf(struct amd_cpudata *cpudata)
>   	perf.nominal_perf = FIELD_GET(AMD_CPPC_NOMINAL_PERF_MASK, cap1);
>   	perf.lowest_nonlinear_perf = FIELD_GET(AMD_CPPC_LOWNONLIN_PERF_MASK, cap1);
>   	perf.lowest_perf = FIELD_GET(AMD_CPPC_LOWEST_PERF_MASK, cap1);
> -	perf.bios_min_perf = FIELD_GET(AMD_CPPC_MIN_PERF_MASK, cppc_req);
> +	if (!(cppc_req & (AMD_CPPC_MAX_PERF_MASK | AMD_CPPC_DES_PERF_MASK)))
> +		perf.bios_min_perf = FIELD_GET(AMD_CPPC_MIN_PERF_MASK, cppc_req);
>   	WRITE_ONCE(cpudata->perf, perf);
>   	WRITE_ONCE(cpudata->prefcore_ranking, FIELD_GET(AMD_CPPC_HIGHEST_PERF_MASK, cap1));
>   	WRITE_ONCE(cpudata->floor_perf_cnt, FIELD_GET(AMD_CPPC_FLOOR_PERF_CNT_MASK, cap1));

Can you tell me more about the actual issue that reproduced this?  Did 
you really see a problem with warm reboots?  Or are you having a system 
crash?  Can you give me some reproduce steps?

My knee jerk reaction was this doesn't make sense for kexec and the 
shutdown sequence both are expecting this flow.  Sashiko seems to agree.

https://sashiko.dev/#/patchset/20261203130758.38506-1-farrukh13hasan31%40gmail.com

      reply	other threads:[~2026-12-03 20:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 13:07 Farrukh Seyer Hasan
2026-12-03 20:38 ` Mario Limonciello [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=1fbd5718-11db-42f0-89e2-6255afc3c5f4@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=farrukh13hasan31@gmail.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=perry.yuan@amd.com \
    --cc=rafael@kernel.org \
    --cc=ray.huang@amd.com \
    --cc=viresh.kumar@linaro.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

all inboxes | Powered by JetHome®