From nobody Sat Sep 26 13:50:17 2026 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010023.outbound.protection.outlook.com [52.101.46.23]) (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 3B14037EFFF; Mon, 31 Aug 2026 19:45:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.23 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788205528; cv=fail; b=MD5mB160bX+iEOg+YT3Qlacm4SWGG6WarxB+peF7x5L4rl3k+PER8PFPs6cy+ZjjbJU3TsvdQauZayHRlLMfEDHCd6Aeggg+K7QPYzfkgyxzsxX3CJc5gjR+nGzVOJ6GYM8YGLBMi0ZZqdXcPCioR5OdyTvtMPlsCcqdpBE81aw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788205528; c=relaxed/simple; bh=4MzXrFmHGvQ9brGxAKdwRCg8IOkPWgAg0tQSXU/EPKw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l5/PohwwV6aGood7ZnSRdQBMdS9rPVsdmnhz5Q9Q+6G9LNHWb2PuqLxwLrjaD2jkdO1r8QtL0hWjKa4Y7gBSFhU6qR+cB2MZJaeCdMdMrJfsu6qnEkglLcUdBqjvdLz3XYfOXaGqwKQTipE97YdBJiIcGuqJM9h4R4jljn9fqW4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=wXczdDif; arc=fail smtp.client-ip=52.101.46.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="wXczdDif" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mQVcbqTcq/IEVvbM2lSBg0wPaqYnHuHTq7iKGqPtg/VN0sPO/9EimUCt0Y+WoXQfChn5O7dLLU0fXLs7kw0SLIbXQW+te2SeVky+cWw2uFgeGtwSmpjKnIXOARZ1rVF2TvvM4ESWDU/NoCw95Idm02DFZOA7Qx9UvK9fZ6iBEFnztgpwDgWNMc6SiT++54vDCiYExW4mmiWBHnI4tZ5nKjgBxlO8FNKazrZK+R6opiojiBd6lpjdrnvxiFo2OZsGY42/5VmFXOFhyx/RTfmlJU892zNZSI815VkdrjUkewj+Xm02fjReOknYy7Fa92G5AYW/JHQlfEtwL8pvLb3VOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+Rq4FVKvryYH9apzkoYSEEpVs9+Q3IcVxA0hfEpiT60=; b=B7/IyxSADVX+PiFtm+VW9h3j6Z9QZWT2IIHrg3EQ0Q+Hwoy/QO7UZjHvuIsVE12s0GBDzYzZXSG8LhkkDfFm8k60S4GxsvwJRH3bfyJP6HhaLUpDID+pPzpXB26FNBY/T06iJowQNwgUayzv7h2mhqDAL9fuOAuHSJkZw4095XfgDWVmzAgr9jar3flXLux7ETnpaxcV99JvTsW8q6ECdqOw9HEXKgyiffbuzNpT71nvIXp7d8E7Yda1pRR+jsIr7Q4pNiB5GLCeCV10eizAeM+0R6wNJErd3GOg1otsxPdEGtI//o5vKEOkiT+jcpBiY5UwEWoWm2m+h3v2e4o4Ww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+Rq4FVKvryYH9apzkoYSEEpVs9+Q3IcVxA0hfEpiT60=; b=wXczdDif5rkLiDIoQkUY/2zxNlsGXuFW/RhbIfQ2NGTzJLohVF4WozKEkWgYHFeNnEczaXZimxEEtC7uJ3N6cUPIoHKp35CU0QiYjKF1DdkceLQkf0VOmZ7sNRnZrV1wmNBAGQ1Kh/BInz4g64gXF7e5YWxDu9205l6E+EuJOnY= Received: from BY3PR05CA0022.namprd05.prod.outlook.com (2603:10b6:a03:254::27) by SN7PR12MB7853.namprd12.prod.outlook.com (2603:10b6:806:348::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.13; Mon, 31 Aug 2026 19:45:17 +0000 Received: from BY1PEPF0001AE16.namprd04.prod.outlook.com (2603:10b6:a03:254:cafe::a) by BY3PR05CA0022.outlook.office365.com (2603:10b6:a03:254::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.382.10 via Frontend Transport; Mon, 31 Aug 2026 19:45:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by BY1PEPF0001AE16.mail.protection.outlook.com (10.167.242.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.382.8 via Frontend Transport; Mon, 31 Aug 2026 19:45:17 +0000 Received: from aus0006770c4n-lx01.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.46; Mon, 31 Aug 2026 14:45:15 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" CC: , , , K Prateek Nayak , , Vishal Badole , Mario Limonciello Subject: [PATCH 1/3] ACPI: CPPC: Refactor boost ratio handling Date: Mon, 31 Aug 2026 14:44:26 -0500 Message-ID: <20260831194428.2287055-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260831194428.2287055-1-mario.limonciello@amd.com> References: <20260831194428.2287055-1-mario.limonciello@amd.com> 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 X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PEPF0001AE16:EE_|SN7PR12MB7853:EE_ X-MS-Office365-Filtering-Correlation-Id: 652472e1-3c0f-45d1-cddb-08df0798623b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700016|82310400026|23010399003|10067099003|11063799006|56012099006|3023799007|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: IAXdcqqXINAjcOjd/z28yaC+Dr5Z9Uw4KtCrEXMwhNpswJmcPxvdLjsFH8iFxcD1lqu5zxpk7nfluZ88UKqimZLAcG/ImoUgeFnbIowBB+KlO7H4tE88iHMtUaPfxulOyDa5hxNtMH7+H2GYSkoCSEosoMHt4mDxw7/OLcuyppa1KCGeT+fyf/hBll9fK49AKCjGfE6+S7KwUXbbVVu19KGGGsWc5x4m0LXCWP3BZumEoWM1ASkGE3KjX2baUvRCVg0NTx1OcU157EnnpYKy2ikBAOvMUc9rpVPcWgSSxLgagSRUCpnOuH1y8sv6OxFqFKnIDdkP/R+bGk9refvMXsvp5c1GWwzM5SFVlHF/xv8FSbEWMCZdcEPLEqcnTXWxI6oTzTp8Et7V8rLFNK1XlYVs+IYFvgMxGyhZGK7j2cwZ8oCDeUipd3gJHx8nI+CjPF2K1B9ZS08INyQfrhm/3Mrer1riUgfGC5zkIP9f72+zN8q/M4ysbj1hYZh1ny8vrhJaRyoiMbN7F8qz8F6zvoLnJtJ4FcwrkGc/qZihNkqW7wGgw+KEQ5EPXQJGTF1M9/huo/USXOQY0YOvy12bImbWiFFaqlezu7+9kLpxiUJjNNumBqmoiK4hlL1TibgPKFOWqmSSK+yP30lvCfkmTBr2e7k755NNszatdDFkAUWV1YnC8vth5uP9papYPJxWhNp/Aq/VoRpxyyWcyB68Rg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700016)(82310400026)(23010399003)(10067099003)(11063799006)(56012099006)(3023799007)(6133799003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nTecr9sqqSvROgLujZrhf3Rsds/4+8YU5ZxxOvcptnjYYz1ZK3D36d2FHctbnAXaJWJSHJofav7nUsqljeK+Sy/ZkuauaRNPAHXJkN84TlUFSTQNXypjV7Pen0UXrXnOluVo8o1/ed/cpMpLpbXiC55yqmJ9Eai38DxcNlN+m4WtVNAXN9MqvepC/55eGBaGGAthgsaJ8m2K5kZBZVtof+yF6sIwlv/+Jg+L0YGtYTRdltoRzV5H9G+ePM8QZlbr14XhMSLpvbxxmtYDq2v7eW9X2EZOjmDTeqMyM769cHilpSsAVI+51oq+J8IaZ9Lf+Zk5jr5A9YAkrXf/QfD+MBnto8LkBUxyrGCX60udRrvn7SrMcdyniQ0NMYzZe83YwpE6++/JeElHN5vpt8Pb0cGxWPg2opj+am75x2czAXKcwEwRe2MJdD0SCZ6IC9cy X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2026 19:45:17.3661 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 652472e1-3c0f-45d1-cddb-08df0798623b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BY1PEPF0001AE16.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7853 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Mario Limonciello Tested-by: K Prateek Nayak --- arch/x86/kernel/acpi/cppc.c | 174 ++++++++++++++++++++++----------- drivers/cpufreq/acpi-cpufreq.c | 5 +- drivers/cpufreq/amd-pstate.c | 14 ++- include/acpi/cppc_acpi.h | 14 ++- 4 files changed, 142 insertions(+), 65 deletions(-) diff --git a/arch/x86/kernel/acpi/cppc.c b/arch/x86/kernel/acpi/cppc.c index bbade0da5130f..78b32bc93e603 100644 --- a/arch/x86/kernel/acpi/cppc.c +++ b/arch/x86/kernel/acpi/cppc.c @@ -10,6 +10,7 @@ #include #include #include +#include =20 #define CPPC_HIGHEST_PERF_PERFORMANCE 196 #define CPPC_HIGHEST_PERF_PREFCORE 166 @@ -81,31 +82,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); + rc =3D amd_get_boost_ratio(0, &numerator, &denominator); if (rc) { - pr_debug("Could not retrieve perf counters (%d)\n", rc); - return; - } - - rc =3D amd_get_boost_ratio_numerator(0, &numerator); - 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); } @@ -225,35 +213,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. + * amd_get_effective_highest_perf: Get the effective highest performance v= alue + * @cpu: CPU to get highest performance for. * - * 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. + * 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. * - * 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. - * - * 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, @@ -263,8 +246,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; } @@ -272,28 +254,108 @@ 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; } =20 - *numerator =3D CPPC_HIGHEST_PERF_PREFCORE; + 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 __initconst =3D { + .performance =3D 5025, + .efficiency =3D 3524, + .low_power =3D 2399, +}; + +static const struct x86_cpu_id amd_zen6_client_ids[] __initconst =3D { + X86_MATCH_VENDOR_FAM_MODEL(AMD, 0x1A, 0x80, &max_freq_zen6_client), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 0x1A, 0x81, &max_freq_zen6_client), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 0x1A, 0x84, &max_freq_zen6_client), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 0x1A, 0x85, &max_freq_zen6_client), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 0x1A, 0xe0, &max_freq_zen6_client), + {} +}; + +int amd_get_max_frequency(unsigned int cpu) +{ + enum x86_topology_cpu_type type =3D cpu_data(cpu).topo.cpu_type; + const struct x86_cpu_id *id =3D x86_match_cpu(amd_zen6_client_ids); + const struct amd_max_freq *max_freq; + + if (!id) + return -ENODEV; + + max_freq =3D (const struct amd_max_freq *)id->driver_data; + + 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; + } + + return -EINVAL; +} +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 > 0 && 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 d2b4a8eba3052..9fb1d7150c356 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -584,11 +584,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 @@ -619,10 +621,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 94a6277edab27..4c0b11a718e38 100644 --- a/include/acpi/cppc_acpi.h +++ b/include/acpi/cppc_acpi.h @@ -192,7 +192,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) @@ -305,7 +307,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.43.0 From nobody Sat Sep 26 13:50:17 2026 Received: from PH7PR06CU001.outbound.protection.outlook.com (mail-westus3azon11010052.outbound.protection.outlook.com [52.101.201.52]) (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 DA5B33FFD; Mon, 31 Aug 2026 19:45:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.201.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788205525; cv=fail; b=DZAIQhTSgl2ol0hx881jXgi3SwywpsEgvsUfvgzqAu43KS7BX3vPNXDAFn080SzwZp9qIX1yfUjCbyEc5IGkL8LZeKDBRw1eGjKO+/F5/y2MTMxbDR4ts9cJ2P+l235Pk6OG1mvPYVFGn8zgygSTK0DMCEoIm94beG+6D+o3AYI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788205525; c=relaxed/simple; bh=jaf2OZrz6goSaXYh9O7m7a41gzvNHur/SKLKuIvqRAc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OAvDqQ+FisqH/jd6TiCFFvJXX4BDDsmcrfqRhiaNf1L0s47wHEofc6Rf79WHSGjbEK9YJlbtEgUz3qcx0ABnNKfjv2CEgEiul8DR6wAXNy4F1nR/Sk754QXUztoqE2ClhT0pE0CPAR/7A8QH3v3HnZsaoDOp+ZNSXUBSCxkF1DQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=G+pgStqt; arc=fail smtp.client-ip=52.101.201.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="G+pgStqt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XiHnLJTi1U6Z9enuLr0eb7X+hkmX4b7NELYXWVurnjBGd+4Wy6Zp8AU57yNyAsb51/C63aAS1+zI828zgPkdC04AhWsC6F7IwA00zkozPyYcStFfx+aI6aWHbmwME/XUk+F2ApeRiPrd6KlCd3vguFOZdNfhh53irIVE5LfSJdvNvMOGOFSRAw2FxHs+/HWGUgFQk/zqumnKk3g/4AYrkm4ZMw/S1GNugIISDh6QAJfR+pItcSx2dH7xCotax7amf3Jmh+xy1fu8ToOqpkQ7PonsRk98MrknYgkSrfpV/jQ9XH9lpVSoh8+jNw7XF5l93fucOzheYKHI25KxQBflJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/170WNqvzSQxQ9u4vl2fD+LLwjr2RfDr0kuTJ3hlnAw=; b=NuRN5HKaN3f7fyTS4H4BZXiC02ZPGAyvGzSJxC6ye1r1DIrGjNq0PAymziv6dYXOBDfx3FgiKpGItDAIRxJxbLZEArRVf0EMwyUI7BxjYm9cY8+8Cbcl7ofoa6C9FdoSyE1vGy37hUDVCrtPvNv4OKeMRBpvNSrJONJvWaN4hYWaUXQKEc5KHpt9F8d3H3Wgsdyuhaxr8gF7oB6PhWdc17C79NtYBKbLr9JDcAa8gSPP/eNoEC8VMJe8kocaWn6S3cbNO57HxQYtz3dSzRLaLVBF5yZrzOqHShFehK0l1f48JVkoHs0IWqvxLD0GoppxX12kIuDqhqzQPF1KqTRbbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/170WNqvzSQxQ9u4vl2fD+LLwjr2RfDr0kuTJ3hlnAw=; b=G+pgStqtDMrptKZ/Ex61MaB6X8tz2vJgyZSwZt4bT0PCYUjGpPzQFFXs8khAiwOsBeyHqEAqIWGAVy+lMHXB03XRhnf38BQuaHUaEcBbvRZ9UwcY0A/IyccTIfoIiu8faBeZgYxVHaXBgYgNGFYmZh/Rg3eGG/TzwdNlWzQLlRc= Received: from BY3PR05CA0015.namprd05.prod.outlook.com (2603:10b6:a03:254::20) by LV2PR12MB541025.namprd12.prod.outlook.com (2603:10b6:408:3a5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.13; Mon, 31 Aug 2026 19:45:20 +0000 Received: from BY1PEPF0001AE16.namprd04.prod.outlook.com (2603:10b6:a03:254:cafe::1c) by BY3PR05CA0015.outlook.office365.com (2603:10b6:a03:254::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.382.10 via Frontend Transport; Mon, 31 Aug 2026 19:45:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by BY1PEPF0001AE16.mail.protection.outlook.com (10.167.242.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.382.8 via Frontend Transport; Mon, 31 Aug 2026 19:45:20 +0000 Received: from aus0006770c4n-lx01.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.46; Mon, 31 Aug 2026 14:45:16 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" CC: , , , K Prateek Nayak , , Vishal Badole , Mario Limonciello Subject: [PATCH 2/3] cpufreq/acpi-cpufreq: Use amd_get_boost_ratio() Date: Mon, 31 Aug 2026 14:44:27 -0500 Message-ID: <20260831194428.2287055-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260831194428.2287055-1-mario.limonciello@amd.com> References: <20260831194428.2287055-1-mario.limonciello@amd.com> 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 X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PEPF0001AE16:EE_|LV2PR12MB541025:EE_ X-MS-Office365-Filtering-Correlation-Id: ff4ff54a-c7b1-4a23-d95a-08df079863fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|82310400026|23010399003|1800799024|376014|18002099003|22082099003|56012099006|11063799006|10067099003; X-Microsoft-Antispam-Message-Info: kXSHlDhcgKN9xqHhiia14EzGVkZKpD7cKpFt4MY8OL18UlFPJrw8VeXoxdhLTYAXPAwwahbCTSJp5Xg8ydwyaCgYA2ikt2TdY/TlnFmjpJE22Z+BE2USXQEE4cDTQb/1kAbtdcrn1jCwXKkG50lVL2li5ajMbucnFRQRQrmc+klzNj9CWD/eE1KJjCpBebSJw1orICgDh9fNkg8kGYTcN1REtGUrjcu4IJ5DSfdNsyNrMGs1nhj6gbLqV5Vo84Q0tIJjb69rShBl6LLOuINpNVEcihwNHRymSo7c3kwG6b5g8l03YqmxJ8Vdk6JxkwNQn0A1HgUCiP7Z83WgJ/McMFd+nBJv1dghj2ZlRRn9MEmH8Z3UPjOVBVbxSstkbSBVwJ8NlwKL0qSQVYBjmESGHVkL/9PWl/s0UxFLlV/PrFo5I/CgdhZgPfhAkeo2yBhK7jUcdtCka3WMlfsK82aJsIg3seu4w7CS81mGcDuHsxs+H/xv7aKrd0Ub3dV3JALEhAYFyOuMYw6JNPcPXVzkbF+3l9bLkDhDFecWCXBQEKltxLN9fWc+rWlGQ5q4tOFM3692evF+Ge2eqQD8KF11v06qVkBFGhnN2QrkTWuH3tKP1AVznb7y4xu6JrUZbtn46VKz1RLa4OrRV1Tbo4DC06w2/XUhZFw0hKaLnicED2qFeDbxbIYQoTR6w2ygnO29LpBam4wZ5elhv8+Mjc91iA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(82310400026)(23010399003)(1800799024)(376014)(18002099003)(22082099003)(56012099006)(11063799006)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: REzdPUAEBEyxUgjNPQgGtfnSVrrwYEKtrRUDEJp7hwiFN4tUFmGhxehABi4HKyQcmA4xZYYLkRRawQSsU9cwN1pIZghzMEgvXjF5j7G+dzsR00ejCOTybihUtGW6Jc5zGTZf+DxLU3yEYxseizvE2E9ju4mZEYvbUKvuGrkns0yQVbARo71C3rOOTvAS1Hz5/d8cewMgF3IiNz41OkETgGSNHDzYE1WNkwHGueUEll1btep4TQR6YBGdZmJ5AMidxSN/ro0Rnro/WukYF0QvEOiu7vy6Hy8/gfZ3M/4enIhWXuHPGEOVaiLbtv+JNfpC/57axgxf5J/OySKMs7oB815XzwXqGo7efHg1sBA18i3f7oskHEwfFA32/KvuRZLKJ6j1Bv6lNxslVRtyuCLC2stgHJzP4X/no7L59vs7p7Qa1Izqy4slGQSRyeOt9feg X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2026 19:45:20.2551 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff4ff54a-c7b1-4a23-d95a-08df079863fc X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BY1PEPF0001AE16.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB541025 Content-Type: text/plain; charset="utf-8" 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.43.0 From nobody Sat Sep 26 13:50:17 2026 Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012013.outbound.protection.outlook.com [40.107.209.13]) (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 A10DB37FF75; Mon, 31 Aug 2026 19:45:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.209.13 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788205537; cv=fail; b=D/0OWEGTWo4AFDGjHLQlinhb9x2AhJ9YIuY9pPa/gG76i9fl9UOZeT3jFU2ptm3vUKeNriSA45q8RNzwXb8ZyC3FFR4WIkXZqOYiXOkCbSLy9hS5W3kD/8UBU0A+lVsNeT39Xeh4NGxgXxvuhB5A/nS3L6YGGsZV+/SZ0AkHNqU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788205537; c=relaxed/simple; bh=vJO/zftZgf7oNP6u9kjDmJa/WP7MqRI/HEwMX6mkg9g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VAY3hBQPA5wrmGfQYs7s5+Kvhz6p6NnE4RwPmFCiX/7KSgxQ+eNjQSwQ5KvbiAUtMg8SOeB9gpz39KSF+aoAG0SA0f/Rhou1VOYIP+rAQrPOLoIuXm4k6bj+CeVvjeZHGdL61iZsphfy8mDn58Hk66FZ3jagRIXkT4kKSoVK67E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=zux8DxTS; arc=fail smtp.client-ip=40.107.209.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="zux8DxTS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NUkN3zZ4s9OkhUtVay0NmruXi8ooMUUvU6sFFzNe7Ugze2c2EmOb1J9D31tz4uTSgikpO3J4sqfoNvfQRnIJPf6S1oYaPM0RZroyRgbOUIppgHTjcGuvE61dkErS7oo+H7kKaf+oVVQhlzLTD4xVZLAUo5pgGTduckzY5YVAqYiOdHKG2UvlZQscKzXSDvDwC/022oHuvDH1jNg2sf/B0rGYtu7fiqEZSnDMvU0/WgHPV961T1VdIw0XaPSaWtKL17u0n2O5l4W+6hHEv7wzEzQ678YOyQeb/MSJRj0axMDuK7wcm19pereuhzDNWXtnswIHbTC/r1UCkhgfw0T6kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lyEbVI8HfK57V6dyt1+EXs+JiM4mL+r2N2mdPeJPSUI=; b=OHGMdASiNJH+VZQaz8aqBoDC3pCxTon9uYLa3MY8JVk0oxV9xv+ZPAjP1FTa4OHuOuzaJCM3Bd1AKzcXklVRDZ8unJmEu6ZFZLOIcRqy74GStEBIW8GN3a6LixKFbVIHDFTWg7lT43051bMPum9gB3AiBxh+il9DjCWFV8htiDhzf0SUts3PNz/hJBOLlSISqk36B+DrDuNmNosbH/QvZSl32JQhPVaE4hmMf1RVInk7UZeo7jejxE5+k8zjSx+tSn79tte8YRbzE1AvXgjHEM08bjXBU/KZFZaD9CFWIOEnfLU3888EKQGkk20iG+bf4l6+krSa73GmnepxvrV3Lg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lyEbVI8HfK57V6dyt1+EXs+JiM4mL+r2N2mdPeJPSUI=; b=zux8DxTSAUFRc0jXzgUpJIkGA86hPVwfUx8Ec5UW5HmAtuBHVY0BJ18AC/71sBhOA742qihZK2IYh3DXFO8iWfKr6MFeP3edd7pdhfDNnI3RW56zQS0dmYErVcjMNlnykLYo4qe/p+iYTlvhJ9jX8k9SqTwoPEup/lEVn+g+ISY= Received: from BY3PR05CA0008.namprd05.prod.outlook.com (2603:10b6:a03:254::13) by MW6PR12MB8897.namprd12.prod.outlook.com (2603:10b6:303:24a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.6; Mon, 31 Aug 2026 19:45:24 +0000 Received: from BY1PEPF0001AE16.namprd04.prod.outlook.com (2603:10b6:a03:254:cafe::30) by BY3PR05CA0008.outlook.office365.com (2603:10b6:a03:254::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.382.10 via Frontend Transport; Mon, 31 Aug 2026 19:45:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by BY1PEPF0001AE16.mail.protection.outlook.com (10.167.242.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.382.8 via Frontend Transport; Mon, 31 Aug 2026 19:45:20 +0000 Received: from aus0006770c4n-lx01.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.46; Mon, 31 Aug 2026 14:45:17 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" CC: , , , K Prateek Nayak , , Vishal Badole , Mario Limonciello Subject: [PATCH 3/3] cpufreq/amd-pstate: Get Highest Freq for a CPU Date: Mon, 31 Aug 2026 14:44:28 -0500 Message-ID: <20260831194428.2287055-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260831194428.2287055-1-mario.limonciello@amd.com> References: <20260831194428.2287055-1-mario.limonciello@amd.com> 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 X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PEPF0001AE16:EE_|MW6PR12MB8897:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d5f9019-8946-4d7d-4378-08df0798646e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|376014|36860700016|1800799024|82310400026|10067099003|22082099003|18002099003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info: vOJK2GrYKnlueNmUsLl03EYGJiqeQeBjoh54K94YaWIJFinNbmayOyfprZ54fXCVofiizFPIr/EcZCPZS8AcRNUJJw5bdgxwP1u0babitoJZBvJyJQck9frOepRV6A7Q1pKhizBWWv+2ivyX27cz9arlrslNAhJHiwYZZ/queBmmwiO43Q//CaJroqNf0jvjuh/wqRmVS3PsUnf/0Y4s5IKwW7N4mAMollZN1EznijMoCIInQSydYC8TQBUw0+I7YwOuaRNl7vqYjIwSY5mNftPh2BGgtlCrpNJUmZGsWwQB35y6b2DzfTCUOOWZqJ+rOrxY29iXq7xfEzsLAPh/ZtfIG3AzUTBZY3aE6BkgXiUK2LOKF8jN5QVtB3OqYKzJyqOqBbsEUM7gnolrR4NQHUgePCYK7DJu3WzWPH7TZEwx8Q15JEGZVERTsppuxnboLuvkCiYO+kclw2Ev7c53UKQFGKy0pXJKgEs4unWQC9NQlg8I6Dt458iMj33ezIrE2PirfLKP8pKoS8xiuLFS9r96SUy4GfxURGHX99VPFHlFC5On5Rg0QMUoiZI9AQpo6CyMdG04PKPih77NQqohX7RRiR0LxlEzVEBmoBX08MAr0j/jSsDAhpGHeUSZpBFdHl+Sp7k45NnSYDR5I8SOi6X/waUElC2uEhVKmGrzpQV/PVbIcjft1M1lvbEzGyXmL1h0BCLBTmFYuhNV6FsnMg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(23010399003)(376014)(36860700016)(1800799024)(82310400026)(10067099003)(22082099003)(18002099003)(56012099006)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SC8ef+YbrX1qHsq3mjxxxBcffVQGk5WiyDtbdhAwgVtextBXSOoPbXq66QOh+6qowlNGPGRNAQ1svwYpvAaxB5Y1xJb/L1Vw/7kJAEYIRmELfZ8noHbjEkAdP9IvvrNiYNyw3aZt8FH1frSSFzyuJg/apAcWcS6byGEo2tu8xpIOmJAIH2tGn5gQWW/aTFKAYDzJ/h1edPYptlV/oKeGh+MDgNQ13OeX4L0dsWmpOPL2OQNWgjJ8/pBwUFz5o1Mp0YQCHgjeOmIOsns8URe/Fg0WgCucw1krMg07btz+HghxXYG9ZOhZqPkGKYEILG2xMh9pqr24FjABz4/Miod+X/EdHGc9VcFXRb0+FXdYjK+IehKoGvebN0JElQMK72WmmjQIUmFHgqW/a8l7nuFMXfYra5vq/GouhKXkqrHg1suMAQ3nJjE6WNyzo2R1rWp6 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2026 19:45:20.9998 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d5f9019-8946-4d7d-4378-08df0798646e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BY1PEPF0001AE16.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8897 Content-Type: text/plain; charset="utf-8" If the highest frequency is known for a CPU, use this instead of trying to calculate by linear interpolation. Signed-off-by: Mario Limonciello Tested-by: K Prateek Nayak --- drivers/cpufreq/amd-pstate.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 9fb1d7150c356..a71f82c93c345 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -1107,6 +1107,7 @@ static int amd_pstate_init_freq(struct amd_cpudata *c= pudata) u32 min_freq, max_freq, nominal_freq, lowest_nonlinear_freq; struct cppc_perf_caps cppc_perf; union perf_cached perf; + int max_frequency; int ret; =20 ret =3D cppc_get_perf_caps(cpudata->cpu, &cppc_perf); @@ -1131,8 +1132,13 @@ static int amd_pstate_init_freq(struct amd_cpudata *= cpudata) =20 WRITE_ONCE(cpudata->nominal_freq, nominal_freq); =20 + /* max freq came from BIOS or quirk */ + max_frequency =3D amd_get_max_frequency(cpudata->cpu); + if (max_frequency > 0) + max_freq =3D max_frequency * 1000; /* 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); + else + 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.43.0