* [PATCH] cpufreq/amd-pstate: Do not fail init when auto_sel cannot be written
@ 2026-09-18 4:42 Wentao Guan
2026-09-18 5:33 ` K Prateek Nayak
0 siblings, 1 reply; 6+ messages in thread
From: Wentao Guan @ 2026-09-18 4:42 UTC (permalink / raw)
To: kprateek.nayak, ray.huang
Cc: scardracs, superm1, linux-pm, linux-kernel, Wentao Guan, stable, LFRon
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.
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.
Fixes: 9dfd13f80c85 ("cpufreq/amd-pstate: Toggle auto_sel in active mode on shared memory systems")
Cc: stable@vger.kernel.org
Tested-by: LFRon <ronforever@outlook.com>
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
---
drivers/cpufreq/amd-pstate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 80d99ba1902c9..3657c5cccd4d8 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -538,5 +538,5 @@ static int shmem_init_perf(struct amd_cpudata *cpudata)
if (ret)
pr_warn("failed to set auto_sel, ret: %d\n", ret);
- return ret;
+ return 0;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cpufreq/amd-pstate: Do not fail init when auto_sel cannot be written
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
2026-09-18 7:08 ` [PATCH v2] cpufreq/amd-pstate: Skip auto_sel write when it already matches the mode Wentao Guan
0 siblings, 2 replies; 6+ messages in thread
From: K Prateek Nayak @ 2026-09-18 5:33 UTC (permalink / raw)
To: Wentao Guan, superm1
Cc: ray.huang, scardracs, linux-pm, linux-kernel, stable, LFRon
Hello Wentao,
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?
>
> Fixes: 9dfd13f80c85 ("cpufreq/amd-pstate: Toggle auto_sel in active mode on shared memory systems")
> Cc: stable@vger.kernel.org
> Tested-by: LFRon <ronforever@outlook.com>
> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
> ---
> drivers/cpufreq/amd-pstate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 80d99ba1902c9..3657c5cccd4d8 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -538,5 +538,5 @@ static int shmem_init_perf(struct amd_cpudata *cpudata)
> if (ret)
> pr_warn("failed to set auto_sel, ret: %d\n", ret);
>
> - return ret;
> + return 0;
> }
--
Thanks and Regards,
Prateek
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] cpufreq/amd-pstate: Do not fail init when auto_sel cannot be written
2026-09-18 5:33 ` K Prateek Nayak
@ 2026-09-18 5:48 ` Wentao Guan
2026-09-18 7:08 ` [PATCH v2] cpufreq/amd-pstate: Skip auto_sel write when it already matches the mode Wentao Guan
1 sibling, 0 replies; 6+ messages in thread
From: Wentao Guan @ 2026-09-18 5:48 UTC (permalink / raw)
To: kprateek.nayak
Cc: guanwentao, linux-kernel, linux-pm, ray.huang, ronforever,
scardracs, stable, superm1
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] cpufreq/amd-pstate: Skip auto_sel write when it already matches the mode
2026-09-18 5:33 ` K Prateek Nayak
2026-09-18 5:48 ` Wentao Guan
@ 2026-09-18 7:08 ` Wentao Guan
2026-09-18 8:43 ` K Prateek Nayak
1 sibling, 1 reply; 6+ messages in thread
From: Wentao Guan @ 2026-09-18 7:08 UTC (permalink / raw)
To: kprateek.nayak
Cc: guanwentao, linux-kernel, linux-pm, ray.huang, ronforever,
scardracs, stable, superm1
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.
Platforms that exclusively support autonomous selection report this field
as an Integer of 1, as required by the ACPI specification, instead of as a
register descriptor. cppc_get_reg_val() reads such a field back
successfully, but cppc_set_reg_val() rejects the write with -EOPNOTSUPP
because the entry is not an ACPI_TYPE_BUFFER.
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
Skip the write when the register already holds the value the requested mode
needs. Active and guided mode are fixed on these platforms, which report
auto_sel as 1, while passive mode still fails to load on a platform that
cannot disable autonomous selection, exactly as it did before the
offending commit.
Fixes: 9dfd13f80c85 ("cpufreq/amd-pstate: Toggle auto_sel in active mode on shared memory systems")
Cc: stable@vger.kernel.org
Tested-by: LFRon <ronforever@outlook.com>
Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
---
changelog v2:
Accecpt and tested the K Prateek Nayak reviews.
v1 link:
https://lore.kernel.org/stable/20260918054808.48999-1-guanwentao@uniontech.com/#R
---
---
drivers/cpufreq/amd-pstate.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 3a6b4b224a66d..91ec44f9fbb96 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -535,6 +535,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);
--
2.30.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] cpufreq/amd-pstate: Skip auto_sel write when it already matches the mode
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
0 siblings, 1 reply; 6+ messages in thread
From: K Prateek Nayak @ 2026-09-18 8:43 UTC (permalink / raw)
To: Wentao Guan
Cc: linux-kernel, linux-pm, ray.huang, ronforever, scardracs, stable,
superm1
Hello Wentao,
On 9/18/2026 12:38 PM, 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.
>
> Platforms that exclusively support autonomous selection report this field
> as an Integer of 1, as required by the ACPI specification, instead of as a
> register descriptor. cppc_get_reg_val() reads such a field back
> successfully, but cppc_set_reg_val() rejects the write with -EOPNOTSUPP
> because the entry is not an ACPI_TYPE_BUFFER.
>
> 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
>
> Skip the write when the register already holds the value the requested mode
> needs. Active and guided mode are fixed on these platforms, which report
> auto_sel as 1, while passive mode still fails to load on a platform that
> cannot disable autonomous selection, exactly as it did before the
> offending commit.
>
> Fixes: 9dfd13f80c85 ("cpufreq/amd-pstate: Toggle auto_sel in active mode on shared memory systems")
> Cc: stable@vger.kernel.org
> Tested-by: LFRon <ronforever@outlook.com>
> Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
You can flip that to:
Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
You did all the hard work to find, debug, and test it!
> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
> ---
> changelog v2:
> Accecpt and tested the K Prateek Nayak reviews.
> v1 link:
> https://lore.kernel.org/stable/20260918054808.48999-1-guanwentao@uniontech.com/#R
> ---
> ---
> drivers/cpufreq/amd-pstate.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 3a6b4b224a66d..91ec44f9fbb96 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -535,6 +535,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);
nit. Now that we arrive here only to flip the autosel value,
you can just do:
cppc_set_auto_sel(cpudata->cpu, !auto_sel)
... and remove that ternary op.
--
Thanks and Regards,
Prateek
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3] cpufreq/amd-pstate: Skip auto_sel write when it already matches the mode
2026-09-18 8:43 ` K Prateek Nayak
@ 2026-09-18 9:09 ` Wentao Guan
0 siblings, 0 replies; 6+ messages in thread
From: Wentao Guan @ 2026-09-18 9:09 UTC (permalink / raw)
To: kprateek.nayak
Cc: guanwentao, linux-kernel, linux-pm, ray.huang, ronforever,
scardracs, stable, superm1
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.
Platforms that exclusively support autonomous selection report this field
as an Integer of 1, as required by the ACPI specification, instead of as a
register descriptor. cppc_get_reg_val() reads such a field back
successfully, but cppc_set_reg_val() rejects the write with -EOPNOTSUPP
because the entry is not an ACPI_TYPE_BUFFER.
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
Skip the write when the register already holds the value the requested mode
needs. Active and guided mode are fixed on these platforms, which report
auto_sel as 1, while passive mode still fails to load on a platform that
cannot disable autonomous selection, exactly as it did before the
offending commit.
Fixes: 9dfd13f80c85 ("cpufreq/amd-pstate: Toggle auto_sel in active mode on shared memory systems")
Cc: stable@vger.kernel.org
Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Tested-by: LFRon <ronforever@outlook.com>
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
---
changelog v3:
Include the K Prateek Nayak reviews to remove that ternary op base on current
condition now have.
v2 link:
https://lore.kernel.org/stable/c3eb86bd-70a6-4bb2-8eff-b2a3c0817514@amd.com/#R
changelog v2:
Accecpt and tested the K Prateek Nayak reviews.
v1 link:
https://lore.kernel.org/stable/20260918054808.48999-1-guanwentao@uniontech.com/#R
---
---
drivers/cpufreq/amd-pstate.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 80d99ba1902c9..2d1f5292d1738 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -532,8 +532,10 @@ static int shmem_init_perf(struct amd_cpudata *cpudata)
return 0;
}
- ret = cppc_set_auto_sel(cpudata->cpu,
- (cppc_state == AMD_PSTATE_PASSIVE) ? 0 : 1);
+ if ((cppc_state != AMD_PSTATE_PASSIVE) == auto_sel)
+ return 0;
+
+ ret = cppc_set_auto_sel(cpudata->cpu, !auto_sel);
if (ret)
pr_warn("failed to set auto_sel, ret: %d\n", ret);
--
2.30.2
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-09-18 9:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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®