Linux Power Management development
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>
Cc: <linux-acpi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-pm@vger.kernel.org>,
	K Prateek Nayak <kprateek.nayak@amd.com>, <x86@kernel.org>,
	Mario Limonciello <mario.limonciello@amd.com>
Subject: [PATCH v2 2/5] ACPI: CPPC: Add support for reading HighestFreq
Date: Mon, 4 May 2026 18:01:38 -0500	[thread overview]
Message-ID: <20260504230141.484743-3-mario.limonciello@amd.com> (raw)
In-Reply-To: <20260504230141.484743-1-mario.limonciello@amd.com>

A future revision of the ACPI specification will be including
a definition for HighestFreq.  Add support for reading it.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v2:
 * Fix optional register mask
---
 drivers/acpi/cppc_acpi.c | 31 +++++++++++++++++++++----------
 include/acpi/cppc_acpi.h |  7 ++++++-
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index fbc620adafad7..f96a83b58072b 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -134,7 +134,7 @@ static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr);
  * cpc_regs[] with the corresponding index. 0 means mandatory and 1
  * means optional.
  */
-#define REG_OPTIONAL (0x7FC7D0)
+#define REG_OPTIONAL (0x1FFC7D0)
 
 /*
  * Use the index of the register in per-cpu cpc_regs[] to check if
@@ -186,6 +186,7 @@ show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, lowest_nonlinear_perf);
 show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, guaranteed_perf);
 show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, lowest_freq);
 show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, nominal_freq);
+show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, highest_freq);
 
 show_cppc_data(cppc_get_perf_ctrs, cppc_perf_fb_ctrs, wraparound_time);
 
@@ -259,6 +260,7 @@ static struct attribute *cppc_attrs[] = {
 	&nominal_freq.attr,
 	&lowest_freq.attr,
 	&ospm_nominal_perf.attr,
+	&highest_freq.attr,
 	NULL
 };
 ATTRIBUTE_GROUPS(cppc);
@@ -793,14 +795,15 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
 	if ((cpc_rev == CPPC_V2_REV && num_ent != CPPC_V2_NUM_ENT) ||
 	    (cpc_rev == CPPC_V3_REV && num_ent != CPPC_V3_NUM_ENT) ||
 	    (cpc_rev == CPPC_V4_REV && num_ent != CPPC_V4_NUM_ENT) ||
-	    (cpc_rev > CPPC_V4_REV && num_ent <= CPPC_V4_NUM_ENT)) {
+	    (cpc_rev == CPPC_V5_REV && num_ent != CPPC_V5_NUM_ENT) ||
+	    (cpc_rev > CPPC_V5_REV && num_ent <= CPPC_V5_NUM_ENT)) {
 		pr_debug("Unexpected number of _CPC return package entries (%d) for CPU:%d\n",
 			 num_ent, pr->id);
 		goto out_free;
 	}
-	if (cpc_rev > CPPC_V4_REV) {
-		num_ent = CPPC_V4_NUM_ENT;
-		cpc_rev = CPPC_V4_REV;
+	if (cpc_rev > CPPC_V5_REV) {
+		num_ent = CPPC_V5_NUM_ENT;
+		cpc_rev = CPPC_V5_REV;
 	}
 
 	cpc_ptr->num_entries = num_ent;
@@ -1402,9 +1405,10 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
 	struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum);
 	struct cpc_register_resource *highest_reg, *lowest_reg,
 		*lowest_non_linear_reg, *nominal_reg, *reference_reg,
-		*guaranteed_reg, *low_freq_reg = NULL, *nom_freq_reg = NULL;
+		*guaranteed_reg, *low_freq_reg = NULL, *nom_freq_reg = NULL,
+		*highest_freq_reg = NULL;
 	u64 high, low, guaranteed, nom, ref, min_nonlinear,
-	    low_f = 0, nom_f = 0;
+	    low_f = 0, nom_f = 0, high_f = 0;
 	int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);
 	struct cppc_pcc_data *pcc_ss_data = NULL;
 	int ret = 0, regs_in_pcc = 0;
@@ -1421,6 +1425,7 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
 	reference_reg = &cpc_desc->cpc_regs[REFERENCE_PERF];
 	low_freq_reg = &cpc_desc->cpc_regs[LOWEST_FREQ];
 	nom_freq_reg = &cpc_desc->cpc_regs[NOMINAL_FREQ];
+	highest_freq_reg = &cpc_desc->cpc_regs[HIGHEST_FREQ];
 	guaranteed_reg = &cpc_desc->cpc_regs[GUARANTEED_PERF];
 
 	/* Are any of the regs PCC ?*/
@@ -1428,7 +1433,7 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
 		CPC_IN_PCC(lowest_non_linear_reg) || CPC_IN_PCC(nominal_reg) ||
 		(CPC_SUPPORTED(reference_reg) && CPC_IN_PCC(reference_reg)) ||
 		CPC_IN_PCC(low_freq_reg) || CPC_IN_PCC(nom_freq_reg) ||
-		CPC_IN_PCC(guaranteed_reg)) {
+		CPC_IN_PCC(guaranteed_reg) || CPC_IN_PCC(highest_freq_reg)) {
 		if (pcc_ss_id < 0) {
 			pr_debug("Invalid pcc_ss_id\n");
 			return -ENODEV;
@@ -1491,7 +1496,7 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
 		goto out_err;
 	}
 
-	/* Read optional lowest and nominal frequencies if present */
+	/* Read optional lowest, highest and nominal frequencies if present */
 	if (CPC_SUPPORTED(low_freq_reg)) {
 		ret = cpc_read(cpunum, low_freq_reg, &low_f);
 		if (ret)
@@ -1504,9 +1509,15 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
 			goto out_err;
 	}
 
+	if (CPC_SUPPORTED(highest_freq_reg)) {
+		ret = cpc_read(cpunum, highest_freq_reg, &high_f);
+		if (ret)
+			goto out_err;
+	}
+
 	perf_caps->lowest_freq = low_f;
 	perf_caps->nominal_freq = nom_f;
-
+	perf_caps->highest_freq = high_f;
 
 out_err:
 	if (regs_in_pcc)
diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h
index 3771e2ed507de..053ea67f767ff 100644
--- a/include/acpi/cppc_acpi.h
+++ b/include/acpi/cppc_acpi.h
@@ -21,14 +21,16 @@
 #define CPPC_V2_REV	2
 #define CPPC_V3_REV	3
 #define CPPC_V4_REV	4
+#define CPPC_V5_REV	5
 #define CPPC_V2_NUM_ENT	21
 #define CPPC_V3_NUM_ENT	23
 #define CPPC_V4_NUM_ENT	25
+#define CPPC_V5_NUM_ENT	27
 
 #define PCC_CMD_COMPLETE_MASK	(1 << 0)
 #define PCC_ERROR_MASK		(1 << 2)
 
-#define MAX_CPC_REG_ENT 23
+#define MAX_CPC_REG_ENT 25
 
 /* CPPC specific PCC commands. */
 #define	CMD_READ 0
@@ -114,6 +116,8 @@ enum cppc_regs {
 	NOMINAL_FREQ,
 	OSPM_NOMINAL_PERF,
 	RESOURCE_PRIORITY,
+	HIGHEST_FREQ,
+	CURRENT_FREQ,
 };
 
 /*
@@ -131,6 +135,7 @@ struct cppc_perf_caps {
 	u32 lowest_nonlinear_perf;
 	u32 lowest_freq;
 	u32 nominal_freq;
+	u32 highest_freq;
 };
 
 struct cppc_perf_ctrls {
-- 
2.43.0


  parent reply	other threads:[~2026-05-04 23:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-04 23:01 [PATCH v2 0/5] Add CPPC HighestFreq support Mario Limonciello
2026-05-04 23:01 ` [PATCH v2 1/5] Revert "ACPI: CPPC: Adjust debug messages in amd_set_max_freq_ratio() to warn" Mario Limonciello
2026-05-05 16:30   ` Kim Phillips
2026-05-08 19:04   ` Rafael J. Wysocki
2026-05-08 19:09     ` Mario Limonciello
2026-05-08 19:17       ` Rafael J. Wysocki
2026-05-08 19:21         ` Mario Limonciello
2026-05-04 23:01 ` Mario Limonciello [this message]
2026-05-04 23:01 ` [PATCH v2 3/5] ACPI: CPPC: Refactor boost ratio handling Mario Limonciello
2026-05-04 23:01 ` [PATCH v2 4/5] cpufreq/acpi-cpufreq: Use amd_get_boost_ratio() Mario Limonciello
2026-05-04 23:01 ` [PATCH v2 5/5] cpufreq/amd-pstate: Get highest freq from CPPC if available Mario Limonciello
2026-05-07  9:33 ` [PATCH v2 0/5] Add CPPC HighestFreq support K Prateek Nayak

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=20260504230141.484743-3-mario.limonciello@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=x86@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