mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cpufreq/amd-pstate: Don't fail active mode init on read-only auto_sel
@ 2026-10-08  4:07 Akram Boulahia
  2026-10-08 21:12 ` Mario Limonciello
  0 siblings, 1 reply; 3+ messages in thread
From: Akram Boulahia @ 2026-10-08  4:07 UTC (permalink / raw)
  To: Mario Limonciello, Huang Rui, linux-pm
  Cc: Perry Yuan, K Prateek Nayak, Rafael J. Wysocki, Viresh Kumar,
	linux-kernel, Akram Boulahia, stable, Marco Scardovi

Since commit 9dfd13f80c85 ("cpufreq/amd-pstate: Toggle auto_sel in active
mode on shared memory systems"), shmem_init_perf() no longer returns
early in active mode and always calls cppc_set_auto_sel(), which was
needed for shared memory systems. However, on firmware where the
Autonomous Selection Enable entry of _CPC is a constant integer rather
than a register, that write fails with -EOPNOTSUPP. The error is
returned, every CPU fails to initialize, cpufreq_register_driver() finds
no policy and returns -ENODEV, and the kernel falls back to
acpi-cpufreq:

  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

This was seen on an ASUS ROG Zephyrus G14 (GA403UV, Ryzen 9 8945HS, BIOS
308). Its _CPC tables are revision 3 with the entry fixed at 1, and
cppc_get_auto_sel() reads back 1 on all CPUs.

If the write returns -EOPNOTSUPP while active mode is requested and
auto_sel already reads as enabled, which is what active mode needs, the
refused write is harmless and initialization can continue. Any other
failure, including a refusal where the current value does not match the
requested mode, is still returned as before.

With this change, amd-pstate-epp loads on all 16 CPUs of that machine
without warnings. amd_pstate=passive behaves as before: it still falls
back to acpi-cpufreq with the same -95 errors, because auto_sel stays at 1
and cannot be changed.

Tested on Linux 7.3.0-rc6-00037-g7b63ef2d55f2.

Fixes: 9dfd13f80c85 ("cpufreq/amd-pstate: Toggle auto_sel in active mode on shared memory systems")
Cc: stable@vger.kernel.org
Cc: Marco Scardovi <scardracs@disroot.org>
Signed-off-by: Akram Boulahia <akram02st@gmail.com>
---
 drivers/cpufreq/amd-pstate.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 8bfd46d60843..05b496946d13 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -500,6 +500,7 @@ static int shmem_init_perf(struct amd_cpudata *cpudata)
 	union perf_cached perf = READ_ONCE(cpudata->perf);
 	u64 numerator;
 	bool auto_sel;
+	bool want;
 
 	int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
 	if (ret)
@@ -518,14 +519,23 @@ static int shmem_init_perf(struct amd_cpudata *cpudata)
 	WRITE_ONCE(cpudata->perf, perf);
 	WRITE_ONCE(cpudata->prefcore_ranking, cppc_perf.highest_perf);
 
+	want = (cppc_state != AMD_PSTATE_PASSIVE);
+
 	ret = cppc_get_auto_sel(cpudata->cpu, &auto_sel);
 	if (ret) {
 		pr_warn("failed to get auto_sel, ret: %d\n", ret);
 		return 0;
 	}
 
-	ret = cppc_set_auto_sel(cpudata->cpu,
-			(cppc_state == AMD_PSTATE_PASSIVE) ? 0 : 1);
+	ret = cppc_set_auto_sel(cpudata->cpu, want);
+
+	/*
+	 * Firmware may expose Autonomous Selection Enable as a read-only
+	 * constant. If it already matches what active mode needs, the
+	 * failed write is harmless.
+	 */
+	if (ret == -EOPNOTSUPP && want && auto_sel)
+		return 0;
 
 	if (ret)
 		pr_warn("failed to set auto_sel, ret: %d\n", ret);
-- 
2.56.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-09  0:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-08  4:07 [PATCH] cpufreq/amd-pstate: Don't fail active mode init on read-only auto_sel Akram Boulahia
2026-10-08 21:12 ` Mario Limonciello
2026-10-09  0:10   ` Akram Boulahia

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®