Linux Power Management development
 help / color / mirror / Atom feed
From: Wentao Guan <guanwentao@uniontech.com>
To: kprateek.nayak@amd.com
Cc: guanwentao@uniontech.com, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org, ray.huang@amd.com,
	ronforever@outlook.com, scardracs@disroot.org,
	stable@vger.kernel.org, superm1@kernel.org
Subject: Re: [PATCH] cpufreq/amd-pstate: Do not fail init when auto_sel cannot be written
Date: Fri, 18 Sep 2026 13:48:08 +0800	[thread overview]
Message-ID: <20260918054808.48999-1-guanwentao@uniontech.com> (raw)
In-Reply-To: <748cb8d6-174c-4cad-98bc-ebb985e2eced@amd.com>

Hi,

> On 9/18/2026 10:12 AM, Wentao Guan wrote:
> > Since commit 9dfd13f80c85 ("cpufreq/amd-pstate: Toggle auto_sel in active
> > mode on shared memory systems"), shmem_init_perf() programs
> > AUTONOMOUS_SELECTION_ENABLE unconditionally, including in active mode.
> >
> > On platforms implementing CPPC v2 and below, _CPC reports Autonomous
> > Selection Enable as a plain integer rather than as a register descriptor.
> > Such a field is a read-only capability flag: cppc_get_reg_val() reads it
> > back successfully (the firmware reports it as enabled), while
> > cppc_set_reg_val() rejects the write with -EOPNOTSUPP because the entry is
> > not an ACPI_TYPE_BUFFER.
> 
> Ah! So it is one of those platforms that fall into:
> 
>     Platforms that exclusively support Autonomous Selection must populate
>     this field as an Integer with a value of 1.
> 
> as per the ACPI spec.
> 
> >
> > shmem_init_perf() propagates that error, so every amd_pstate_epp_cpu_init()
> > fails, cpufreq_register_driver() ends up with an empty policy list and
> > returns -ENODEV, and amd-pstate refuses to load at all:
> >
> >   amd_pstate: failed to set auto_sel, ret: -95
> >   amd_pstate: Failed to initialize CPU 0: -95
> >   ...
> >   amd_pstate: failed to register with return -19
> >
> > Failing to write auto_sel is not fatal: the register is either already
> > enabled, as reported by the cppc_get_auto_sel() call right above, or not
> > writable at all, and active mode worked in both cases before the offending
> > commit.  Downgrade the failure to a warning and let initialization
> > continue, matching how the cppc_get_auto_sel() failure is handled.
> 
> Can't we just skip cppc_set_auto_sel() if the auto_sel is already at
> the desired value? Something like:
> 
>   (Completely untested)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index d4ff8b228f86..ed540da818ef 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -524,6 +524,9 @@ static int shmem_init_perf(struct amd_cpudata *cpudata)
>  		return 0;
>  	}
> 
> +	if ((cppc_state != AMD_PSTATE_PASSIVE) == auto_sel)
> +		return 0;
> +
>  	ret = cppc_set_auto_sel(cpudata->cpu,
>  			(cppc_state == AMD_PSTATE_PASSIVE) ? 0 : 1);
> 
> ---
> 
> That way we fail for passive mode switch which will operate under
> incorrectly assumptions since these platform only supports autonomous
> modes.

> Thoughts?

Thanks for your review, full agree with your suggested patch.
I will send v2 after be tested later.

BRs
Wentao Guan

  reply	other threads:[~2026-09-18  5:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18  4:42 [PATCH] cpufreq/amd-pstate: Do not fail init when auto_sel cannot be written Wentao Guan
2026-09-18  5:33 ` K Prateek Nayak
2026-09-18  5:48   ` Wentao Guan [this message]
2026-09-18  7:08   ` [PATCH v2] cpufreq/amd-pstate: Skip auto_sel write when it already matches the mode Wentao Guan
2026-09-18  8:43     ` K Prateek Nayak
2026-09-18  9:09       ` [PATCH v3] " Wentao Guan

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=20260918054808.48999-1-guanwentao@uniontech.com \
    --to=guanwentao@uniontech.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=ray.huang@amd.com \
    --cc=ronforever@outlook.com \
    --cc=scardracs@disroot.org \
    --cc=stable@vger.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