From nobody Sat Sep 26 11:46:48 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18D694825B0; Thu, 24 Sep 2026 16:01:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790265663; cv=none; b=kp9GLU4NCYvCMoZJv1t0xSe+LNoHINmWxpjjr51ZUp8QmXYi0RMTokVqMmnMzoEW4X6nyOWbEjG1z2ONFwV67f+Rg9MxF3uF2Nmba1ZLXhG+7PXVXFmlshrGarpYd323GSEE7Q1zSM0NvwUPAGO0/DZ8kdT/HHPGynN4juBXdJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790265663; c=relaxed/simple; bh=7Sm1+818GeG0t7D+5s7EDP1NBipRrb/XhkFtGDI6mlA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d+TPBU1kvrB7wRjQthi/3ZXU/5i7ze+9EcZiEHo7TABOU/h/HrnDIwcJCbgpXXH4MDuI7X9Fr/Gh0erxmqrqq4BtxAJeDrsRVx/d2v0B0TlT4m8zOmTCeOjXzm3x+wwritUnTOgRnd7RE+idS4g5jqomEfq55o6lL13GmaSXygc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gouhcHnI; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gouhcHnI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CDC61F000FF; Thu, 24 Sep 2026 16:01:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790265662; bh=QVp5gf7IGH8fmNs5ohJPxgFYd0uT/7O4/Uswe2+Ka9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gouhcHnI4X3eoETwRyyXQgLTm6JUjJQ7p5vSrBezYxKC3l+s2eIl3P2c223HnRbVX p/9+XWZQiWAfsPRBk7C+Fj9CyTYHDhAYFHjuvs972fiHl6NKUssbIm2Ajz4CoR2SCz +9sSeybiHMn0wXx9OQzfC1Z7QyKAUMkW7e55uqI4gD/KUowXFICHDdcuYESESKE0ES UF2zldNJktXOJi9MDxoh/4O6PpojP7uOWQy/NLy7ZgBG3TTHxa5xWAofzMf8A945I4 NlehBeEGW+SEZV8J4mZ3W/2iYEGsXn0/hISAbcgPlPaMghKSTxf/i+TemKEo9+9M1l mMP3T4gK6HTGA== From: "Mario Limonciello (AMD)" To: =?UTF-8?q?Rafael=20J=20=2E=20Wysocki=20=E2=8F=8E?= Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, K Prateek Nayak , x86@kernel.org, Mario Limonciello Subject: [PATCH v3 1/3] ACPI: CPPC: Refactor boost ratio handling Date: Thu, 24 Sep 2026 11:00:50 -0500 Message-ID: <20260924160052.2858456-2-superm1@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260924160052.2858456-1-superm1@kernel.org> References: <20260924160052.2858456-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mario Limonciello Rename amd_get_boost_ratio_numerator() to amd_get_effective_highest_perf() to better reflect that it returns the effective highest performance value for a CPU, accounting for preferred cores and heterogeneous topologies. Add a new helper amd_get_boost_ratio() for doing both for boost ratio calculations and update callers to use it. This refactoring is needed because on some AMD systems (Zen6+), the boost ratio should be calculated from frequency values rather than performance values. The frequency values will eventually come from the BIOS, but for now use some hardcoded values for Zen6 platforms. Tested-by: K Prateek Nayak Signed-off-by: Mario Limonciello --- arch/x86/kernel/acpi/cppc.c | 166 ++++++++++++++++++++++----------- drivers/cpufreq/acpi-cpufreq.c | 5 +- drivers/cpufreq/amd-pstate.c | 14 ++- include/acpi/cppc_acpi.h | 14 ++- 4 files changed, 134 insertions(+), 65 deletions(-) diff --git a/arch/x86/kernel/acpi/cppc.c b/arch/x86/kernel/acpi/cppc.c index d2185b7a20306..1c6bf56c3215b 100644 --- a/arch/x86/kernel/acpi/cppc.c +++ b/arch/x86/kernel/acpi/cppc.c @@ -11,6 +11,7 @@ #include #include #include +#include =20 #define CPPC_HIGHEST_PERF_PERFORMANCE 196 #define CPPC_HIGHEST_PERF_PREFCORE 166 @@ -95,31 +96,18 @@ int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 = val) =20 static void amd_set_max_freq_ratio(void) { - struct cppc_perf_caps perf_caps; - u64 numerator, nominal_perf; + u64 numerator, denominator; u64 perf_ratio; int rc; =20 - rc =3D cppc_get_perf_caps(0, &perf_caps); - if (rc) { - pr_debug("Could not retrieve perf counters (%d)\n", rc); - return; - } - - rc =3D amd_get_boost_ratio_numerator(0, &numerator); + rc =3D amd_get_boost_ratio(0, &numerator, &denominator); if (rc) { - pr_debug("Could not retrieve highest performance (%d)\n", rc); - return; - } - nominal_perf =3D perf_caps.nominal_perf; - - if (!nominal_perf) { - pr_debug("Could not retrieve nominal performance\n"); + pr_debug("Could not retrieve boost ratio (%d)\n", rc); return; } =20 /* midpoint between max_boost and max_P */ - perf_ratio =3D (div_u64(numerator * SCHED_CAPACITY_SCALE, nominal_perf) += SCHED_CAPACITY_SCALE) >> 1; + perf_ratio =3D (div_u64(numerator * SCHED_CAPACITY_SCALE, denominator) + = SCHED_CAPACITY_SCALE) >> 1; =20 freq_invariance_set_perf_ratio(perf_ratio, false); } @@ -239,35 +227,30 @@ int amd_detect_prefcore(bool *detected) EXPORT_SYMBOL_GPL(amd_detect_prefcore); =20 /** - * amd_get_boost_ratio_numerator: Get the numerator to use for boost ratio= calculation - * @cpu: CPU to get numerator for. - * @numerator: Output variable for numerator. - * - * Determine the numerator to use for calculating the boost ratio on - * a CPU. On systems that support preferred cores, this will be a hardcoded - * value. On other systems this will the highest performance register valu= e. + * amd_get_effective_highest_perf: Get the effective highest performance v= alue + * @cpu: CPU to get highest performance for. * - * If booting the system with amd-pstate enabled but preferred cores disab= led then - * the correct boost numerator will be returned to match hardware capabili= ties - * even if the preferred cores scheduling hints are not enabled. + * Get the effective highest performance value for a CPU, accounting for + * preferred cores and heterogeneous topologies. On systems with preferred + * cores, this may be a hardcoded value. On heterogeneous systems, this + * may be a per-CPU value. On other systems, this is the shared highest + * performance value. * - * Return: 0 for success, negative error code otherwise. + * Return: Effective highest performance value, or negative error code. */ -int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator) +int amd_get_effective_highest_perf(unsigned int cpu) { bool prefcore; int ret; u32 tmp; =20 ret =3D amd_detect_prefcore(&prefcore); - if (ret) + if (ret < 0) return ret; =20 /* without preferred cores, return the highest perf register value */ - if (!prefcore) { - *numerator =3D boost_numerator; - return 0; - } + if (!prefcore) + return boost_numerator; =20 /* * For AMD CPUs with Family ID 19H and Model ID range 0x70 to 0x7f, @@ -277,8 +260,7 @@ int amd_get_boost_ratio_numerator(unsigned int cpu, u64= *numerator) if (cpu_feature_enabled(X86_FEATURE_ZEN4)) { switch (boot_cpu_data.x86_model) { case 0x70 ... 0x7f: - *numerator =3D CPPC_HIGHEST_PERF_PERFORMANCE; - return 0; + return CPPC_HIGHEST_PERF_PERFORMANCE; default: break; } @@ -286,28 +268,100 @@ int amd_get_boost_ratio_numerator(unsigned int cpu, = u64 *numerator) =20 /* detect if running on heterogeneous design */ if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES)) { - switch (cpu_data(cpu).topo.cpu_type) { - case TOPO_CPU_TYPE_UNKNOWN: - case TOPO_CPU_TYPE_ANY: - pr_warn("Undefined core type found for cpu %d\n", cpu); - break; - case TOPO_CPU_TYPE_PERFORMANCE: - /* use the max scale for performance cores */ - *numerator =3D CPPC_HIGHEST_PERF_PERFORMANCE; - return 0; - case TOPO_CPU_TYPE_LOW_POWER: - case TOPO_CPU_TYPE_EFFICIENCY: - /* use the highest perf value for efficiency and low-power cores */ - ret =3D amd_get_highest_perf(cpu, &tmp); - if (ret) - return ret; - *numerator =3D tmp; - return 0; - } + if (cpu_feature_enabled(X86_FEATURE_ZEN5) && + cpu_data(cpu).topo.cpu_type =3D=3D TOPO_CPU_TYPE_PERFORMANCE) + return CPPC_HIGHEST_PERF_PERFORMANCE; + + /* Zen 5 efficiency, and Zen 6+ */ + ret =3D amd_get_highest_perf(cpu, &tmp); + if (ret < 0) + return ret; + + return tmp; + } + + return CPPC_HIGHEST_PERF_PREFCORE; +} +EXPORT_SYMBOL_GPL(amd_get_effective_highest_perf); + +struct amd_max_freq { + u32 performance; + u32 efficiency; + u32 low_power; +}; + +static const struct amd_max_freq max_freq_zen6_client =3D { + .performance =3D 5025, + .efficiency =3D 3524, + .low_power =3D 2399, +}; + +int amd_get_max_frequency(unsigned int cpu) +{ + enum x86_topology_cpu_type type =3D cpu_data(cpu).topo.cpu_type; + const struct amd_max_freq *max_freq =3D NULL; + + if (cpu_feature_enabled(X86_FEATURE_ZEN6) && + cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES)) + max_freq =3D &max_freq_zen6_client; + + if (!max_freq) + return 0; + + switch (type) { + case TOPO_CPU_TYPE_PERFORMANCE: + return max_freq->performance; + case TOPO_CPU_TYPE_EFFICIENCY: + return max_freq->efficiency; + case TOPO_CPU_TYPE_LOW_POWER: + return max_freq->low_power; + default: + break; } =20 - *numerator =3D CPPC_HIGHEST_PERF_PREFCORE; + return 0; +} +EXPORT_SYMBOL_GPL(amd_get_max_frequency); + +/** + * amd_get_boost_ratio: Get numerator and denominator for boost ratio + * @cpu: CPU to get the boost ratio for. + * @numerator: Output variable for numerator. + * @denominator: Output variable for denominator. + * + * Get the numerator and denominator for calculating the boost ratio. + * + * Return: 0 for success, negative error code otherwise. + */ +int amd_get_boost_ratio(unsigned int cpu, u64 *numerator, u64 *denominator) +{ + struct cppc_perf_caps perf_caps; + int max_frequency; + int ret; + + ret =3D cppc_get_perf_caps(cpu, &perf_caps); + if (ret) + return ret; + + max_frequency =3D amd_get_max_frequency(cpu); + /* Use frequency values if available */ + if (max_frequency && perf_caps.nominal_freq) { + *numerator =3D max_frequency; + *denominator =3D perf_caps.nominal_freq; + return 0; + } + + /* Fall back to performance values */ + ret =3D amd_get_effective_highest_perf(cpu); + if (ret < 0) + return ret; + + *numerator =3D ret; + + *denominator =3D perf_caps.nominal_perf; + if (!*denominator) + return -EINVAL; =20 return 0; } -EXPORT_SYMBOL_GPL(amd_get_boost_ratio_numerator); +EXPORT_SYMBOL_GPL(amd_get_boost_ratio); diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 10ea6035f4ad6..523ee1a06ef8a 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c @@ -640,12 +640,13 @@ static u64 get_max_boost_ratio(unsigned int cpu, u64 = *nominal_freq) } =20 if (boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_AMD) { - ret =3D amd_get_boost_ratio_numerator(cpu, &highest_perf); - if (ret) { + ret =3D amd_get_effective_highest_perf(cpu); + if (ret < 0) { pr_debug("CPU%d: Unable to get boost ratio numerator (%d)\n", cpu, ret); return 0; } + highest_perf =3D ret; } else { highest_perf =3D perf_caps.highest_perf; } diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index fbccbe86c94d0..496e0342c1c90 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -555,11 +555,13 @@ static int msr_init_perf(struct amd_cpudata *cpudata) if (ret) return ret; =20 - ret =3D amd_get_boost_ratio_numerator(cpudata->cpu, &numerator); - if (ret) + ret =3D amd_get_effective_highest_perf(cpudata->cpu); + if (ret < 0) return ret; =20 - ret =3D rdmsrq_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &cppc_req); + numerator =3D ret; + + ret =3D rdmsrq_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &cppc_req); if (ret) return ret; =20 @@ -590,10 +592,12 @@ static int shmem_init_perf(struct amd_cpudata *cpudat= a) if (ret) return ret; =20 - ret =3D amd_get_boost_ratio_numerator(cpudata->cpu, &numerator); - if (ret) + ret =3D amd_get_effective_highest_perf(cpudata->cpu); + if (ret < 0) return ret; =20 + numerator =3D ret; + perf.highest_perf =3D numerator; perf.max_limit_perf =3D numerator; perf.min_limit_perf =3D cppc_perf.lowest_perf; diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h index 3f0005abac648..5bcdb0e553b96 100644 --- a/include/acpi/cppc_acpi.h +++ b/include/acpi/cppc_acpi.h @@ -202,7 +202,9 @@ extern int cppc_set_auto_sel(int cpu, bool enable); extern int cppc_get_perf_limited(int cpu, u64 *perf_limited); extern int cppc_set_perf_limited(int cpu, u64 bits_to_clear); extern int amd_get_highest_perf(unsigned int cpu, u32 *highest_perf); -extern int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator); +extern int amd_get_effective_highest_perf(unsigned int cpu); +extern int amd_get_max_frequency(unsigned int cpu); +extern int amd_get_boost_ratio(unsigned int cpu, u64 *numerator, u64 *deno= minator); extern int amd_detect_prefcore(bool *detected); #else /* !CONFIG_ACPI_CPPC_LIB */ static inline int cppc_get_desired_perf(int cpunum, u64 *desired_perf) @@ -321,7 +323,15 @@ static inline int amd_get_highest_perf(unsigned int cp= u, u32 *highest_perf) { return -ENODEV; } -static inline int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *num= erator) +static inline int amd_get_effective_highest_perf(unsigned int cpu) +{ + return -EOPNOTSUPP; +} +static inline int amd_get_max_frequency(unsigned int cpu) +{ + return 0; +} +static inline int amd_get_boost_ratio(unsigned int cpu, u64 *numerator, u6= 4 *denominator) { return -EOPNOTSUPP; } --=20 2.53.0 From nobody Sat Sep 26 11:46:48 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 395D54503E4; Thu, 24 Sep 2026 16:01:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790265664; cv=none; b=APrMPEcPAgqTAuaMlyUbna/aPkNIYeL8wvW9RupqS4LxSNQNaYTq3rKWK4HiMdREYGUShEt6LCrTnKaRrKAqoCSLvCENw6Ed3BbTrLMdPGR8ekgpbKe/wD/N/QOFK73hDVsyFYYyZE3gGoI/tFddT9e8IyVNXlZrUaNOWO/+Hsw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790265664; c=relaxed/simple; bh=1plywIJLDji44OSYLVz0L2MqZabW2EVBru1OGAZ49Qs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ny2duUNA6eX/h1BWUkQ3ZCTEzhJJy9q/LQcAQFQFtmm1kWTLTg7AAwsvnYxuaaFGd1sOMAs3VkwdBFHXzHg39yPtFPIIFRC45kM/6iJI9IL1wGmwy6Xb10T5sQVMjX9zVtHopNWHboL7GJ3ri3XGGhuhwQA4FsYRvYQRHiijRVQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DJSlrWs6; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DJSlrWs6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D3CF1F00898; Thu, 24 Sep 2026 16:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790265662; bh=x6VZ4NYHxdF5KHVkhld7yVnQ4i6s62tsYc74Rk2w+0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DJSlrWs6efigY9tkR+ER9NoPCBGUCZMMfuPDy/j0zcy7h005qrruEZsUjhCmYUOVf twXRWKac026gsyzvTE/5R7qVdt173tvbc6Um68TGwYLsXF9F1AyrbD+xU26EA78zjL bfREOKEGLETNzOxDVhF//4MNKMi46G9cUgaxz4X2usLl5wAX9PJPCtpXVvvgLsk33d rHKpKOC38hcG2AV9Q3akPqYyDgf1vdY6x5wIrH9B68xYpSPYbd/h7JlwNDiWHd8c/p cdRKhJ9WmhJibWLECBTsStlRwuQjjLpjhoxNjZZgum+JE848Avzc541fEHmJzrru7q QjM+Ymavxo0HQ== From: "Mario Limonciello (AMD)" To: =?UTF-8?q?Rafael=20J=20=2E=20Wysocki=20=E2=8F=8E?= Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, K Prateek Nayak , x86@kernel.org, Mario Limonciello Subject: [PATCH v3 2/3] cpufreq/acpi-cpufreq: Use amd_get_boost_ratio() Date: Thu, 24 Sep 2026 11:00:51 -0500 Message-ID: <20260924160052.2858456-3-superm1@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260924160052.2858456-1-superm1@kernel.org> References: <20260924160052.2858456-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mario Limonciello Update get_max_boost_ratio() to use the new amd_get_boost_ratio() helper function instead of calling amd_get_effective_highest_perf() directly. This ensures the boost ratio is calculated correctly on systems where frequency values should be used instead of performance values. Reviewed-by: K Prateek Nayak Tested-by: K Prateek Nayak Signed-off-by: Mario Limonciello --- drivers/cpufreq/acpi-cpufreq.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 523ee1a06ef8a..2e74a000cdc74 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c @@ -626,7 +626,7 @@ static int acpi_cpufreq_blacklist(struct cpuinfo_x86 *c) static u64 get_max_boost_ratio(unsigned int cpu, u64 *nominal_freq) { struct cppc_perf_caps perf_caps; - u64 highest_perf, nominal_perf; + u64 numerator, denominator; int ret; =20 if (acpi_pstate_strict) @@ -640,33 +640,31 @@ static u64 get_max_boost_ratio(unsigned int cpu, u64 = *nominal_freq) } =20 if (boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_AMD) { - ret =3D amd_get_effective_highest_perf(cpu); - if (ret < 0) { - pr_debug("CPU%d: Unable to get boost ratio numerator (%d)\n", + ret =3D amd_get_boost_ratio(cpu, &numerator, &denominator); + if (ret) { + pr_debug("CPU%d: Unable to get boost ratio (%d)\n", cpu, ret); return 0; } - highest_perf =3D ret; } else { - highest_perf =3D perf_caps.highest_perf; + numerator =3D perf_caps.highest_perf; + denominator =3D perf_caps.nominal_perf; } =20 - nominal_perf =3D perf_caps.nominal_perf; - if (nominal_freq) *nominal_freq =3D perf_caps.nominal_freq * 1000; =20 - if (!highest_perf || !nominal_perf) { + if (!numerator || !denominator) { pr_debug("CPU%d: highest or nominal performance missing\n", cpu); return 0; } =20 - if (highest_perf < nominal_perf) { + if (numerator < denominator) { pr_debug("CPU%d: nominal performance above highest\n", cpu); return 0; } =20 - return div_u64(highest_perf << SCHED_CAPACITY_SHIFT, nominal_perf); + return div_u64(numerator << SCHED_CAPACITY_SHIFT, denominator); } =20 #else --=20 2.53.0 From nobody Sat Sep 26 11:46:48 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6EE04A6CFE; Thu, 24 Sep 2026 16:01:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790265665; cv=none; b=YG97wuc3ypU35vWV8+iTt+XlT+FFI5Ia9t3W7a5ziaasi3dfWCoxypCCxA2ZCgIanNQLiNWvbO3QXT8jIA6Q1sMYz0qEC8g7aUDnihOG1NE+paz8dxk7L7hGxjFj0mSu4lmvMM8iVGjSyW7GwyrctHD2rDY9hGdcD7i0Ow7Pe9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790265665; c=relaxed/simple; bh=Bo2UGHOYNYLWF9uIzmRC0ZazwugY4B830c/mPkLPNZo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b9AmQxdH1O+RPxRkBMnmItXDkksHU8dPAd1+Qbuybfjgi9qqcZCIr/YqxoCyWUAD8pFyGxfyl/62Yoi8QZUFZWUZlQRp/hf3eG07jDcvZm+LbgYzTKmr353yiuBYkrJ45CAAtnW6FTX1mqsKuQwJkiZLTANmKrhpeZVGbZJT9Tc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EgNVmBjm; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EgNVmBjm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 292391F00893; Thu, 24 Sep 2026 16:01:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790265663; bh=LK4pmZuRDKEBTXXexxgFUW4f2mz0iU8rh4lCyzxrJVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EgNVmBjmvusupVvrrpoqlf4g9GmEf99gYZclehKG69Q0l//nphw7eDfCi2b0ILgHW 9nxioZdk++JKV/NRZeDmG3FYdO7MXog9FKXxX310lS3n9eosuTYTdDs1GxubQjR5IP 6kGL649rwdh59IdyyCnC3jisd34b7LCAKeLT7Tn7SsY3I5qhLAiA7K2pH6z2e261hU 9vKKIMmeYvpDF3EM3H8qig9/gXvGJYAvomsmJEFW+uHlT0KD25q21kC3rMCQiVAQ6f L9FA6Qb+Hc0zZlpUh67dquybwuUTj61z/9LfUe0qh5YgKdzxx8d1ZvBAoI2W72fUJe XOwv4KDvQ7Mnw== From: "Mario Limonciello (AMD)" To: =?UTF-8?q?Rafael=20J=20=2E=20Wysocki=20=E2=8F=8E?= Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, K Prateek Nayak , x86@kernel.org, Mario Limonciello Subject: [PATCH v3 3/3] cpufreq/amd-pstate: Get Highest Freq for a CPU Date: Thu, 24 Sep 2026 11:00:52 -0500 Message-ID: <20260924160052.2858456-4-superm1@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260924160052.2858456-1-superm1@kernel.org> References: <20260924160052.2858456-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mario Limonciello If the highest frequency is known for a CPU, use this instead of trying to calculate by linear interpolation. Signed-off-by: Mario Limonciello --- 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 496e0342c1c90..2a0cbfe21a67d 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -1102,8 +1102,10 @@ static int amd_pstate_init_freq(struct amd_cpudata *= cpudata) =20 WRITE_ONCE(cpudata->nominal_freq, nominal_freq); =20 - /* max_freq is calculated according to (nominal_freq * highest_perf)/nomi= nal_perf */ - max_freq =3D perf_to_freq(perf, nominal_freq, perf.highest_perf); + /* try to look up from BIOS/quirk first, fall back to (nominal_freq * hig= hest_perf)/nominal_perf */ + max_freq =3D amd_get_max_frequency(cpudata->cpu) * 1000; + if (!max_freq) + max_freq =3D perf_to_freq(perf, nominal_freq, perf.highest_perf); WRITE_ONCE(cpudata->max_freq, max_freq); =20 lowest_nonlinear_freq =3D perf_to_freq(perf, nominal_freq, perf.lowest_no= nlinear_perf); --=20 2.53.0