From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.85.23 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796423853; b=l/jpEptkeUsgWAU+3VBPYm2WfvfORflMHOAFfCSQrbrK+JLLEL8SdFCLGFmfEI/rOImJ PRjJ/bip95G3rEFuMBKuRQW7hgipfnv4PmpklfceImmmpjQKV95dyIChlsZVZZYVep4Cr kRBxCA2xbepLKFokcOO7E+qtG/gKWxo/o4oxwhXbGkF+Y0/aps7t3AMBWyYCRBic1fV7K 7fE41P1+2+7ciEu/fPka/unfIoGQpORGp8BMxGg4doqsMUiYP4TXXIvKpQlj45jscY9HU c2kqSD3SH6CLoLk2a9U0CoSO2c/hIKIofIg+gcMwokSrsUBRxz7czJJBacIHhTpDlvg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796423853; h=DMARC-Filter:DKIM-Signature:Received:Received:Message-ID:Date: User-Agent:Subject:Content-Language:To:References:Cc:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-ClientProxiedBy:MIME-Version: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=MdxmiiP3tUz70MKTbsstxGpyqAlxiHKGK8pgNFVEo24=; b=Dg1Soas1+sVsGRBk5Tn/8/a8qmZODl+5Zx2fEB/xfSdeYMud9metKFEKJFvETRWqgIm9 zdGWXVIrx3qFzDbzwpH3rk0+L+LKvXM+uMSZbRh6ms/8sZ7nPQIn8F8/M/Slrc9vbE/TJ nkrx7sd1DWNZoQ5DjXMua82bm+YHFXCulaX9VtAlNCYLi7F6eePrEa6f/n5IxDMkRxDy3 K3wyZPvBdodoQHwGjB+7DxseFdwB0dp7mvfd9PmqtJVli+zrNRWmhno8b2cWJd6lqIIVs Dl3H9xBBeFarved1h+PGdUAnUaU/lwJ+DUxjd5Jcua38BMOg9JzWQW2Dw9nFvt1H9Nw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=U8ArTgWY; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.85.23 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010023.outbound.protection.outlook.com [52.101.85.23]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A8B7606A322; Fri, 4 Dec 2026 22:37:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7A8B7606A322 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, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=U8ArTgWY ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=g/yf9JI8s1hQ6719f0xxiZer3CRipEmntKHC4mnyIQ0lqv4I5Uc3dBnjRLmFZjxwnRPunUihCrDM53dzK24opx7NtaAz1gldqQ5BMrIhAMstSL0As/3dNLylzIMnFMUllaAwQP5P4e/y5RprSRRf50n0gFVhdGEB8uglnamoizohB4fJWi4NyvAV47dzPWsqD3ZyUp7Z/b1PSZ1CWzgw23/A7ICfV1YAqDVYYxTYIQ5CToo6tJmqJdKW1Spb6eljEhd3jQqKEkV6win/8j4C8g4OHY9yIuxyXD+9drIK7N+f/Z0GF1mDe2rC69mIeIYuXJFho+QzocuDY3yKa3DhUw== 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=MdxmiiP3tUz70MKTbsstxGpyqAlxiHKGK8pgNFVEo24=; b=KUTKRu054hxGaVFVI+pX4UODd0lwNPh2aSdRnD+O5806DUrnlraW8pWB79YVodPD76+c8j5pvY8sf7DSXLf9Ix7HiO1hmPlwqJ4uraiG73S2ak4DNYwsvNB1ZME1Xbd8DGlbU6BPnRd6/PlmizO+4aD5JsrxgxLEqvLqxcK7zTekalD36fAFPrwn2nd8FMoFGCNXyanZoGP25IHsNdXWZpd7tQbX2ZeFuUXaJjSU7lazjIphSykE/s1aOYiKIUn+W2eQXEQooC9KDRoqF2Lo4pnq3cmDzxeJRwTvNCD6GpqQNRlgcumJHte9ZLA9ymRuNBHdgPc0RMkQVYAb1AG2Kw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none 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=MdxmiiP3tUz70MKTbsstxGpyqAlxiHKGK8pgNFVEo24=; b=U8ArTgWY3Qzdvmo4LUfp8sOoBvg1sYTeeH4DqCfAlO0QjAYXPIsHrTwU/IpyPRywTCsRLe6C+rvC+K5LIlJWunptSfSN4eVVhYo/HYyi2Lrk8SPI5jl30pcHxk/v2zky3cATrz+m4rhDXJp5xhgOQHHDRPjxXwIHb7vuTrQUHd8= Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from PH7PR12MB9174.namprd12.prod.outlook.com (2603:10b6:510:2ed::9) by IA1PR12MB6018.namprd12.prod.outlook.com (2603:10b6:208:3d6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.13; Fri, 4 Dec 2026 22:37:27 +0000 Received: from PH7PR12MB9174.namprd12.prod.outlook.com ([fe80::eaaa:b430:ba9:5dc]) by PH7PR12MB9174.namprd12.prod.outlook.com ([fe80::eaaa:b430:ba9:5dc%7]) with mapi id 15.21.0688.011; Fri, 4 Dec 2026 22:37:27 +0000 Message-ID: <2064094f-e522-4937-836f-6a5ef1311ccf@amd.com> Date: Fri, 4 Dec 2026 16:37:23 -0600 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/3] cpufreq: amd-pstate: Set asymmetric CPU capacity on hybrid platforms Content-Language: en-US To: Vishal Badole References: <20261204132715.1668516-1-Vishal.Badole@amd.com> <20261204132715.1668516-3-Vishal.Badole@amd.com> Cc: ray.huang@amd.com, rafael@kernel.org, viresh.kumar@linaro.org, perry.yuan@amd.com, kprateek.nayak@amd.com, hansg@kernel.org, ilpo.jarvinen@linux.intel.com, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, lenb@kernel.org, peterz@infradead.org, ricardo.neri-calderon@linux.intel.com, x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org From: Mario Limonciello In-Reply-To: <20261204132715.1668516-3-Vishal.Badole@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: CH2PR02CA0006.namprd02.prod.outlook.com (2603:10b6:610:4e::16) To PH7PR12MB9174.namprd12.prod.outlook.com (2603:10b6:510:2ed::9) X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR12MB9174:EE_|IA1PR12MB6018:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c3376a8-6542-4c3a-ef52-08df52572c95 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|23010399003|366016|1800799024|4143699003|11063799006|6133799003|261009223027099003|261009221227099003|18002099003|22082099003|56012099006|10067099003|261102130727099003|261026121527099003|261022105027099003|261021123027099003|261022075727099003|261026140227099003|261028144727099003|261021121427099003|261102123227099003; X-Microsoft-Antispam-Message-Info: EagS/PULdNbkOzh1zzApfLJeDLVQzRyStHDssyxNw+kdJ9uLt7KuT7LK6LMTR2M6z4Xey0IYUn1BzlxGPGlLRnMNlXzXqHP6q9Uwb6JC240jZ+rmzHU2o8QbftOqAPB2gr34kSrvQCHgj1V0pzwFVlZFa+IExTL5suk6TaCLjc43OORYdM5fcFz+L1vvu4TMEjSMyPf9cgBZeXY5TTi07jUDh6H3H/SbI7xvklhvVoe5h33UYl1KU35gxTetIm2bCaoJFtPufeFOxabdBQIXd0q/cT3Jd78Z2udgpGvwFr63f4XAsp/InyE3+TeZHTUBTpUXm0u92mL+oIZpkMfCWPkc3FAOxyINHHfn1KtIau+vGIJH5kbQ8RkXNnsxUxSuc6WB8qp/LR9O++8f0nrQcQyVeWx/ddfTEg7e3tT88E8M9c1sPRYrYHQ3luBk4QBU/c7UFU7+Ytvla26/WPrID3nDOaGyTcgUi94fxLS+YuwNbinLvZbRTlx1mQcJjfzamUIhgMjTnXsrVOjj2xstMQ7RC3R53pGZ5kQyxaiyT5aY1bqlfCvLM0w0w8/vKqFbd40zFjLquTCwCr8GDWQ24BZKpCkaiQ/12vzcAKnxK0E= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR12MB9174.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(23010399003)(366016)(1800799024)(4143699003)(11063799006)(6133799003)(261009223027099003)(261009221227099003)(18002099003)(22082099003)(56012099006)(10067099003)(261102130727099003)(261026121527099003)(261022105027099003)(261021123027099003)(261022075727099003)(261026140227099003)(261028144727099003)(261021121427099003)(261102123227099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QzBlaWNER1k3bVNhci95MXE1cGZtZllUVGN1OE0zNWVLSERTWU5RVmpDNGc0?= =?utf-8?B?bXlwdnQvZGhRTW9XQ3lXZWFaeWdjWHhSMHdzcDZDNnNnMnBoSHg1b2tNdUl3?= =?utf-8?B?RzVDYUkwZVU4MWNMSWRXS3Zva0FPKzdvcjRlL1dpUDI5cUQ4TWZGRWF5RkZN?= =?utf-8?B?dVNRYmVSV21ZOHc4dnpmc1U2cUlsYjBUZlZDdTZpb1Jxb0IwSE1ab1c2OG1q?= =?utf-8?B?QjNWZVIxWDI5T0pBYVRFR0w1aXZNYzVMWXlLWVNwazhWZ045WXl4Rk53d0do?= =?utf-8?B?Q0l2WjZYcHJEdW53NlYxY0FRQWhoYU16cVZEUUlPazM1a3JDa0ZlVk9RREdh?= =?utf-8?B?W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?B?Mlo0dHZsZFlwYWdBekZTbjdET1BVeWdzb09xZkVDR2hNa09acjErL3kwdUNX?= =?utf-8?B?aTZEU1l4U3JaZ0hxdndsd2R3ZUxjdFpYdGhLWElrRFk0blRTRWovZXFjVEo2?= =?utf-8?Q?+L/nCzlUp978uQQMCl?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c3376a8-6542-4c3a-ef52-08df52572c95 X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB9174.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 22:37:27.5426 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NKtiwvkG2zbiuRstUrnjiX7/HoVRhwus/he7wHH5qIAvzT6T6Bwhl4uGteAHF7v8LdZ1FV1/WhGjwzAdLXRdCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6018 On 12/4/26 07:27, Vishal Badole wrote: > AMD heterogeneous processors combine multiple core types (e.g. > performance and efficiency cores) whose maximum sustained performance > and frequency differ. On such platforms the Linux scheduler relies on > per-CPU capacity values to place and balance tasks across cores. > > Today amd-pstate does not export any per-CPU capacity information. As a > result the scheduler sees every CPU as having identical capacity and > treats performance and efficiency cores as interchangeable. Tasks are > therefore placed and balanced without regard to core strength, which > hurts both throughput and energy efficiency on hybrid systems. > > This happens because the scheduler defaults to a uniform > SCHED_CAPACITY_SCALE when no arch- or driver-supplied capacity exists, > and amd-pstate never feeds the asymmetry it knows (via CPPC highest > frequency or the effective highest performance register) into the arch > hybrid capacity scaling interface. > > Enable capacity aware scheduling by scaling each CPU's capacity relative > to a reference CPU. Use the maximum attainable frequencies when available > for both CPUs, or their effective highest performance values otherwise. > If reference setup fails, keep CAS disabled and continue normal CPUFreq > registration. > > Capacity aware scheduling is enabled by default on supported hardware and > can be turned off with the "amd_cas=disable" boot parameter. Its effective > state is exposed through the "cas" sysfs attribute, and also exported via > amd_pstate_cas_active() so amd-hfi can stand down when capacity aware > scheduling owns the heterogeneous cores. > > Signed-off-by: Vishal Badole Can you have a look at the Sashiko feedback? It's found quite a bit. https://sashiko.dev/#/patchset/20261204132715.1668516-1-Vishal.Badole%40amd.com > --- > MAINTAINERS | 1 + > arch/x86/include/asm/amd/amd-pstate.h | 16 +++ > arch/x86/include/asm/topology.h | 6 + > arch/x86/kernel/acpi/cppc.c | 4 +- > drivers/cpufreq/amd-pstate.c | 184 +++++++++++++++++++++++++- > 5 files changed, 206 insertions(+), 5 deletions(-) > create mode 100644 arch/x86/include/asm/amd/amd-pstate.h > > diff --git a/MAINTAINERS b/MAINTAINERS > index 44540a1eb2b80..300dce181c1c4 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -1322,6 +1322,7 @@ R: K Prateek Nayak > L: linux-pm@vger.kernel.org > S: Supported > F: Documentation/admin-guide/pm/amd-pstate.rst > +F: arch/x86/include/asm/amd/amd-pstate.h > F: drivers/cpufreq/amd-pstate* > F: tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py > > diff --git a/arch/x86/include/asm/amd/amd-pstate.h b/arch/x86/include/asm/amd/amd-pstate.h > new file mode 100644 > index 0000000000000..1c0eb56c8f867 > --- /dev/null > +++ b/arch/x86/include/asm/amd/amd-pstate.h > @@ -0,0 +1,16 @@ > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > +/* > + * Public interface for the AMD P-state driver. > + */ > +#ifndef _ASM_X86_AMD_PSTATE_H_ > +#define _ASM_X86_AMD_PSTATE_H_ > + > +#include > + > +#if IS_ENABLED(CONFIG_X86_AMD_PSTATE) > +bool amd_pstate_cas_active(void); > +#else > +static inline bool amd_pstate_cas_active(void) { return false; } > +#endif > + > +#endif /* _ASM_X86_AMD_PSTATE_H_ */ > diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h > index 1825691af9410..ddcd550e25846 100644 > --- a/arch/x86/include/asm/topology.h > +++ b/arch/x86/include/asm/topology.h > @@ -264,6 +264,12 @@ void x86_pci_root_bus_resources(int bus, struct list_head *resources); > > extern bool x86_topology_update; > > +static inline void arch_mark_cpu_topology_changed(void) > +{ > + if (IS_ENABLED(CONFIG_SMP)) > + x86_topology_update = true; > +} > + > #ifdef CONFIG_SCHED_MC_PRIO > #include > #include > diff --git a/arch/x86/kernel/acpi/cppc.c b/arch/x86/kernel/acpi/cppc.c > index 1c6bf56c3215b..15590e9da2dca 100644 > --- a/arch/x86/kernel/acpi/cppc.c > +++ b/arch/x86/kernel/acpi/cppc.c > @@ -248,8 +248,8 @@ int amd_get_effective_highest_perf(unsigned int cpu) > if (ret < 0) > return ret; > > - /* without preferred cores, return the highest perf register value */ > - if (!prefcore) > + /* Reuse the cached value for homogeneous CPUs without preferred cores. */ > + if (!prefcore && !cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES)) > return boost_numerator; > > /* > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c > index 3e0308f644778..366ba3802f3c8 100644 > --- a/drivers/cpufreq/amd-pstate.c > +++ b/drivers/cpufreq/amd-pstate.c > @@ -39,10 +39,12 @@ > #include > #include > #include > +#include > > #include > #include > > +#include > #include > #include > #include > @@ -86,6 +88,9 @@ static struct cpufreq_driver amd_pstate_driver; > static struct cpufreq_driver amd_pstate_epp_driver; > static int cppc_state = AMD_PSTATE_UNDEFINED; > static bool amd_pstate_prefcore = true; > +static bool amd_pstate_cas = true; > +static bool amd_pstate_cas_initialized; > +static u32 amd_pstate_ref_freq_khz; > static struct quirk_entry *quirks; > > /* > @@ -962,6 +967,142 @@ static void amd_pstate_init_prefcore(struct amd_cpudata *cpudata) > sched_set_itmt_core_prio((int)READ_ONCE(cpudata->prefcore_ranking), cpudata->cpu); > } > > +bool amd_pstate_cas_active(void) > +{ > + return READ_ONCE(amd_pstate_cas_initialized); > +} > +EXPORT_SYMBOL_GPL(amd_pstate_cas_active); > + > +static bool amd_pstate_update_ref(int offline_cpu) > +{ > + u32 ref_max_freq = 0, max_freq, nominal_freq; > + struct cppc_perf_caps perf_caps; > + int cpu, ret, highest_perf; > + > + for_each_online_cpu(cpu) { > + if (cpu == offline_cpu) > + continue; > + > + ret = amd_get_max_frequency(cpu); > + if (ret < 0) { > + pr_warn("Invalid maximum frequency (%d) on CPU%d\n", ret, cpu); > + return false; > + } > + > + max_freq = (u32)ret * 1000; > + if (!max_freq) { > + ret = cppc_get_perf_caps(cpu, &perf_caps); > + if (ret) > + return false; > + > + if (!perf_caps.nominal_freq) { > + pr_warn("Missing nominal frequency on CPU%d\n", cpu); > + return false; > + } > + > + highest_perf = amd_get_effective_highest_perf(cpu); > + if (highest_perf <= 0) { > + pr_warn("Invalid highest performance (%d) on CPU%d\n", > + highest_perf, cpu); > + return false; > + } > + > + nominal_freq = perf_caps.nominal_freq * 1000; > + max_freq = DIV_ROUND_UP_ULL((u64)nominal_freq * highest_perf, > + perf_caps.nominal_perf); > + } > + > + if (max_freq <= ref_max_freq) > + continue; > + > + ref_max_freq = max_freq; > + } > + > + if (!ref_max_freq) { > + pr_warn("No reference CPU available for capacity scaling\n"); > + return false; > + } > + > + amd_pstate_ref_freq_khz = ref_max_freq; > + > + return true; > +} > + > +static void __init amd_pstate_init_cas(void) > +{ > + if (!amd_pstate_cas) > + return; > + > + amd_pstate_cas = false; > + if (!cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES)) > + return; > + > + if (!amd_pstate_update_ref(nr_cpu_ids)) > + return; > + > + amd_pstate_cas = arch_enable_hybrid_capacity_scale(); > +} > + > +static void amd_pstate_update_cpu_capacity(struct amd_cpudata *data) > +{ > + unsigned long max_freq = READ_ONCE(data->max_freq); > + int cpu = data->cpu; > + > + arch_set_cpu_capacity(cpu, max_freq, amd_pstate_ref_freq_khz, > + max_freq, amd_pstate_ref_freq_khz); > + topology_set_cpu_scale(cpu, arch_scale_cpu_capacity(cpu)); > +} > + > +static void __amd_pstate_set_cpu_capacity(struct amd_cpudata *cpudata, bool refresh) > +{ > + int cpu; > + > + lockdep_assert_cpus_held(); > + lockdep_assert_held(&sched_domains_mutex); > + > + if (cpudata) { > + u32 max_freq = READ_ONCE(cpudata->max_freq); > + > + if (max_freq > amd_pstate_ref_freq_khz) { > + amd_pstate_ref_freq_khz = max_freq; > + refresh = true; > + } > + } > + > + if (refresh) { > + for_each_online_cpu(cpu) { > + struct cpufreq_policy *policy; > + > + if (cpudata && cpu == cpudata->cpu) > + continue; > + > + policy = cpufreq_cpu_get_raw(cpu); > + if (policy && policy->driver_data) > + amd_pstate_update_cpu_capacity(policy->driver_data); > + } > + } > + > + if (cpudata) > + amd_pstate_update_cpu_capacity(cpudata); > + WRITE_ONCE(amd_pstate_cas_initialized, true); > +} > + > +static void amd_pstate_refresh_cpu_capacity(struct amd_cpudata *cpudata, int offline_cpu) > +{ > + guard(mutex)(&sched_domains_mutex); > + > + if (amd_pstate_update_ref(offline_cpu)) > + __amd_pstate_set_cpu_capacity(cpudata, true); > +} > + > +static void amd_pstate_set_cpu_capacity(struct amd_cpudata *cpudata) > +{ > + guard(mutex)(&sched_domains_mutex); > + > + __amd_pstate_set_cpu_capacity(cpudata, false); > + arch_mark_cpu_topology_changed(); > +} > + > static void amd_pstate_update_limits(struct cpufreq_policy *policy) > { > struct amd_cpudata *cpudata; > @@ -1093,6 +1234,9 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata) > bios_min_freq, cpudata->cpu); > } > > + if (amd_pstate_cas) > + amd_pstate_set_cpu_capacity(cpudata); > + > return 0; > } > > @@ -1203,6 +1347,7 @@ static void amd_pstate_cpu_exit(struct cpufreq_policy *policy) > freq_qos_remove_request(&cpudata->req[0]); > policy->fast_switch_possible = false; > kfree(cpudata); > + policy->driver_data = NULL; > } > > static int amd_pstate_get_balanced_epp(struct cpufreq_policy *policy) > @@ -1916,12 +2061,20 @@ static ssize_t prefcore_show(struct device *dev, > return sysfs_emit(buf, "%s\n", str_enabled_disabled(amd_pstate_prefcore)); > } > > +static ssize_t cas_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + return sysfs_emit(buf, "%s\n", str_enabled_disabled(amd_pstate_cas_active())); > +} > + > static DEVICE_ATTR_RW(status); > static DEVICE_ATTR_RO(prefcore); > +static DEVICE_ATTR_RO(cas); > > static struct attribute *pstate_global_attributes[] = { > &dev_attr_status.attr, > &dev_attr_prefcore.attr, > + &dev_attr_cas.attr, > NULL > }; > > @@ -2142,7 +2295,14 @@ static int amd_pstate_cpu_online(struct cpufreq_policy *policy) > return ret; > > cached_floor_perf = freq_to_perf(perf, cpudata->nominal_freq, cpudata->floor_freq); > - return amd_pstate_set_floor_perf(policy, cached_floor_perf); > + ret = amd_pstate_set_floor_perf(policy, cached_floor_perf); > + if (ret) > + return ret; > + > + if (amd_pstate_cas) > + amd_pstate_refresh_cpu_capacity(cpudata, nr_cpu_ids); > + > + return 0; > } > > static int amd_pstate_cpu_offline(struct cpufreq_policy *policy) > @@ -2151,6 +2311,9 @@ static int amd_pstate_cpu_offline(struct cpufreq_policy *policy) > union perf_cached perf = READ_ONCE(cpudata->perf); > int ret; > > + if (amd_pstate_cas) > + amd_pstate_refresh_cpu_capacity(NULL, cpudata->cpu); > + > /* > * Reset CPPC_REQ MSR to the BIOS value, this will allow us to retain the BIOS specified > * min_perf value across kexec reboots. If this CPU is just onlined normally after this, the > @@ -2431,8 +2594,10 @@ static int __init amd_pstate_init(void) > return ret; > } > > - if (cpu_feature_enabled(X86_FEATURE_AMD_WORKLOAD_CLASS) && > - IS_ENABLED(CONFIG_AMD_HFI)) > + amd_pstate_init_cas(); > + > + if ((cpu_feature_enabled(X86_FEATURE_AMD_WORKLOAD_CLASS) && > + IS_ENABLED(CONFIG_AMD_HFI)) || amd_pstate_cas) > amd_pstate_prefcore = false; > > ret = amd_pstate_register_driver(cppc_state); > @@ -2441,6 +2606,10 @@ static int __init amd_pstate_init(void) > return ret; > } > > + /* Per-CPU capacities are set during registration; rebuild domains once. */ > + if (amd_pstate_cas) > + rebuild_sched_domains(); > + > dev_root = bus_get_dev_root(&cpu_subsys); > if (dev_root) { > ret = sysfs_create_group(&dev_root->kobj, &amd_pstate_global_attr_group); > @@ -2481,8 +2650,17 @@ static int __init amd_prefcore_param(char *str) > return 0; > } > > +static int __init amd_cas_param(char *str) > +{ > + if (!strcmp(str, "disable")) > + amd_pstate_cas = false; > + > + return 0; > +} > + > early_param("amd_pstate", amd_pstate_param); > early_param("amd_prefcore", amd_prefcore_param); > +early_param("amd_cas", amd_cas_param); > > MODULE_AUTHOR("Huang Rui "); > MODULE_DESCRIPTION("AMD Processor P-state Frequency Driver");