mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ACPI: CPPC: Add helper to get effective guaranteed performance
@ 2026-05-29  8:18 Xueqin Luo
  2026-05-29 15:33 ` srinivas pandruvada
  0 siblings, 1 reply; 3+ messages in thread
From: Xueqin Luo @ 2026-05-29  8:18 UTC (permalink / raw)
  To: rafael, lenb, srinivas.pandruvada, viresh.kumar, saket.dumbre,
	linux-acpi, linux-kernel, linux-pm, acpica-devel
  Cc: Xueqin Luo

According to the ACPI CPPC specification, if the Guaranteed
Performance register is not implemented, OSPM assumes the
guaranteed performance is equal to nominal performance.

Add cppc_get_effective_guaranteed_perf() helper to provide a
spec-compliant effective guaranteed performance value while
preserving the raw values returned by cppc_get_perf_caps().

Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
---
 drivers/acpi/cppc_acpi.c       | 26 ++++++++++++++++++++++++++
 drivers/cpufreq/intel_pstate.c | 10 ++++------
 include/acpi/cppc_acpi.h       |  5 +++++
 3 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index f370be8715ae..6dc11030707a 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -1328,6 +1328,32 @@ int cppc_get_highest_perf(int cpunum, u64 *highest_perf)
 }
 EXPORT_SYMBOL_GPL(cppc_get_highest_perf);
 
+/**
+ * cppc_get_effective_guaranteed_perf - get effective guaranteed performance
+ * @cpunum: CPU number
+ * @guaranteed_perf: Effective guaranteed performance value
+ *
+ * The ACPI CPPC specification states that if the Guaranteed
+ * Performance register is not implemented, OSPM assumes the
+ * guaranteed performance is equal to nominal performance.
+ *
+ * Return: 0 on success, negative errno on failure.
+ */
+int cppc_get_effective_guaranteed_perf(int cpunum, u64 *guaranteed_perf)
+{
+	struct cppc_perf_caps perf_caps;
+	int ret;
+
+	ret = cppc_get_perf_caps(cpunum, &perf_caps);
+	if (ret)
+		return ret;
+	*guaranteed_perf = perf_caps.guaranteed_perf ?:
+			   perf_caps.nominal_perf;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(cppc_get_effective_guaranteed_perf);
+
 /**
  * cppc_get_epp_perf - Get the epp register value.
  * @cpunum: CPU from which to get epp preference value.
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 8dc22a65e025..8934e48f71a2 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -404,17 +404,15 @@ static void intel_pstate_set_itmt_prio(int cpu)
 
 static int intel_pstate_get_cppc_guaranteed(int cpu)
 {
-	struct cppc_perf_caps cppc_perf;
+	u64 guaranteed_perf;
 	int ret;
 
-	ret = cppc_get_perf_caps(cpu, &cppc_perf);
+	ret = cppc_get_effective_guaranteed_perf(cpu, &guaranteed_perf);
+
 	if (ret)
 		return ret;
 
-	if (cppc_perf.guaranteed_perf)
-		return cppc_perf.guaranteed_perf;
-
-	return cppc_perf.nominal_perf;
+	return guaranteed_perf;
 }
 
 static int intel_pstate_cppc_get_scaling(int cpu)
diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h
index d1f02ceec4f9..c02f3bc1fc1a 100644
--- a/include/acpi/cppc_acpi.h
+++ b/include/acpi/cppc_acpi.h
@@ -155,6 +155,7 @@ struct cppc_cpudata {
 extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf);
 extern int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf);
 extern int cppc_get_highest_perf(int cpunum, u64 *highest_perf);
+extern int cppc_get_effective_guaranteed_perf(int cpunum, u64 *guaranteed_perf);
 extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs);
 extern int cppc_get_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);
 extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);
@@ -198,6 +199,10 @@ static inline int cppc_get_highest_perf(int cpunum, u64 *highest_perf)
 {
 	return -EOPNOTSUPP;
 }
+static inline int cppc_get_effective_guaranteed_perf(int cpunum, u64 *guaranteed_perf)
+{
+	return -EOPNOTSUPP;
+}
 static inline int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
 {
 	return -EOPNOTSUPP;
-- 
2.43.0


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

end of thread, other threads:[~2026-06-01  2:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-29  8:18 [PATCH] ACPI: CPPC: Add helper to get effective guaranteed performance Xueqin Luo
2026-05-29 15:33 ` srinivas pandruvada
2026-06-01  2:31   ` luoxueqin

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®