From nobody Tue Apr 7 22:02:26 2026 Received: from CY3PR05CU001.outbound.protection.outlook.com (mail-westcentralusazon11013054.outbound.protection.outlook.com [40.93.201.54]) (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 A352D364029; Wed, 11 Mar 2026 14:01:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.201.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237709; cv=fail; b=KtEFbGbnipzX0L4/Lv7kRnbycI2iQVLqB05L9Hk4knhGIzZHTrBtgKiKHYpn1LTMvQWfrgO+ok8reEqwWYVYRdCSRhNl0hp8oyUdH00pYFsO/AfFlki+HgB9bK5QApXT4puJiv96tanD7cdraKkPU9vnTMXAACuQA6b3a0y/QL8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237709; c=relaxed/simple; bh=XuTIV0n+oRXw9VTDjTtp3eqDdIbXA6Y5/lckxC4Rr58=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SiECjX+uO1UwUu/MpPtvAFlcSFXHmpE+B2BdMYHxuFI2GH3DVMr+x8OX7bb2f+EKESidSPKfI+7ncQTGwwQ7x/LY7Gxd6hNCygeywUGpI+0IvSQofp7gbgHmzf1xcm1SajUSVV+9vRSiPW8qUu0/2hGAx8qIJppzTwd5cPpRrA0= 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=Ny4RFLgj; arc=fail smtp.client-ip=40.93.201.54 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="Ny4RFLgj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cny99ioOVMGldLSuUMd+WNvA+oZWW/7TwCsyLFgT8FwX6qNvNJFM+HjKbW8l5zSwLLExkoRJeQamrDdaLEQVojFTrsDjw7YemmGHPh9LE54UaCZvueSScuxjNlqmEMrTH+WS3y3hpxzDYrFdMZR/qh2zSIem+O5IA46/3r9gWn0U4I0xYPRenZBCKwzCooPd60uGnvES6tO3pv8TgO9oUpJU+KG7uS4+ops8ybXbIZPXQhUOjBu/iifiFpb+rjMwtPQbCxZCFgkv76LW4cAhT9AHVKuDA3QIjaIO0NJgy73b6WBN12PINyvam1Vaos5wTUeb3zV/p7+UW2Ys+O/IbA== 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=nFOf6e8Ya+iEhlhvsOYlnIG5vNdJ9JjF27Lv0KmAHUU=; b=RxBPnKjddB57YlmuqzArwnsbsU5g60romfJu6OXYUvb5/HE40NYvR5uKM9hjL3P7x/lnNVs8yNvsJvvP7hqWjZo3/Ro0xh4hEORx6UffZcEvleLItAsDUNFxiMLM2f1a54ftpf3u2kP7oY14d6uCgpa2TUDdZPHe3HNX4/8Obo85EyBYcR9sLlFktonjRlX+7uRWnZ+hDhiDBjCw9WUpTV70fGarf8SlG+bT5rptIIFfRpODAv1kLam0aZ5MgoW/S6jy1Nr93sMGvUfjNEwi/HdotaeKEns2GD8nJ//4ydJlzmcUiDnlKyBynPLzqL8sIzghepsNP+4YA4rp9yE+kg== 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=nFOf6e8Ya+iEhlhvsOYlnIG5vNdJ9JjF27Lv0KmAHUU=; b=Ny4RFLgjZn1txw7gPkHEGR61giTnCSqGiXyHiM8kPYrzNBjyfI220byt/Cc5wDSbQyh5G0BL4S4dxiVko2UeGNE1LKp1uxGYMTR6LhlZMju8jHT4xvbRbn+/g/kn8XBPC4gLESPPT9DfM7LuRO0kL3cPNmQfV3DjfGA89SApvpA= Received: from BYAPR02CA0039.namprd02.prod.outlook.com (2603:10b6:a03:54::16) by IA0PR12MB9045.namprd12.prod.outlook.com (2603:10b6:208:406::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9723.4; Wed, 11 Mar 2026 14:01:44 +0000 Received: from SJ1PEPF000023D1.namprd02.prod.outlook.com (2603:10b6:a03:54:cafe::65) by BYAPR02CA0039.outlook.office365.com (2603:10b6:a03:54::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9678.26 via Frontend Transport; Wed, 11 Mar 2026 14:01:46 +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 SJ1PEPF000023D1.mail.protection.outlook.com (10.167.244.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.18 via Frontend Transport; Wed, 11 Mar 2026 14:01:43 +0000 Received: from BLRRASHENOY1.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.17; Wed, 11 Mar 2026 09:01:40 -0500 From: "Gautham R. Shenoy" To: Mario Limonciello , "Rafael J . Wysocki" , Viresh Kumar , K Prateek Nayak CC: , , "Gautham R. Shenoy" , Mario Limonciello Subject: [PATCH v2 1/9] amd-pstate: Fix memory leak in amd_pstate_epp_cpu_init() Date: Wed, 11 Mar 2026 19:31:08 +0530 Message-ID: <20260311140116.19604-2-gautham.shenoy@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260311140116.19604-1-gautham.shenoy@amd.com> References: <20260311140116.19604-1-gautham.shenoy@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: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D1:EE_|IA0PR12MB9045:EE_ X-MS-Office365-Filtering-Correlation-Id: 8cf1d5f8-9ba1-435b-5892-08de7f76b9b9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700016|82310400026|18002099003|56012099003|22082099003; X-Microsoft-Antispam-Message-Info: CyF0xrvaKBAw8s2qBcGJE3A4g4SyXaS1yJE3UnO3goLdvGxuRkEhHWsxDsIEDZHm745yj5+x/2cxFkbvBrDsuc+zhuiE7Du5C2E37D4sIRv1RET8GxsDeq2yWflmh/L92R/PvaVxtjnYEsAJpfVYJTmlRWbj/DBGrw0UftsTORGHfkfhnB5ZLBaiGKPjCV4poaBKwxFJA29sTzyrwU2+n+lSXYuUoo7XWz6FgKCmcDhyNmEHP3ezgrHYiq0IyRjg16M+atSMcXsxbCgjlPOOAP/NNPgC7nLeKhfp61G0UXCBR+wUbVgYpOQ3KbPzeVkh9t1IIRnE2ztjPJj3PRZH+mXX8Vs9LrJEkgEOL5jldjMzYchiBou0b3yC4bmdEMXTLPvYFwhih2g7A6X1sS8DGiIoX4if5Ef1f32FoYQ/Rajo/99e6VmZVq5SpkT8o4w4A2rgeOPBgG/1OPFfE/UhMeRyHCjeh/XDRFLH18TUyLhWJpqIwf/aMosaYFGrlOh/PhTRt2zU8WTY92zKW4a9yryMu+7aQk2IA8NKcRJjifwWQ6vkcBy8z82BXqlKXjy30N7qAOcUMmGwhxGuelw2jLJP3MW9QRuijf2xEk9H/DYGdgNh1suQibZAvaKFhXT83fMuH/r9p1bdJ8vQIEiVXV8upevfLhfY27K9kggZzvwgxs2jaonOqD3clV1cHF/ITcHMEzOmVdlDccJAkIuzY49ndnTAM5usXs8QJdIgaRQ= 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)(18002099003)(56012099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ya20P+Q8Roq6vRmsF3/8vnx5LtroWcGIUsH9YlQtEB2YEzVFSszwk9wnpyt0LAzvcHkW6Zu/smiAdiooPdYdHs3reJzwW9CFRY7Z5gWJUcLzoHOKmtHjM40D+BeATuKWgsoed6h1k9QjdiDB9AbohZoeJVm9t6WmUaZiOX4rt4TSQcbfUjWiNo0MDbHghXksd4LH3soOsWpPOwXOQDWSC9Aais0Y/MAmDw0qtp0skJE8bGMY970I3v6H+48WS6mdXdlzwneJ+gZALO8VwOF8OZKR5vnYfNcfzZnLKzbu7VFcMKFrkGRJv9R5OKU+8dkOeKsq612wDhXVcD4lkV9wokFn/sC1K/pvznOpwAdSV9qz11pcO8RLzrHxwocoxq1RFjxqNoDGyVYKXnrvNSGERfuBJujR12HIj0RHQLZMqn3d5beK3lxxlJCb8nZ2EzQG X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2026 14:01:43.0862 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8cf1d5f8-9ba1-435b-5892-08de7f76b9b9 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: SJ1PEPF000023D1.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB9045 Content-Type: text/plain; charset="utf-8" On failure to set the epp, the function amd_pstate_epp_cpu_init() returns with an error code without freeing the cpudata object that was allocated at the beginning of the function. Ensure that the cpudata object is freed before returning from the function. This memory leak was discovered by Claude Opus 4.6 with the aid of Chris Mason's AI review-prompts (https://github.com/masoncl/review-prompts/tree/main/kernel). Assisted-by: Claude:claude-opus-4.6 review-prompts/linux Fixes: f9a378ff6443 ("cpufreq/amd-pstate: Set different default EPP policy = for Epyc and Ryzen") Reviewed-by: Mario Limonciello (AMD) Signed-off-by: Gautham R. Shenoy --- drivers/cpufreq/amd-pstate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 5aa9fcd80cf51..d57969c72c9dc 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -1533,7 +1533,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_pol= icy *policy) =20 ret =3D amd_pstate_set_epp(policy, cpudata->epp_default); if (ret) - return ret; + goto free_cpudata1; =20 current_pstate_driver->adjust_perf =3D NULL; =20 --=20 2.34.1 From nobody Tue Apr 7 22:02:26 2026 Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012035.outbound.protection.outlook.com [40.107.209.35]) (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 7DE3936492D; Wed, 11 Mar 2026 14:11:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.209.35 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773238310; cv=fail; b=rtviDu8XPidSSJo4qZMQrLP47Dczc/OUv4oz6jEN8mvFfFscNWdP1OjbfauKBpgf1LNIBNF0P+9k9uipEkh7mBOkTDLA9AZKEkAS4dd8eWslMR4q5TwDPJ1yrXd8OzgW/QoiztxHZcYG+Ns5X4A8SEkQ4+HNhGkHOhfY2/OlbIU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773238310; c=relaxed/simple; bh=TolGaAjP+hdGIKlApaDjQYDyC7YRz09x4VAJmANDTWM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N1vpN3Y7lApu5snY2gqvhl7xaSLd/O1IfWLrTW32oSvOZihe1vWEQWrhUgnvA3hweALzzxwj4WVRMipydDSmVeCSRjcjq1JPkGmT8C8x81i0YVgZrF3b0Y9TcdTm6LgKzeiiAiOPvXdaFcbJI5n7QQX6ngQI86ToH9II6sx80QU= 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=0Yf4OWzb; arc=fail smtp.client-ip=40.107.209.35 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="0Yf4OWzb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hYI0EKW47dy5VP7MPdP/IH74mdydKpgL40qwnLES/MCkPI1DSpYyAu2GlAu2Wo7R6Bs7mz6Db2sgrm3UgTsVh0zVHcyxZ2T74xUcuopqy8F4T4H1U6CHc47FPNNEZCelLVH8DvrCILmmMObCL4oaIUBU6vZo8I5yHazbAosdhwx9RO137CIG9Hf1mOg7dJgqpW66cZYQGbkWaBD302Cp49BuG5iHQpdVAoaLr9r38n/SnhxPoL46M6kHA1in8qjjcHQJlxdJ4lJULJ465SUxqnPta06dpiiuzM1UYURX7iPXO4mZ34ZNNknZxu30Lf97sdP6o13d9mpHe5XgPBTqkw== 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=7pzlpzA8yGLtPHZ5le54owSJpjZDHrFVUWKfr3ILc4U=; b=VD9L5GEt082VhkA5UdBt5FI4BupxrG44XNbloQWinUD7aTpAJwjrLRpD79gUE3NhyChXyY/l4W+Kj9IPKkC3MGaJims19wgHoCKavkQaSnBPTT8HD+rXDHO2+p3y2qMAbstlRvKeRiqppAnkGNojKVrztQa31k811+fLUVbBoxmLpktE24WWK+rNAj3zHyccn56UzhRtEkUyVAYBhDe5BypMkggdjT0SKIfzt6dtahRc+LURUHnexIglDs76U46w/pg3PmBq/wRtnKk79P2iSoPnEHQkS66iO2M6RJ/0Ckb5W3dtp0uelMV2lXEPSv4py4wCX6ctgJfU7n5cmWB8gQ== 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=7pzlpzA8yGLtPHZ5le54owSJpjZDHrFVUWKfr3ILc4U=; b=0Yf4OWzbIGXXIyjsOAJfOCLBJF/aHMrYYb8U0Aug3j+rEH/QJFQvU8g1nFevNRB6UoGroiV7TSUW5E2TBz4TLIaNrJOZbdq/bSoUg+FH+Xp6fXnhjfUVRHd62g/jQiMuo+C7sgsB/G3kdauUy68qGYiILFOaFxcbrYDE1UnJY3g= Received: from BLAPR03CA0129.namprd03.prod.outlook.com (2603:10b6:208:32e::14) by IA1PR12MB7543.namprd12.prod.outlook.com (2603:10b6:208:42d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9723.3; Wed, 11 Mar 2026 14:11:46 +0000 Received: from BL02EPF00021F6C.namprd02.prod.outlook.com (2603:10b6:208:32e:cafe::50) by BLAPR03CA0129.outlook.office365.com (2603:10b6:208:32e::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9678.27 via Frontend Transport; Wed, 11 Mar 2026 14:11:23 +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 BL02EPF00021F6C.mail.protection.outlook.com (10.167.249.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.18 via Frontend Transport; Wed, 11 Mar 2026 14:11:46 +0000 Received: from BLRRASHENOY1.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.17; Wed, 11 Mar 2026 09:01:43 -0500 From: "Gautham R. Shenoy" To: Mario Limonciello , "Rafael J . Wysocki" , Viresh Kumar , K Prateek Nayak CC: , , "Gautham R. Shenoy" Subject: [PATCH v2 2/9] amd-pstate: Update cppc_req_cached in fast_switch case Date: Wed, 11 Mar 2026 19:31:09 +0530 Message-ID: <20260311140116.19604-3-gautham.shenoy@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260311140116.19604-1-gautham.shenoy@amd.com> References: <20260311140116.19604-1-gautham.shenoy@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: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00021F6C:EE_|IA1PR12MB7543:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e424499-e16d-46da-ec38-08de7f78215d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700016|1800799024|376014|22082099003|56012099003|18002099003; X-Microsoft-Antispam-Message-Info: 2eIRjRSk9x3GMfulsxQcUPqZkkxuBOoCseTvjqmS0/qxWnEgrF4g5GLMJXFazvVfjdgUu5ma/VQexK+4ytYG/9pyj+PnicNTOeImnFxiOfoLz4dZRik4rRDbhQTJwb2SeIo0actT/fJVU1tYWC+zVR98cnhO0ZJfq3R3V0WmztalQnfj+YmcPdrJub9AwR1j0QbF4js0SYS1TaEAidHAA8Zx7+cdIKBFEWmrf4ERR+JCZXE3Jeug+2SrxEnWbTTpEB5b+2P9r/5Wguq2dI2GKudg13qGLwk4y6a0A2SY6Tndtzr8YY6bSutqsJPpI/Pkxj5VjjKx6jNjDPsS1ZUYWT7HIxnu21FtnipBsNICADsBqL7zMisd2QaGzN31H5H87lrUPDxECodF5mtbaYg6cfiBEQrEubjoQGFy0D7Nj7oVJkNPmWF89e9co4UfPXKt5ujZVnsIbVIu+niwE3PO99iKuUqzbi+JKXPbsOrSW1R0LCZIkWnWO0oGPolIWXDoze/2hcCoz2hjswePkVrCy0/Bjjo55dmOhjgW7lLbHsLwRCbTM+RjpJ8HbFD6X4a/Ss8uxoIg9ItwU3LTTetiWgyBwyTEFfLQfnxkwOs7MkeFWKKuU+UYazflTxibcxRESjWqMdv/epzIxkMXE5O1Fl3BqRDuetgUeiBJThZN0mNPVwX++N5rnX8vbs33UEhqyAX/0ZWa6iAyQ5cIeimerxkn+rJReJcHhFxyyiLiJv4= 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)(82310400026)(36860700016)(1800799024)(376014)(22082099003)(56012099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Mfo+Jf2sQnnoQSJMo0UueGDJYnxfAU/agfMwWUoLEdNxgORiajcdvxNeCV8st0/ZPr4e0sDmzVIZ8MIsILEyncYbohrtKS+rWf2Mvg1wQzTJFGSe1vzX11rzEJbA0ps0/oKRO4TcTA70qZpCW8i+b1Oudy4R+V6Vb2CKR8aT91ZMpsaOlrYhBP3zw9PMhPSOiftOzDDJ5wLTG6FUD+txl/jjwSnwO4fBixzD4JCLr6ObpPharRB2HEPhIu5v/MZ6LXjigWNNIUwQGDpuu2NnKy/XW3+vxMPR69sN3fKCeiAU33BUwYhmni6SybKpNTBVFP1k//phtqrHRMY7rXwOEO/LFB6rVeCEnho2TvdApTmGsyNA3zv6K84w8utJOuI+4AjaqZzcBks3THJkaTm6YU7SyCFkV21Wuef0MFbsYLEf4rX3PQdqeM16hxb0kruc X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2026 14:11:46.5359 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e424499-e16d-46da-ec38-08de7f78215d 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: BL02EPF00021F6C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7543 Content-Type: text/plain; charset="utf-8" The function msr_update_perf() does not cache the new value that is written to MSR_AMD_CPPC_REQ into the variable cpudata->cppc_req_cached when the update is happening from the fast path. Fix that by caching the value everytime the MSR_AMD_CPPC_REQ gets updated. This issue was discovered by Claude Opus 4.6 with the aid of Chris Mason's AI review-prompts (https://github.com/masoncl/review-prompts/tree/main/kernel). Assisted-by: Claude:claude-opus-4.6 review-prompts/linux Fixes: fff395796917 ("cpufreq/amd-pstate: Always write EPP value when updat= ing perf") Signed-off-by: Gautham R. Shenoy Reviewed-by: Mario Limonciello (AMD) --- drivers/cpufreq/amd-pstate.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index d57969c72c9dc..24cdeffbcd40e 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -261,7 +261,6 @@ static int msr_update_perf(struct cpufreq_policy *polic= y, u8 min_perf, =20 if (fast_switch) { wrmsrq(MSR_AMD_CPPC_REQ, value); - return 0; } else { int ret =3D wrmsrq_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, value); =20 --=20 2.34.1 From nobody Tue Apr 7 22:02:26 2026 Received: from SA9PR02CU001.outbound.protection.outlook.com (mail-southcentralusazon11013016.outbound.protection.outlook.com [40.93.196.16]) (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 8095D372EFD; Wed, 11 Mar 2026 14:01:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.196.16 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237713; cv=fail; b=VZxYJoRLy4x4aCDEzv0ANotCB5yvuDO4mnQbvnK3kQhbBHtt8AT2GdGG+BFzBNEEzl4d+eppEQQ52StdEjfojuJDI96waNl+i7MVa01ofGcYpGMofWvht1NEnvXdywtwd6asLyEF618PjNVNVUalSktEmnqMoS9jFqUHwpRs4wg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237713; c=relaxed/simple; bh=ERDLP2yDIE+LbCEpbvCi04ACdHnp9GqSEDVmw4qbRGE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ge+tlT6CVjhqo2+9d0mWq9C2B4UDSDL5tZ9P/j/kq1WApLLhcobDf6h8neH9OaVfhPzLeTIHBxKfsoKwuvcYw0oA4kMYF66TQPGAFVKSOL76v70s67VVy97YC4er8qUKt7C8uURMHcitp4X4cPonR1NwlLK9/yPb/IAtsYmGmN0= 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=OjenNMcN; arc=fail smtp.client-ip=40.93.196.16 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="OjenNMcN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PcK5vO4yIMZ5ZpcMZuTanliilyM5qZ7bC/UN6rpURXZCRzX2ptWGDgHITuSXiVBIk7d3i84tYI9xCmag/VSnMuCkdyC6xLzyOsCm3Wgsn8k21ONLUqFPzCn/ebSpxTTj8Z2aapUm6w6pH0ISv1J9t22t0pQxtvCjlMpklNwRYux65+1DdeCh2G5ak2pxmx7rPz4c+rasDtct2VMSiLMNpQ1g4fLgtJrGgoeN0IeYgueGm8LefD6/JCdCpnJKiq/1bqMolPqh2nw2n6Su8hov2TZynhWPeXNR8Iau5D8Qgw82AEbu7l/ABptbZULYTLJ9vqyPnRpE4YjjVQmCBQPx9A== 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=nIklXVIqMNnvTwvkJUffYmhLZc1doDN22kT9oQnfjOQ=; b=nlegFzfm6Ft+Kl6ZVGyNNZrjODGR2x/KgyY3+eYXDXI0yrkzTDGOSIEokitDzz5MGz/06/4SAdnQE/8U/fkFlRL0yHh13X9M7Gfoo5pw98ZXJLa7zVTM0RQGM34v/11hXoc5CKtDJOSOXFjm9OxQOiJ9DdlZtlXaahxRsWRh2QfGSBuoiwPMXsYmDDz6desxBd3QtssubYWl48JCYQWbcINhQ32aLfUu3VEifyQdJNjGVUSpHlrIaiSGgwmAmrQi51CO+/0XwVqBiO4ZKYXrMWL2pHALpd2tLTfqQcZULZJfgpw3jFDza1240C3IAKHjF5zKHF2s2T1sb/wRQ8n3PQ== 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=nIklXVIqMNnvTwvkJUffYmhLZc1doDN22kT9oQnfjOQ=; b=OjenNMcNsmZLB7yaZ8qfne1539x36qCmtRViqO0akXyTj2OFxhIgEkpD0IUWXsCDgyWTsM5GZoSy2k+6P3cq0hWhzoWjeeOnAi6VfKzUSaM2bGtwOujCsETT9ThoHtBLo3RdroLIA4EKav9vkknNBO2QoOU2pxuuGCoVx6UVJ7o= Received: from SJ2PR07CA0003.namprd07.prod.outlook.com (2603:10b6:a03:505::26) by SA1PR12MB999110.namprd12.prod.outlook.com (2603:10b6:806:4a1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9700.11; Wed, 11 Mar 2026 14:01:48 +0000 Received: from SJ1PEPF000023D2.namprd02.prod.outlook.com (2603:10b6:a03:505:cafe::14) by SJ2PR07CA0003.outlook.office365.com (2603:10b6:a03:505::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9678.26 via Frontend Transport; Wed, 11 Mar 2026 14:01:49 +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 SJ1PEPF000023D2.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.18 via Frontend Transport; Wed, 11 Mar 2026 14:01:47 +0000 Received: from BLRRASHENOY1.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.17; Wed, 11 Mar 2026 09:01:45 -0500 From: "Gautham R. Shenoy" To: Mario Limonciello , "Rafael J . Wysocki" , Viresh Kumar , K Prateek Nayak CC: , , "Gautham R. Shenoy" Subject: [PATCH v2 3/9] amd-pstate: Make certain freq_attrs conditionally visible Date: Wed, 11 Mar 2026 19:31:10 +0530 Message-ID: <20260311140116.19604-4-gautham.shenoy@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260311140116.19604-1-gautham.shenoy@amd.com> References: <20260311140116.19604-1-gautham.shenoy@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: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D2:EE_|SA1PR12MB999110:EE_ X-MS-Office365-Filtering-Correlation-Id: 2498fd9b-2d83-4b12-6b33-08de7f76bc9a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700016|22082099003|18002099003|56012099003; X-Microsoft-Antispam-Message-Info: U0frJksKbQtY+4WisFYg+uw/u8/uZpsDRsOPiUV6ReWf6YkUqBoLCwLjaKNLurkpaEviEAybHnAEfZ5n/LQcOJ+z5i6bHzCuB4TIRsecjJpsFw6lFTtBDam3qVYvJMbuZk3HEwzOSOK4O1vBifGJk2WU7sUUAqug6BlNYYv//0LYiWjdW6rroGcbsx4sJpug0TUnvKLWMDsFGUb+I9vSb+2tb4sl7objKIbu+LuboQA7NHs+tzJWMTntdqaEFbD6Wv8E7X8gFqqVRaXP9DgIiqiKDo+OV8R2uETf//EhWZ7g/Rz3c59pQlWwmGXoNHYxSs2EtWJ2CXhRWYbkVtsmwdNEaJXBzwSxAW8m7dtdqgClzcF+DkJE0RhAscXqEK1YaT/zo7y7mi7dytnPSJanioujGCT4JjyZl0c4vsu7nzyTLngRAD98DeCfnO06cYlD5hfLAh4anZmpY0zuZA7BhVqdUuJG+6Sbkd2SfmuUXG0mReNU3buMtw73LHib9LBLyl27nR+VEE22kLixztUKM9ow341npAbbvY6JprSqh0Lc5qAMTqXhHLSKAwacMxBZbk1uPwDmklEf/jTt1yDkuIBAiFJyLZe+huwDk3TTMbjKTLufj6FnAswnKszHaXqNPvUNQQxJLjMrWDq1PJI60IXrIN7M9nFPi9TAwrpAj0mQYdjbHffj756+LKDjWqPyoQr3Ejr1xmxk3JuZnqEKIpyjO3wG2zOXlsWvg1mesQDdIqOur5/OUrWolZVyFmAINtQjErgLtYqxemti2uG3gw== 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)(376014)(1800799024)(82310400026)(36860700016)(22082099003)(18002099003)(56012099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8hQfe3KKC/H1xcmVJyEpQ4C5cScpk5HDcDpYd2SiXMN2sutuVFvChV75ac0cohWHZRX4q+bU0dKhHXFlV9yhkn+tjLUq0ktQfM43RCXX0iQHZZ59alslGLuyGlGU/Cop9Lz123jRSftulvk7sbjOrO9e1thnjuN+x91oSjxXuXZze/2aymj02p8OXKWZjru8QEvAyIZZUMKNnHiXKsJOyEcOslV/hSPD54TJyDF5mWfJPTPVUzUr9OQLXwjTEYY9sLpfjJS5ovS7pgTHx0qkZq/YgNuNOXEC3HZ2hRpFrtDoQv17R90GzTvWZ2MApLE9RpdLmwjGySgxWS+zrx3w4yvsam3UqC4nVClILRusYL0XkYn6pUgh46udYMshoYj1MZ1rplsYrNAF3HbWwjq9iEC/NXfzlZ8XBQJgI0aeKxc+woELSaOJQClZ3o9lVwtc X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2026 14:01:47.9476 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2498fd9b-2d83-4b12-6b33-08de7f76bc9a 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: SJ1PEPF000023D2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB999110 Content-Type: text/plain; charset="utf-8" Certain amd_pstate freq_attrs such as amd_pstate_hw_prefcore and amd_pstate_prefcore_ranking are enabled even when preferred core is not supported on the platform. Similarly there are common freq_attrs between the amd-pstate and the amd-pstate-epp drivers (eg: amd_pstate_max_freq, amd_pstate_lowest_non_linear_freq, etc.) but are duplicated in two different freq_attr structs. Unify all the attributes in a single place and associate each of them with a visibility function that determines whether the attribute should be visible based on the underlying platform support and the current amd_pstate mode. Signed-off-by: Gautham R. Shenoy Reviewed-by: Mario Limonciello (AMD) --- drivers/cpufreq/amd-pstate.c | 123 ++++++++++++++++++++++++++--------- 1 file changed, 92 insertions(+), 31 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 24cdeffbcd40e..fb5d7bb320c15 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -1220,12 +1220,86 @@ static ssize_t show_energy_performance_preference( return sysfs_emit(buf, "%s\n", energy_perf_strings[preference]); } =20 +cpufreq_freq_attr_ro(amd_pstate_max_freq); +cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq); + +cpufreq_freq_attr_ro(amd_pstate_highest_perf); +cpufreq_freq_attr_ro(amd_pstate_prefcore_ranking); +cpufreq_freq_attr_ro(amd_pstate_hw_prefcore); +cpufreq_freq_attr_rw(energy_performance_preference); +cpufreq_freq_attr_ro(energy_performance_available_preferences); + +struct freq_attr_visibility { + struct freq_attr *attr; + bool (*visibility_fn)(void); +}; + +/* For attributes which are always visible */ +static bool always_visible(void) +{ + return true; +} + +/* Determines whether prefcore related attributes should be visible */ +static bool prefcore_visibility(void) +{ + return amd_pstate_prefcore; +} + +/* Determines whether energy performance preference should be visible */ +static bool epp_visibility(void) +{ + return cppc_state =3D=3D AMD_PSTATE_ACTIVE; +} + +static struct freq_attr_visibility amd_pstate_attr_visibility[] =3D { + {&amd_pstate_max_freq, always_visible}, + {&amd_pstate_lowest_nonlinear_freq, always_visible}, + {&amd_pstate_highest_perf, always_visible}, + {&amd_pstate_prefcore_ranking, prefcore_visibility}, + {&amd_pstate_hw_prefcore, prefcore_visibility}, + {&energy_performance_preference, epp_visibility}, + {&energy_performance_available_preferences, epp_visibility}, +}; + +static struct freq_attr **get_freq_attrs(void) +{ + bool attr_visible[ARRAY_SIZE(amd_pstate_attr_visibility)]; + struct freq_attr **attrs; + int i, j, count; + + for (i =3D 0, count =3D 0; i < ARRAY_SIZE(amd_pstate_attr_visibility); i+= +) { + struct freq_attr_visibility *v =3D &amd_pstate_attr_visibility[i]; + + attr_visible[i] =3D v->visibility_fn(); + if (attr_visible[i]) + count++; + } + + /* amd_pstate_{max_freq, lowest_nonlinear_freq, highest_freq} should alwa= ys be visible */ + BUG_ON(!count); + + attrs =3D kcalloc(count + 1, sizeof(struct freq_attr *), GFP_KERNEL); + if (!attrs) + return ERR_PTR(-ENOMEM); + + for (i =3D 0, j =3D 0; i < ARRAY_SIZE(amd_pstate_attr_visibility); i++) { + if (!attr_visible[i]) + continue; + + attrs[j++] =3D amd_pstate_attr_visibility[i].attr; + } + + return attrs; +} + static void amd_pstate_driver_cleanup(void) { if (amd_pstate_prefcore) sched_clear_itmt_support(); =20 cppc_state =3D AMD_PSTATE_DISABLE; + kfree(current_pstate_driver->attr); current_pstate_driver =3D NULL; } =20 @@ -1250,6 +1324,7 @@ static int amd_pstate_set_driver(int mode_idx) =20 static int amd_pstate_register_driver(int mode) { + struct freq_attr **attr =3D NULL; int ret; =20 ret =3D amd_pstate_set_driver(mode); @@ -1258,6 +1333,22 @@ static int amd_pstate_register_driver(int mode) =20 cppc_state =3D mode; =20 + /* + * Note: It is important to compute the attrs _after_ + * re-initializing the cppc_state. Some attributes become + * visible only when cppc_state is AMD_PSTATE_ACTIVE. + */ + attr =3D get_freq_attrs(); + if (IS_ERR(attr)) { + ret =3D (int) PTR_ERR(attr); + pr_err("Couldn't compute freq_attrs for current mode %s [%d]\n", + amd_pstate_get_mode_string(cppc_state), ret); + amd_pstate_driver_cleanup(); + return ret; + } + + current_pstate_driver->attr =3D attr; + /* at least one CPU supports CPB */ current_pstate_driver->boost_enabled =3D cpu_feature_enabled(X86_FEATURE_= CPB); =20 @@ -1399,37 +1490,9 @@ static ssize_t prefcore_show(struct device *dev, return sysfs_emit(buf, "%s\n", str_enabled_disabled(amd_pstate_prefcore)); } =20 -cpufreq_freq_attr_ro(amd_pstate_max_freq); -cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq); - -cpufreq_freq_attr_ro(amd_pstate_highest_perf); -cpufreq_freq_attr_ro(amd_pstate_prefcore_ranking); -cpufreq_freq_attr_ro(amd_pstate_hw_prefcore); -cpufreq_freq_attr_rw(energy_performance_preference); -cpufreq_freq_attr_ro(energy_performance_available_preferences); static DEVICE_ATTR_RW(status); static DEVICE_ATTR_RO(prefcore); =20 -static struct freq_attr *amd_pstate_attr[] =3D { - &amd_pstate_max_freq, - &amd_pstate_lowest_nonlinear_freq, - &amd_pstate_highest_perf, - &amd_pstate_prefcore_ranking, - &amd_pstate_hw_prefcore, - NULL, -}; - -static struct freq_attr *amd_pstate_epp_attr[] =3D { - &amd_pstate_max_freq, - &amd_pstate_lowest_nonlinear_freq, - &amd_pstate_highest_perf, - &amd_pstate_prefcore_ranking, - &amd_pstate_hw_prefcore, - &energy_performance_preference, - &energy_performance_available_preferences, - NULL, -}; - static struct attribute *pstate_global_attributes[] =3D { &dev_attr_status.attr, &dev_attr_prefcore.attr, @@ -1696,7 +1759,6 @@ static struct cpufreq_driver amd_pstate_driver =3D { .set_boost =3D amd_pstate_set_boost, .update_limits =3D amd_pstate_update_limits, .name =3D "amd-pstate", - .attr =3D amd_pstate_attr, }; =20 static struct cpufreq_driver amd_pstate_epp_driver =3D { @@ -1712,7 +1774,6 @@ static struct cpufreq_driver amd_pstate_epp_driver = =3D { .update_limits =3D amd_pstate_update_limits, .set_boost =3D amd_pstate_set_boost, .name =3D "amd-pstate-epp", - .attr =3D amd_pstate_epp_attr, }; =20 /* @@ -1858,7 +1919,7 @@ static int __init amd_pstate_init(void) return ret; =20 global_attr_free: - cpufreq_unregister_driver(current_pstate_driver); + amd_pstate_unregister_driver(0); return ret; } device_initcall(amd_pstate_init); --=20 2.34.1 From nobody Tue Apr 7 22:02:26 2026 Received: from CY3PR05CU001.outbound.protection.outlook.com (mail-westcentralusazon11013034.outbound.protection.outlook.com [40.93.201.34]) (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 8FF0D3A4F23; Wed, 11 Mar 2026 14:02:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.201.34 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237729; cv=fail; b=Inyx+E5EVNbit2BQxOAY4Hohk9hDy/ntFWGSU1//0VQrCCmOV036saoY4pvhLp5pCmNVRPB9rFTZW1ObccfadXS7cYVTsjxXdG2Mtp3nhtE9P4CI6MO4ApyiM+incYmzTRPoneR4Llm6cb0N0U8+xYHI2SUzgheo+kji/AHGNmg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237729; c=relaxed/simple; bh=lDNuAUYL83vsdV2My3Y+jWemRdOWw5ge8IGu3lAKx7s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AxCvFxw/LW330WCUVHJUjVvdf6i2qCVagev121BNIy5bV6GEHiJJgIwfpHnpIR0XJ3ay66C/Gkfw0T994D6OltEX6Be9xshkODChHyqTMHsNFXx9xIb84vGRvsRL74TVvJ1YmpQloXRdJa5/KABb+0EGa+3ySEg88LxKI36siHE= 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=I8fhdAki; arc=fail smtp.client-ip=40.93.201.34 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="I8fhdAki" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=s6ksB31N5JTFUWcV8Tru3LldaBeEezCODFOyS6K7RQNX4X3QQjkZFWl1Ut39KPvpxlJIDt5UmQ80+DrHIZJlibBbg/cHR/iYzgw7DpKOAC11LeYYQr67tDIJuilHdR8G1FOxMfB6U67CUQPfPpXbLvjZm7RxojYkcca1sLCrCtC8PRuj3hs7Oiad4LkaaG6YDN3iM72FTbMLbSJnJaRG2nP4wD7FrCCZSAeAzwC4KZPAtS/ZpUnHb08GnE1qMunuyRK+Eb9gsPaZMq06TdMxdhNIJlAt9NOZYEVbvB0FKgbvmFDqRb0uWkyKm1KZZJ7Bq8a4emnrD7cXPdu8NJNtiw== 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=5Ca4rhd1lnPRTFpPzaFHJgfMFIvhdJ/XPd9UWRQUGqg=; b=OviWVgqoWvRfDQESm3ASDjXH4vfxbdxo7aajdBRiqe11j2yZxbvq+b1IAcc+nLFQ6QJTq3PrgQ1ll7Llapxdec/8hOHkOw7642EZ1q6pbxZy7bRrXw/IyFdfBt39Pg6zn8NNXKKPHyzF0TyxggAYMtLowApckOXcWF0OO9+LmIrdy1he5yLfHPpZwAZBrDKh45QYFT/U5nKcc2ifan0u8eUU49Y1bNfQ40h90BA9GJsgNWTMJsMZ33u5sXnzF+Iind67kjlxJMVrItjtxf075fYKl03m8dck7k6IyRMA3aZ2kGisOaIqqHrUDc6eGmvsWbpteAO2cWlC7l0aCmpa1g== 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=5Ca4rhd1lnPRTFpPzaFHJgfMFIvhdJ/XPd9UWRQUGqg=; b=I8fhdAkiPILXctjjiPRcDpnV2EeqYYLH3H/SEq0SsWWzu6g6ARnf1z3xKjWpvh1LwzB4qvfuU5vCdg0WDss8H8LErSKu2RrW03hIJ9F8Ia6uhmAdY+rzq5L9RWjpb+johAVvR4ynE8TZQwQG870n4mzsHpni3PiNIO/Rdzdj/g8= Received: from SJ0PR13CA0032.namprd13.prod.outlook.com (2603:10b6:a03:2c2::7) by CH1PR12MB9599.namprd12.prod.outlook.com (2603:10b6:610:2ae::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9700.11; Wed, 11 Mar 2026 14:01:52 +0000 Received: from SJ1PEPF000023CE.namprd02.prod.outlook.com (2603:10b6:a03:2c2:cafe::2b) by SJ0PR13CA0032.outlook.office365.com (2603:10b6:a03:2c2::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9678.20 via Frontend Transport; Wed, 11 Mar 2026 14:01:51 +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 SJ1PEPF000023CE.mail.protection.outlook.com (10.167.244.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.18 via Frontend Transport; Wed, 11 Mar 2026 14:01:51 +0000 Received: from BLRRASHENOY1.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.17; Wed, 11 Mar 2026 09:01:47 -0500 From: "Gautham R. Shenoy" To: Mario Limonciello , "Rafael J . Wysocki" , Viresh Kumar , K Prateek Nayak CC: , , "Gautham R. Shenoy" , "H. Peter Anvin" , "Borislav Petkov" , Dave Hansen , "Thomas Gleixner" , Ingo Molnar , Subject: [PATCH v2 4/9] x86/cpufeatures: Add AMD CPPC Performance Priority feature Date: Wed, 11 Mar 2026 19:31:11 +0530 Message-ID: <20260311140116.19604-5-gautham.shenoy@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260311140116.19604-1-gautham.shenoy@amd.com> References: <20260311140116.19604-1-gautham.shenoy@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: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023CE:EE_|CH1PR12MB9599:EE_ X-MS-Office365-Filtering-Correlation-Id: 8fadb0c9-dff3-47a9-cec7-08de7f76bed6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700016|7416014|376014|22082099003|56012099003|18002099003; X-Microsoft-Antispam-Message-Info: SoXitwqZEUGjIJ34MWVblidLYIZ73RxRHmbk7HUmI35Tp4UDeiS7PEcRvdjR+lTOiqn8uItkzKUXU26kJqWE/W0nh8SUFUfCc+41svT9rMtXjSRoYx1oaRGIpJR11qCTQkBAmZnYxu8MgcoQ7z6VPwK/vqmU/usDEsDV/eQQjsGzE3vn6b1hoje61iaKjVQRloFXonefqP/ZtFl1kGaU/N+X0JEmPT3Msiw0s/UyMHDwn2rWId2FS3xyPGY5AiYgGECn6Kmgdky4aQQ5eYlANhDAP4bMzbc4NitUaRX+EoTykKy7+i3H8MeW0D4348oVAwpMYWm6py9fyLS7GFgK63q/K7/sF67pfRrMiwSZFfWsY6rYhSCtO4CwfA0bhp3HqQAxe6yxrx9RgAEpbIrVLtkcMo6UrmyH4p7dSdz7h/vtY3Z8+bqQtuLF6xtjhXAhbNGz6zG/2VwqU0fMXuaKK5c5lqz1zyvGcg1A3aYTTyrnZiRns24jZAjOiTP0G/cuTyn4blkbeRtpvw2Qm10zDjggz2e7hmmwGkzy7jw1P1Z82Isa1j+c2fqwIKgjGTK1mEKAAzLDsU1wFXKswcNIGR2Zj3ZYPlI6Vm2u9RlcjwnPpC0/jI2WFHAThHabuIcFYAV7JzG1GoN6X0MFVbLz6QGvXoaDFToOMXFWHhneWA3bnM1ICNilgx+VG2c5GDy5bxE8Y9fu1rpr6bWJcXC7Zfl27TLNIyqSgxv0ptA1bhx187x//tNZZAiYwXVwOWTjoCgWBgdyh7JM8Hq0nHwVVQ== 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)(82310400026)(36860700016)(7416014)(376014)(22082099003)(56012099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EaJ7dZ3deRSwV/ZLQLbS3VegbASljviGotfv1FjpA4COZrmauh8eo5ioJK3EQZi987ufnQeFyHMoiKgMBjzIBbsSMogKMmH8tdGOAVAJ+CNjgd81lcnjJoGf1FA88B3qde/514CYkrR5+9CBoVIV4yQ6QRdWqA7pMORocjOvX2T6RLOHe6NjsmqWRA6FBRR1vGgs88H+YUtr1UZNcMfVZGKlKNPlkwdfN9AcDuiVBULih1R3GN/KET7bMBDHdGjtC8ZFne1/t78bIfWMvxNl0QZqkvZlvTfit1yyOSkSyIpM2lUOXzm4fSi4kWZ4SqG/4zMOoWOB732mGq93+iEa75NE7f8gRj/OmlVegHWg1ADqwFuAamoS+g5cgNhxrInXL023u9ULNadGaXGAyeLiFebPXZHd+pWA1zHvJcp/HDIEtR6dZcFMVlmceC8e8NRh X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2026 14:01:51.6702 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8fadb0c9-dff3-47a9-cec7-08de7f76bed6 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: SJ1PEPF000023CE.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH1PR12MB9599 Content-Type: text/plain; charset="utf-8" Some future AMD processors have feature named "CPPC Performance Priority" which lets userspace specify different floor performance levels for different CPUs. The platform firmware takes these different floor performance levels into consideration while throttling the CPUs under power/thermal constraints. The presence of this feature is indicated by bit 16 of the EDX register for CPUID leaf 0x80000007. More details can be found in AMD Publication titled "AMD64 Collaborative Processor Performance Control (CPPC) Performance Priority" Revision 1.10. Define a new feature bit named X86_FEATURE_CPPC_PERF_PRIO to map to CPUID 0x80000007.EDX[16]. Reviewed-by: Borislav Petkov (AMD) Signed-off-by: Gautham R. Shenoy --- Link to AMD publication describing this feature: https://docs.amd.com/v/u/e= n-US/69206_1.10_AMD64_CPPC_PUB arch/x86/include/asm/cpufeatures.h | 2 +- arch/x86/kernel/cpu/scattered.c | 1 + tools/arch/x86/include/asm/cpufeatures.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpuf= eatures.h index dbe104df339b8..86d17b195e794 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -415,7 +415,7 @@ */ #define X86_FEATURE_OVERFLOW_RECOV (17*32+ 0) /* "overflow_recov" MCA over= flow recovery support */ #define X86_FEATURE_SUCCOR (17*32+ 1) /* "succor" Uncorrectable error con= tainment and recovery */ - +#define X86_FEATURE_CPPC_PERF_PRIO (17*32+ 2) /* CPPC Floor Perf support */ #define X86_FEATURE_SMCA (17*32+ 3) /* "smca" Scalable MCA */ =20 /* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */ diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattere= d.c index 42c7eac0c387b..837d6a4b0c282 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -52,6 +52,7 @@ static const struct cpuid_bit cpuid_bits[] =3D { { X86_FEATURE_CPB, CPUID_EDX, 9, 0x80000007, 0 }, { X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 }, { X86_FEATURE_AMD_FAST_CPPC, CPUID_EDX, 15, 0x80000007, 0 }, + { X86_FEATURE_CPPC_PERF_PRIO, CPUID_EDX, 16, 0x80000007, 0 }, { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, { X86_FEATURE_X2AVIC_EXT, CPUID_ECX, 6, 0x8000000a, 0 }, { X86_FEATURE_COHERENCY_SFW_NO, CPUID_EBX, 31, 0x8000001f, 0 }, diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/incl= ude/asm/cpufeatures.h index c3b53beb13007..1f1aeeb151337 100644 --- a/tools/arch/x86/include/asm/cpufeatures.h +++ b/tools/arch/x86/include/asm/cpufeatures.h @@ -414,7 +414,7 @@ */ #define X86_FEATURE_OVERFLOW_RECOV (17*32+ 0) /* "overflow_recov" MCA over= flow recovery support */ #define X86_FEATURE_SUCCOR (17*32+ 1) /* "succor" Uncorrectable error con= tainment and recovery */ - +#define X86_FEATURE_CPPC_PERF_PRIO (17*32+ 2) /* CPPC Floor Perf support */ #define X86_FEATURE_SMCA (17*32+ 3) /* "smca" Scalable MCA */ =20 /* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */ --=20 2.34.1 From nobody Tue Apr 7 22:02:26 2026 Received: from BN8PR05CU002.outbound.protection.outlook.com (mail-eastus2azon11011026.outbound.protection.outlook.com [52.101.57.26]) (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 60237283FC5; Wed, 11 Mar 2026 14:01:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.57.26 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237720; cv=fail; b=JVJDGUdLGlgTvgQtd13VGLDggOAv7SOH7Kka9dj7hMRz51Mf2bfPJEJPNWxSM2s5L+WngYEQt2VmN5Sy4h1yIeIEy/ZL4vhi3gDdLgdpAoN3NMLBeO9JPsAEx9xptydtDkSX0i3dSPGvtFdId2ug7vxb3TmNfWOlzE6SNJWUDcQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237720; c=relaxed/simple; bh=+vrgG7jLvK4AJDGuFdzJQ1y+oGg1i/b0DTTvmowfUyk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bcHWBFm7vjNOGQDJ3e6l6g8CzKTi/RW/Uyp0MDe24LzBteFem0qsKd4D+jNqwZXYhANpOEmBXqUO7vHyURBze4tEhurb9dzSP4gEDJJmVMSFiv23HjvPwAFmlf8xj6PGLRiRnw5PSREbIsCPQvWBvfK6Iqmq2FkcqGwEBXgx+Ho= 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=riJtbky5; arc=fail smtp.client-ip=52.101.57.26 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="riJtbky5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=m56ceGkx51bCMlPjLDspNvNymhjop6EQI0W5VABxKZCYNHKVrrqHnLRTV7LE+SMRneQnOPiuLvREOxOyDPRqtpqBwPS+KjD/vGOx0PrQfgLZUjWoKn3C0Ehq7qW7XHgiqZR8+szh30CokTG9WozRTrSf9O+zrRRsU2zfhjIRd0CJQpzDdpKx5oRl0OpdXgnjE1Yv0aL4yaHsAHOMe3NHnJsibl0fu7JZ07vLeyyg6bscZuuSB25yfJPYViT2YTp97zmZLWcarnCnlek4xXcYUMSyM2LA5Cja3W5J+2DHLzSNNHqyGsA9eqeDH5wWFz2HFt2NBos96qKERw201/apqQ== 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=JIs5JjfGtEtwSgGlgXMffYi2vpyIrXwSsq/ya221OiE=; b=TMhqQ6VtwtwlrzvNzxo1k4GfxhLxJZ2sLq1zyqKzwy6g0stAhORKLWGlZe/fGWGfCDIgUh8PtCjAINCXUfKXoYMyWuhZDx5eCMOA1kH8A5y6tR0h+bmRnbZXY82V4enhZqj+NEtY0/u+/USdZhN/ksKrZQQTcLrhWZpXLGqt6E33Q0MYY9ZnUcp9ShBX+e7vLnmHZIp0EiHFl16Q9uqvBZUVLI6kiyboi0pc35f1fSDzBtSq2qaczgMSD14tkj0mrSD2iXozYf0hQkvNn3bHZzmHR8uskWJ3QdzNEQCBRyde3Okq9/b8XQpExQHcCEjqbnDz6NvwDef8EQQ5X6NzmQ== 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=JIs5JjfGtEtwSgGlgXMffYi2vpyIrXwSsq/ya221OiE=; b=riJtbky5+XRo+vgOzXc+Oj+q+EZVYKTm4alYFEQ0MF9NoEYJnPHrSs4K0b87Sol+C9+LQm2dpnGFLqbSNCkvBHJhtvpHBL65fcRF5Yv2uW4ODKa2rnKGPjxcMcdGuIXnBmXLIMd4klgOHKUBOhesgwx4rTZIi3h8Q/w2GKgLBqM= Received: from BYAPR05CA0012.namprd05.prod.outlook.com (2603:10b6:a03:c0::25) by PH7PR12MB8594.namprd12.prod.outlook.com (2603:10b6:510:1b3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9700.11; Wed, 11 Mar 2026 14:01:54 +0000 Received: from SJ1PEPF000023CD.namprd02.prod.outlook.com (2603:10b6:a03:c0:cafe::a7) by BYAPR05CA0012.outlook.office365.com (2603:10b6:a03:c0::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9678.24 via Frontend Transport; Wed, 11 Mar 2026 14:01:54 +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 SJ1PEPF000023CD.mail.protection.outlook.com (10.167.244.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.18 via Frontend Transport; Wed, 11 Mar 2026 14:01:54 +0000 Received: from BLRRASHENOY1.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.17; Wed, 11 Mar 2026 09:01:51 -0500 From: "Gautham R. Shenoy" To: Mario Limonciello , "Rafael J . Wysocki" , Viresh Kumar , K Prateek Nayak CC: , , "Gautham R. Shenoy" Subject: [PATCH v2 5/9] amd-pstate: Add support for CPPC_REQ2 and FLOOR_PERF Date: Wed, 11 Mar 2026 19:31:12 +0530 Message-ID: <20260311140116.19604-6-gautham.shenoy@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260311140116.19604-1-gautham.shenoy@amd.com> References: <20260311140116.19604-1-gautham.shenoy@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: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023CD:EE_|PH7PR12MB8594:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d60c395-48f0-4e23-e3fa-08de7f76c043 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|1800799024|36860700016|22082099003|56012099003|18002099003; X-Microsoft-Antispam-Message-Info: sM7DVWJYAahy0otlgft9VYSvovUL17ceZ5M3ES7puUo255C/oFppd8t0XiXldgpcchOWjcLdOeZtSmwRwQcmMEuq78e06WweJooO99UTT+q3kC5woFVwSpKwyUqjyG6u/5kJ08MkiGfi6hDJU5n82Kfkp+oWG6VDJgGWqdqLxc1QErNTaYHiQqTLC14uAhjl0SUjnfGEslrgBuJd4Q3hwU89dT/KbQujeorxVdaOtODfNiwos9H1Lrs7s190mFFvu2p1pdxHjxvQDpoNSRJbBhbAyxURxcoYYKM/a4fjix+SE2+RVK+bZQzkYmWdwhroSFUqaocVIgX3GO55kfzxBqnAMjoqO0Atkm3JIehLKs7G/gvkZGSX+Sr5aHolf3v6R+RWRLnjrL1NDTMCD/lg2UIQgH6LuusA0CePMWPoM60oJ+zFeXKyCYBwcBMoTnG4OZnYx0oJcB+aoQvmJ1SnMx0isdZu1atKJtljjXJe6G9nHNLegQkzvtzEhI4oKwVgi5W0aAhPFU3f88s4Tpi/7U3HQn5An0HKtQoQ3Z/NMNb+O7nGydAl2F6Rq85ZQsn2h7Q6yKPXoiWq/ZbxRuhpP4O9BULc4ISpfMeNWC0ZEAxtQPA7RMYk0CB/0ihDkM+wQgjyLFmrc5pVRrU3DB4AL3UYHbyDD4m/M2dsR6jOGuGlmz2gH1tCVEs59kfgkWr86BSnH1U3CY0bLAa61KFshB7BK1O6bR7d3AjpQg4Y9+w+dG8JOvHA7sh8SmYdPv+f1LES4/Rm27D0Xmb/OwJbwQ== 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)(376014)(82310400026)(1800799024)(36860700016)(22082099003)(56012099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ufoHNeS7yKAJl8M9Tymbo/44R2x+gKwT00XhNiSPvXPPh669XfE0F0XKirQrA/8xBaAO1+1mlbhjlNzcVXa258bSCbciZFrBoyJN16HyFLunfzOm8ko+dAXXgTSN0gEy6KbSqwuQljhKuwsW9zs8qL4WQQMoAt5ZDP/GVEzqyUGHuaizzBHmzCdU/pIp2gZFakVmXzKNm0HgbFcLoRMoVX2b02CIG6cHz9ucfbmVp1FfUP1w+pUCv05n2qOUEdwvLU5KQDi1Bc/AC5+LYewb7NRqx1ZWTtVHDuxoULsYDVsfjVHqq3FOJgvm7HHbRwINPQoQs9FppoLxqe2vsa5mYvOgAjZWgJFtL7LIodzmzVXDdXtHlHOMX4Anse4GAEo3DtINGSWMJVxg79+ca4ZznrCDW+3L0zYxunW7uQadtY8L1OUsi4K+rdLmiQ2NY6SB X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2026 14:01:54.0950 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d60c395-48f0-4e23-e3fa-08de7f76c043 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: SJ1PEPF000023CD.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8594 Content-Type: text/plain; charset="utf-8" Some future AMD processors have feature named "CPPC Performance Priority" which lets userspace specify different floor performance levels for different CPUs. The platform firmware takes these different floor performance levels into consideration while throttling the CPUs under power/thermal constraints. The presence of this feature is indicated by bit 16 of the EDX register for CPUID leaf 0x80000007. More details can be found in AMD Publication titled "AMD64 Collaborative Processor Performance Control (CPPC) Performance Priority" Revision 1.10. The number of distinct floor performance levels supported on the platform will be advertised through the bits 32:39 of the MSR_AMD_CPPC_CAP1. Bits 0:7 of a new MSR MSR_AMD_CPPC_REQ2 (0xc00102b5) will be used to specify the desired floor performance level for that CPU. Add support for the aforementioned MSR_AMD_CPPC_REQ2, and macros for parsing and updating the relevant bits from MSR_AMD_CPPC_CAP1 and MSR_AMD_CPPC_REQ2. On boot if the default value of the MSR_AMD_CPPC_REQ2[7:0] (Floor Perf) is lower than CPPC.lowest_perf, and thus invalid, initialize it to MSR_AMD_CPPC_CAP1.nominal_perf which is a sane default value. Signed-off-by: Gautham R. Shenoy Reviewed-by: Mario Limonciello (AMD) --- Link to AMD publication describing this feature: https://docs.amd.com/v/u/e= n-US/69206_1.10_AMD64_CPPC_PUB arch/x86/include/asm/msr-index.h | 5 +++ drivers/cpufreq/amd-pstate.c | 70 ++++++++++++++++++++++++++++++++ drivers/cpufreq/amd-pstate.h | 5 +++ 3 files changed, 80 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index 6673601246b38..e126c7fb69cf6 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -765,12 +765,14 @@ #define MSR_AMD_CPPC_CAP2 0xc00102b2 #define MSR_AMD_CPPC_REQ 0xc00102b3 #define MSR_AMD_CPPC_STATUS 0xc00102b4 +#define MSR_AMD_CPPC_REQ2 0xc00102b5 =20 /* Masks for use with MSR_AMD_CPPC_CAP1 */ #define AMD_CPPC_LOWEST_PERF_MASK GENMASK(7, 0) #define AMD_CPPC_LOWNONLIN_PERF_MASK GENMASK(15, 8) #define AMD_CPPC_NOMINAL_PERF_MASK GENMASK(23, 16) #define AMD_CPPC_HIGHEST_PERF_MASK GENMASK(31, 24) +#define AMD_CPPC_FLOOR_PERF_CNT_MASK GENMASK_ULL(39, 32) =20 /* Masks for use with MSR_AMD_CPPC_REQ */ #define AMD_CPPC_MAX_PERF_MASK GENMASK(7, 0) @@ -778,6 +780,9 @@ #define AMD_CPPC_DES_PERF_MASK GENMASK(23, 16) #define AMD_CPPC_EPP_PERF_MASK GENMASK(31, 24) =20 +/* Masks for use with MSR_AMD_CPPC_REQ2 */ +#define AMD_CPPC_FLOOR_PERF_MASK GENMASK(7, 0) + /* AMD Performance Counter Global Status and Control MSRs */ #define MSR_AMD64_PERF_CNTR_GLOBAL_STATUS 0xc0000300 #define MSR_AMD64_PERF_CNTR_GLOBAL_CTL 0xc0000301 diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index fb5d7bb320c15..3122ad5af6f47 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -329,6 +329,63 @@ static inline int amd_pstate_set_epp(struct cpufreq_po= licy *policy, u8 epp) return static_call(amd_pstate_set_epp)(policy, epp); } =20 +static int amd_pstate_set_floor_perf(struct cpufreq_policy *policy, u8 per= f) +{ + struct amd_cpudata *cpudata =3D policy->driver_data; + u64 value, prev; + int ret; + + if (!cpu_feature_enabled(X86_FEATURE_CPPC_PERF_PRIO)) + return 0; + + value =3D prev =3D READ_ONCE(cpudata->cppc_req2_cached); + FIELD_MODIFY(AMD_CPPC_FLOOR_PERF_MASK, &value, perf); + + if (value =3D=3D prev) + return 0; + + ret =3D wrmsrq_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ2, value); + if (ret) { + pr_err("failed to set CPPC REQ2 value. Error (%d)\n", ret); + return ret; + } + + WRITE_ONCE(cpudata->cppc_req2_cached, value); + + return ret; +} + +static int amd_pstate_init_floor_perf(struct cpufreq_policy *policy) +{ + struct amd_cpudata *cpudata =3D policy->driver_data; + u8 floor_perf; + u64 value; + int ret; + + if (!cpu_feature_enabled(X86_FEATURE_CPPC_PERF_PRIO)) + return 0; + + ret =3D rdmsrq_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ2, &value); + if (ret) { + pr_err("failed to read CPPC REQ2 value. Error (%d)\n", ret); + return ret; + } + + WRITE_ONCE(cpudata->cppc_req2_cached, value); + floor_perf =3D FIELD_GET(AMD_CPPC_FLOOR_PERF_MASK, + cpudata->cppc_req2_cached); + + /* Set a sane value for floor_perf if the default value is invalid */ + if (floor_perf < cpudata->perf.lowest_perf) { + floor_perf =3D cpudata->perf.nominal_perf; + ret =3D amd_pstate_set_floor_perf(policy, floor_perf); + if (ret) + return ret; + } + + return 0; +} + static int shmem_set_epp(struct cpufreq_policy *policy, u8 epp) { struct amd_cpudata *cpudata =3D policy->driver_data; @@ -426,6 +483,7 @@ static int msr_init_perf(struct amd_cpudata *cpudata) perf.lowest_perf =3D FIELD_GET(AMD_CPPC_LOWEST_PERF_MASK, cap1); WRITE_ONCE(cpudata->perf, perf); WRITE_ONCE(cpudata->prefcore_ranking, FIELD_GET(AMD_CPPC_HIGHEST_PERF_MAS= K, cap1)); + WRITE_ONCE(cpudata->floor_perf_cnt, FIELD_GET(AMD_CPPC_FLOOR_PERF_CNT_MAS= K, cap1)); =20 return 0; } @@ -1036,6 +1094,12 @@ static int amd_pstate_cpu_init(struct cpufreq_policy= *policy) if (cpu_feature_enabled(X86_FEATURE_CPPC)) policy->fast_switch_possible =3D true; =20 + ret =3D amd_pstate_init_floor_perf(policy); + if (ret) { + dev_err(dev, "Failed to initialize Floor Perf (%d)\n", ret); + goto free_cpudata1; + } + ret =3D freq_qos_add_request(&policy->constraints, &cpudata->req[0], FREQ_QOS_MIN, FREQ_QOS_MIN_DEFAULT_VALUE); if (ret < 0) { @@ -1597,6 +1661,12 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_po= licy *policy) if (ret) goto free_cpudata1; =20 + ret =3D amd_pstate_init_floor_perf(policy); + if (ret) { + dev_err(dev, "Failed to initialize Floor Perf (%d)\n", ret); + goto free_cpudata1; + } + current_pstate_driver->adjust_perf =3D NULL; =20 return 0; diff --git a/drivers/cpufreq/amd-pstate.h b/drivers/cpufreq/amd-pstate.h index cb45fdca27a6c..0c587ca200199 100644 --- a/drivers/cpufreq/amd-pstate.h +++ b/drivers/cpufreq/amd-pstate.h @@ -62,9 +62,12 @@ struct amd_aperf_mperf { * @cpu: CPU number * @req: constraint request to apply * @cppc_req_cached: cached performance request hints + * @cppc_req2_cached: cached value of MSR_AMD_CPPC_REQ2 * @perf: cached performance-related data * @prefcore_ranking: the preferred core ranking, the higher value indicat= es a higher * priority. + * @floor_perf_cnt: Cached value of the number of distinct floor + * performance levels supported * @min_limit_freq: Cached value of policy->min (in khz) * @max_limit_freq: Cached value of policy->max (in khz) * @nominal_freq: the frequency (in khz) that mapped to nominal_perf @@ -87,10 +90,12 @@ struct amd_cpudata { =20 struct freq_qos_request req[2]; u64 cppc_req_cached; + u64 cppc_req2_cached; =20 union perf_cached perf; =20 u8 prefcore_ranking; + u8 floor_perf_cnt; u32 min_limit_freq; u32 max_limit_freq; u32 nominal_freq; --=20 2.34.1 From nobody Tue Apr 7 22:02:26 2026 Received: from CY7PR03CU001.outbound.protection.outlook.com (mail-westcentralusazon11010005.outbound.protection.outlook.com [40.93.198.5]) (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 4A2E43630BF; Wed, 11 Mar 2026 14:02:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.198.5 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237724; cv=fail; b=olG0Sfer+W1+/TNkWYZT+AWxhdlwLNXxaY1+Yv/qJdXoS7hj2nO42O6RO/JyxEN9cv5+g6qFBfwjbn41nYWERyLLL2wEV14aqOQw20wNlothyK60JKm1J2zELjoEeg8phy6K+jxI8BkYU8M/KOrex0o3KQmf9lcWqXbs3xKoSnM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237724; c=relaxed/simple; bh=n1Tl38Sn6lxI0OmhSE5nm83xT1r+US2/yBIpGuqLFIE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C+L6WZejUmr67e/z+XJAH5d3CCpdnqBghKk6goOvI1NJCD2vKq/N7Jsx4giryLi1nk/k+JQeZVSp63TDcZx7sXX9eEDeUSQxnFibXPryVlM3/dMUPnJEhFtFcR0AeAcFl5kw+ZM95QV39cz8XQ/mILXDZBfkLjVxnWpdl4A4QUY= 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=Uq7xvWbO; arc=fail smtp.client-ip=40.93.198.5 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="Uq7xvWbO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mra2fP7o/Vc3VCXquldfCrqVl0AU11M1C+drR2MTdz93DN2YZuxvYR+35hdEBrxHxu4+2TG7rQxLxNMu/zyjmYK0MMgtN32dUFlfc2pE3441VMxxSmG3XPRY+WsnQ7gnXxj2YfrcJPp/oGhC4m9k49KVkXoDZ5DIhvFfrjN+Q5aQ32WLKmui/M8OP8ZjyUYwTyq40VVnfRvYidN/BlDdn0gFD2Nq7GK8gKSnQvQqpn7a9SLaBZbK3+uBxg7bg5vmHTusFIak7UlnoioE6BkHvo1bGQp9yTn+S1TpB4yjmo5tEOBZB03sn4ZHcZuwKm/VW0WoLegT8UAPZF6ezObyZA== 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=hfZxwt5XGXotEdEgKtkjcXWUiYeMwfAWNtQCMY9WUWc=; b=NFU3Xy6BgdNPs2KnZse9dpYuNdoLdT4NJk0jeS0DpJiikD/3sgGwrYpVlkf1oa3HP4Y5ubsnzAyZi8FFnRTkZ2P/v819h3vfTGE0VIrbfgIoJl4XWjQYQaziJGbUH16R8CoFxm4LDoSRif1dQrXd2tToZYHJ+qs6/HSkMMMhfh0HgpybuqTi2yEZ8eulwWeohBeASjmbd3md5KSu+ortKoZRRVg7YlFehPK7K3TADYv/W9r+DuKtC6ck+Qt9exlT5u2NMjS4ao29rIR0vI0LMZGOWMsYMqXprvvlz0VyFU5pNsJoJgKr1g4spRxyj6Gy+PgBqxXLf32LZuJ/K3TxsQ== 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=hfZxwt5XGXotEdEgKtkjcXWUiYeMwfAWNtQCMY9WUWc=; b=Uq7xvWbOVmjUH9HD391EPwZFbx/2djhy4jYwjYjCwHDp9Rw2TKBGM3lI3ItdjKQDwG2zsSDVr7Ah8++CkdzbUWXUAgN/TOucqfi4lSmq7lZGY9t/IS5okPO2u7j8K8s74JYTpw392oghgK6fGxTx/5BJ3JA6fRxpb4bpwRna/rw= Received: from SJ2PR07CA0004.namprd07.prod.outlook.com (2603:10b6:a03:505::10) by IA1PR12MB7494.namprd12.prod.outlook.com (2603:10b6:208:41a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9723.4; Wed, 11 Mar 2026 14:01:56 +0000 Received: from SJ1PEPF000023D2.namprd02.prod.outlook.com (2603:10b6:a03:505:cafe::85) by SJ2PR07CA0004.outlook.office365.com (2603:10b6:a03:505::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9678.26 via Frontend Transport; Wed, 11 Mar 2026 14:01:49 +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 SJ1PEPF000023D2.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.18 via Frontend Transport; Wed, 11 Mar 2026 14:01:56 +0000 Received: from BLRRASHENOY1.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.17; Wed, 11 Mar 2026 09:01:54 -0500 From: "Gautham R. Shenoy" To: Mario Limonciello , "Rafael J . Wysocki" , Viresh Kumar , K Prateek Nayak CC: , , "Gautham R. Shenoy" Subject: [PATCH v2 6/9] amd-pstate: Add sysfs support for floor_freq and floor_count Date: Wed, 11 Mar 2026 19:31:13 +0530 Message-ID: <20260311140116.19604-7-gautham.shenoy@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260311140116.19604-1-gautham.shenoy@amd.com> References: <20260311140116.19604-1-gautham.shenoy@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: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D2:EE_|IA1PR12MB7494:EE_ X-MS-Office365-Filtering-Correlation-Id: 0abb3697-900f-4d0b-b563-08de7f76c1be X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|376014|82310400026|22082099003|56012099003|18002099003; X-Microsoft-Antispam-Message-Info: DixFlcteZ0jSB994bKmkscYNq/664PoNqZAffT2R7EIbidAoiRwMtAWe+jT78AR6y4NyLfVo1i/lW3vAAIWIgU3HoGnRlLNpLHpJUGkzLyawhSM/ZkexR3iZV4tUXCP5N0jgGuM2sP6VcWbAYuLZfiMd/gIXcbTfVUGlSqgHNzJjyl6o0DiBxpgOhEJXy53nRoI+FSnvpwW8tqTgjzumBvJeopAU9u3cUSQqnsHwG/YFHVEHnScxtLcDsLxUx5v8XoCmyPee1hz+i7bufw7fQoQL6MwzoAKiIP6SeZd+PJLGuVDifqB0j1bKkuN90djKvW7J246pPelUXhLdHvtgc9N4gHCXQ09hs6DMhJFyclXA1/WxwOzytlJO9Fy0UNES7WnitZeunhHu1y/8rOAFCTwhm6CbnO5SOm8h7sdK7sDYc5S4YsKyznOi2JOE44X9J3WWHrZdJGVZQ+917Bgmea/UWAUA98WugpIIFOHvqNwz8urAiNPAbzks50ss07PYjjIN+TrEAtoUWSqw+A6+f4T5QbneSBY26jTAKKCU5CNeqf50mrKXAKHOI23UU2l741iNlPdt/qsYWHlmhlAuNN9QBOXeux9q925A28O7dvmyUjMuiYXxyo1jkygfJ//8Hmi/FisP9Lcslzg4sH8hCaLFELAA7N06iBy6FIhB0eSRQbAf4OkYi9VGjiX+edfiUk1QMZTiXZ+UxtJmeHToyODqQcmDMIOYAWIGn4+NqjLzeP/KhLkU9Mwa0xrzVtg3AikLAy0QcflYyF5k3nEE0g== 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)(36860700016)(376014)(82310400026)(22082099003)(56012099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Xzc8jGB2AYRKzcjzVfuZdpIKTUWT5/2D+oQZgimJZ+/A+LY5tRNcf4Ec8V/RalV/RqIS9z/fjdik7dztWMic144PlF9RI/EWtww9XK0Z5PHVW2yAIQtOZRsCLTrIAfNvf2ywYFxZDhe+/qGbdP/EafMTjJHFWKGQ0DezKdXmEfrWy00aUG2CebntRxKwbGFD8KBtiZbpm4urhSn1hA4JBJiNvs8PyRqGSFKejPYJaMz84+Pas2ZJANt7RbgceCRe2GLFNLCmvZP6gWzWwXm33T7BsZholPRVRSbMk5w57liFL4JkwiIg+1mfyIZKMsJV17y9zqF9NJ3Pk4nL4adavWlrR9QBxP+4fKW9wM7dE8V9SoaJguJo809go981mCTyqnQhdwciAo7FVpiS0HduSOwNZfys0w6dU5UFbMpecKsia2oLssBIpJUsn/Mg1Roc X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2026 14:01:56.5827 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0abb3697-900f-4d0b-b563-08de7f76c1be 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: SJ1PEPF000023D2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7494 Content-Type: text/plain; charset="utf-8" When Floor Performance feature is supported by the platform, expose two sysfs files: * amd_pstate_floor_freq to allow userspace to request the floor frequency for each CPU. * amd_pstate_floor_count which advertises the number of distinct levels of floor frequencies supported on this platform. Signed-off-by: Gautham R. Shenoy Reviewed-by: Mario Limonciello (AMD) --- drivers/cpufreq/amd-pstate.c | 50 ++++++++++++++++++++++++++++++++++++ drivers/cpufreq/amd-pstate.h | 2 ++ 2 files changed, 52 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 3122ad5af6f47..54b650f3b4e78 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -383,6 +383,8 @@ static int amd_pstate_init_floor_perf(struct cpufreq_po= licy *policy) return ret; } =20 + cpudata->floor_freq =3D perf_to_freq(cpudata->perf, cpudata->nominal_freq, + floor_perf); return 0; } =20 @@ -1284,6 +1286,44 @@ static ssize_t show_energy_performance_preference( return sysfs_emit(buf, "%s\n", energy_perf_strings[preference]); } =20 +static ssize_t store_amd_pstate_floor_freq(struct cpufreq_policy *policy, + const char *buf, size_t count) +{ + struct amd_cpudata *cpudata =3D policy->driver_data; + union perf_cached perf =3D READ_ONCE(cpudata->perf); + unsigned int freq; + u8 floor_perf; + int ret; + + ret =3D kstrtouint(buf, 0, &freq); + if (ret) + return ret; + + floor_perf =3D freq_to_perf(perf, cpudata->nominal_freq, freq); + ret =3D amd_pstate_set_floor_perf(policy, floor_perf); + + if (!ret) + cpudata->floor_freq =3D freq; + + return ret ?: count; +} + +static ssize_t show_amd_pstate_floor_freq(struct cpufreq_policy *policy, c= har *buf) +{ + struct amd_cpudata *cpudata =3D policy->driver_data; + + return sysfs_emit(buf, "%u\n", cpudata->floor_freq); +} + + +static ssize_t show_amd_pstate_floor_count(struct cpufreq_policy *policy, = char *buf) +{ + struct amd_cpudata *cpudata =3D policy->driver_data; + u8 count =3D cpudata->floor_perf_cnt; + + return sysfs_emit(buf, "%u\n", count); +} + cpufreq_freq_attr_ro(amd_pstate_max_freq); cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq); =20 @@ -1292,6 +1332,8 @@ cpufreq_freq_attr_ro(amd_pstate_prefcore_ranking); cpufreq_freq_attr_ro(amd_pstate_hw_prefcore); cpufreq_freq_attr_rw(energy_performance_preference); cpufreq_freq_attr_ro(energy_performance_available_preferences); +cpufreq_freq_attr_rw(amd_pstate_floor_freq); +cpufreq_freq_attr_ro(amd_pstate_floor_count); =20 struct freq_attr_visibility { struct freq_attr *attr; @@ -1316,6 +1358,12 @@ static bool epp_visibility(void) return cppc_state =3D=3D AMD_PSTATE_ACTIVE; } =20 +/* Determines whether amd_pstate_floor_freq related attributes should be v= isible */ +static bool floor_freq_visibility(void) +{ + return cpu_feature_enabled(X86_FEATURE_CPPC_PERF_PRIO); +} + static struct freq_attr_visibility amd_pstate_attr_visibility[] =3D { {&amd_pstate_max_freq, always_visible}, {&amd_pstate_lowest_nonlinear_freq, always_visible}, @@ -1324,6 +1372,8 @@ static struct freq_attr_visibility amd_pstate_attr_vi= sibility[] =3D { {&amd_pstate_hw_prefcore, prefcore_visibility}, {&energy_performance_preference, epp_visibility}, {&energy_performance_available_preferences, epp_visibility}, + {&amd_pstate_floor_freq, floor_freq_visibility}, + {&amd_pstate_floor_count, floor_freq_visibility}, }; =20 static struct freq_attr **get_freq_attrs(void) diff --git a/drivers/cpufreq/amd-pstate.h b/drivers/cpufreq/amd-pstate.h index 0c587ca200199..ab4caea39f0e8 100644 --- a/drivers/cpufreq/amd-pstate.h +++ b/drivers/cpufreq/amd-pstate.h @@ -72,6 +72,7 @@ struct amd_aperf_mperf { * @max_limit_freq: Cached value of policy->max (in khz) * @nominal_freq: the frequency (in khz) that mapped to nominal_perf * @lowest_nonlinear_freq: the frequency (in khz) that mapped to lowest_no= nlinear_perf + * @floor_freq: Cached value of the user requested floor_freq * @cur: Difference of Aperf/Mperf/tsc count between last and current samp= le * @prev: Last Aperf/Mperf/tsc count value read from register * @freq: current cpu frequency value (in khz) @@ -100,6 +101,7 @@ struct amd_cpudata { u32 max_limit_freq; u32 nominal_freq; u32 lowest_nonlinear_freq; + u32 floor_freq; =20 struct amd_aperf_mperf cur; struct amd_aperf_mperf prev; --=20 2.34.1 From nobody Tue Apr 7 22:02:26 2026 Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012056.outbound.protection.outlook.com [52.101.53.56]) (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 657C1373BE2; Wed, 11 Mar 2026 14:02:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.53.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237723; cv=fail; b=YAf+fiL7Xj5NFbZ7aQMx3DFRImoerYxpn/p9o16VLm8MDWLKBsGpUZ3V7ndpL5SQ+qNV2VfShO1nZMyxyMbE+N5WEFd6GKTPWGCHR+TaGdKfDdogkUt8q85dBywynvo3cY4EOugs7ol9SBwEsqyOwynWonGR5PzSU+L5qZOOw4g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237723; c=relaxed/simple; bh=Cg63vYR3AFGnbyjvM8T8iAtjW80ivsKuDzbuRP/oHvA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QCngznscgur9yGNCDwtMPu7LXBsvvuz17mOmoy8paJXEan/fqfkah9mVD+gCrcbmT9+uYTGYhBfTG/Lxsb9e5oZynMB0gONyD1LSlumD/nFefNelsYh1y7k7tO4XUC36JCbnEgkdWDTmSkcStnFSn9trALFLdp4c3ERHa0n/dGU= 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=OMOAxcIW; arc=fail smtp.client-ip=52.101.53.56 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="OMOAxcIW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=izZhAlaAnp9vThrRDNEhBGZ6k+P7xkWV0D3hU21J3oB2EmJGHxUz7zv9khpte0CWua/BayB+FAt0ZEWQyRLkMpWEjpBynTjihzABM3zT2CpMgYkDSmF+Jiyt5jWBljxoxhj0NJDUbPO8ZTIMR5jVuap+9m3cNkT47/ItZXRkS2zLkBkqtE8enufqbrXN3hH1dDZHG88dVQ2WGLlA8qOZfBBfXGdmOPUQWnZV6BKIzMjDb2/xTltO1CsJ7mIonY5pCfc81V8/Ahrj6WixZK2BfrzfAIsuadLl6/9GXR4nAoDwPmAfpyJSy6KsK2qHLrLuFTczmd4NlK8mEyvEtY+B1w== 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=wujOmyHpRdf6rdJ573nRhT4OOBNwo3Es00kWzGiV7kQ=; b=QFfPoMLc8cjk9/USia9C1Bz/YSzDLNwAMpaDpy/ik9hhRDGxNppVb2grzESlZfDVpBMzEb11okaF18JaRH2GSy9Sxm1nE/SQ8o9V94qeqhbVaj3aPhzuRt9O2prWvDS1NPEf6aPX+Pl8JPWe5Px1h5WAc4fj526EFaFnofzc3hE+LtR3bnU/CNLVVqKExk3wpHIlk+wHyq0DJYSO2pF3zgSWg/DV1DPrxA50GkB3fbnQ6yU/BQ41hmVRB2ZAG4eL9IhDII1/wT3cQ3AE+5yHl4uWhkHELg1TG/yrERH0GACHPGJw7DLFUkNpAb20nu1ZJv38H+c1vlXFcSfHJCdgfQ== 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=wujOmyHpRdf6rdJ573nRhT4OOBNwo3Es00kWzGiV7kQ=; b=OMOAxcIWgxzYIUiV91VI8igpd3FY+x9KPqK+i/b/+ekCrnOVlxps8PQxRWsrIDwNq6hUsiPWNKdFvi7tsn48Kg08RjHBDm2bWYCmUjWnxxwD/wedWJ/kS29sCEOSjrzpA3zsXNXW9sVwjarT5CZdRrloO93lcWNVT5mOnXD+8C4= Received: from SJ2PR07CA0013.namprd07.prod.outlook.com (2603:10b6:a03:505::15) by DS4PR12MB9769.namprd12.prod.outlook.com (2603:10b6:8:2a9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9700.12; Wed, 11 Mar 2026 14:01:59 +0000 Received: from SJ1PEPF000023D2.namprd02.prod.outlook.com (2603:10b6:a03:505:cafe::5c) by SJ2PR07CA0013.outlook.office365.com (2603:10b6:a03:505::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9678.26 via Frontend Transport; Wed, 11 Mar 2026 14:02:01 +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 SJ1PEPF000023D2.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.18 via Frontend Transport; Wed, 11 Mar 2026 14:01:59 +0000 Received: from BLRRASHENOY1.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.17; Wed, 11 Mar 2026 09:01:56 -0500 From: "Gautham R. Shenoy" To: Mario Limonciello , "Rafael J . Wysocki" , Viresh Kumar , K Prateek Nayak CC: , , "Gautham R. Shenoy" Subject: [PATCH v2 7/9] amd-pstate: Introduce a tracepoint trace_amd_pstate_cppc_req2() Date: Wed, 11 Mar 2026 19:31:14 +0530 Message-ID: <20260311140116.19604-8-gautham.shenoy@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260311140116.19604-1-gautham.shenoy@amd.com> References: <20260311140116.19604-1-gautham.shenoy@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: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D2:EE_|DS4PR12MB9769:EE_ X-MS-Office365-Filtering-Correlation-Id: 64b88376-dd40-469b-3ccb-08de7f76c34f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700016|1800799024|376014|18002099003|22082099003|56012099003; X-Microsoft-Antispam-Message-Info: HW50lK4kAig9HyLE8sYFNxatOzs/VkP9jvXF9Dd5YVMdsgzyvYAH7YFGfVxZjmwLyLV0rH9WmVxIhqDiIU0JE7/KZf0oHNjsY96y2kpCi54W2w9KvHKgofu52dZUEOMYOgCS6BEtIyQhxlsFHxxV9JCUHSbIE3Eyu1pUkepl8mfWErg7EPmlIA2POhYRppGHvHO/6AvBUJQw41dI5RYD1DRDJyvrVeTrpIaLR59Z+bkz50BEgvf+shx5Kzfkeg1u2cOBm+5V2dh1cv2MijYrWvRd4staJ2UnCozErcbLYhZnLX9RgTZFGnEreXpS6NqqqDmhQRd20V4piM33Y6SS2d2ovN8lzpmKa43hx67JgHAYdOd2w/crBXAEuZYtBWJF8I+4H8jqNqFM6i5fKDPj//P99a9dcAP3qqRGuxdJt4wAQVf7MxlokGway1AJSUZJdQ5Rf/kwdKiX0dUukxE5hI3T4s/+2/DLoZzQ7rk57MzZWB4Brduk0ET9Lu3WdkkYUztzxtk4JQPV0gzHwGEP/i8XPAJnpk+hg93SYKqlCvZENa0QkOp8sXl06S3YJWTJdAg8JEw5vwnISkj3DTqmYfN1b2UM2Cr0GZNgLXZcSET7jltxf9jGPsVW3kZbUmIl82PFe3aZbzHfSnC97fEzFR+5JxjzQ4cfnph9YuaN6khyywea2dDzydv346KoGBd6iPuylPXL6HSXb0F+kq8TGLpUVOYYMSLeKIGkN2hY0XYdFEmqS+2RAqvDc62/7yKU6KN8bf8OUZ6k0RZ0vzUEhA== 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)(82310400026)(36860700016)(1800799024)(376014)(18002099003)(22082099003)(56012099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sxMKy6Y8Z8axfD2K+eU4meI2pTCSjblXde9uB4y+iwSBmFMskkWuYr53+Og43f152Ybew1BNKe2WBr3CGP82P7kzBtEgohbqydJe2IPYshIMTuNE9xIEtyL5G+Y3T1H1RA3zcG50/MG8ERs4Mx3gRzVQN6i7+7kk/493eyowD5ezmzytvKjI6O1GGd4abtSZ+y0JAUQNDmJN835qAc0cgFeJAxd8parTI/CaIxTc6LDuvVnwltIRnRMqRSWSL4KW5/mbGi9P5N1A1EnhAe37RRLlD2AZ+zhLSHuFbPIEj6E00zxkxeyJm14H5JjpX7J7mHk8sfjVFu+bXZuh9L0JYbj/Lgm+dbnVpdkggrgxIBm4WCeAdnYDYHc8gKNe7ZJ8hmUG1ManBdp0uYOd43M0gBeeaG8xzsb9YUcoNepNLQ6zqPeKzCO32TcaVZWWUaz1 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2026 14:01:59.2016 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 64b88376-dd40-469b-3ccb-08de7f76c34f 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: SJ1PEPF000023D2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS4PR12MB9769 Content-Type: text/plain; charset="utf-8" Introduce a new tracepoint trace_amd_pstate_cppc_req2() to track updates to MSR_AMD_CPPC_REQ2. Invoke this while changing the Floor Perf. Reviewed-by: Mario Limonciello Signed-off-by: Gautham R. Shenoy --- drivers/cpufreq/amd-pstate-trace.h | 35 ++++++++++++++++++++++++++++++ drivers/cpufreq/amd-pstate.c | 14 +++++++++--- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/amd-pstate-trace.h b/drivers/cpufreq/amd-pstat= e-trace.h index 32e1bdc588c52..91fa073b2be48 100644 --- a/drivers/cpufreq/amd-pstate-trace.h +++ b/drivers/cpufreq/amd-pstate-trace.h @@ -133,6 +133,41 @@ TRACE_EVENT(amd_pstate_epp_perf, ) ); =20 +TRACE_EVENT(amd_pstate_cppc_req2, + + TP_PROTO(unsigned int cpu_id, + u8 floor_perf, + bool changed, + int err_code + ), + + TP_ARGS(cpu_id, + floor_perf, + changed, + err_code), + + TP_STRUCT__entry( + __field(unsigned int, cpu_id) + __field(u8, floor_perf) + __field(bool, changed) + __field(int, err_code) + ), + + TP_fast_assign( + __entry->cpu_id =3D cpu_id; + __entry->floor_perf =3D floor_perf; + __entry->changed =3D changed; + __entry->err_code =3D err_code; + ), + + TP_printk("cpu%u: floor_perf=3D%u, changed=3D%u (error =3D %d)", + __entry->cpu_id, + __entry->floor_perf, + __entry->changed, + __entry->err_code + ) +); + #endif /* _AMD_PSTATE_TRACE_H */ =20 /* This part must be outside protection */ diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 54b650f3b4e78..a79c6213a67e4 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -333,6 +333,7 @@ static int amd_pstate_set_floor_perf(struct cpufreq_pol= icy *policy, u8 perf) { struct amd_cpudata *cpudata =3D policy->driver_data; u64 value, prev; + bool changed; int ret; =20 if (!cpu_feature_enabled(X86_FEATURE_CPPC_PERF_PRIO)) @@ -341,17 +342,24 @@ static int amd_pstate_set_floor_perf(struct cpufreq_p= olicy *policy, u8 perf) value =3D prev =3D READ_ONCE(cpudata->cppc_req2_cached); FIELD_MODIFY(AMD_CPPC_FLOOR_PERF_MASK, &value, perf); =20 - if (value =3D=3D prev) - return 0; + changed =3D value !=3D prev; + if (!changed) { + ret =3D 0; + goto out_trace; + } =20 ret =3D wrmsrq_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ2, value); if (ret) { + changed =3D false; pr_err("failed to set CPPC REQ2 value. Error (%d)\n", ret); - return ret; + goto out_trace; } =20 WRITE_ONCE(cpudata->cppc_req2_cached, value); =20 +out_trace: + if (trace_amd_pstate_cppc_req2_enabled()) + trace_amd_pstate_cppc_req2(cpudata->cpu, perf, changed, ret); return ret; } =20 --=20 2.34.1 From nobody Tue Apr 7 22:02:26 2026 Received: from SA9PR02CU001.outbound.protection.outlook.com (mail-southcentralusazon11013039.outbound.protection.outlook.com [40.93.196.39]) (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 D8F47373BE2; Wed, 11 Mar 2026 14:02:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.196.39 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237729; cv=fail; b=dDp8+BwFNmdRhGerG7AvEtYGDVUQGHqYQqC9I34QxX+BvIfCAOicYSNgIJOBaoqABXKMTaSzq8unF0V9GLkj6FL59shjPUCKMwTRpMg3jAE3EszH2r0Y01+FUtrZEAE5aHGf/Bv+dgq2FSyqMDm3DJ5jJysZv9bVdobnvhGiYTI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237729; c=relaxed/simple; bh=A1yHnhB/IYVOd2+W3u/SqDV3u1aRzkm3Sb8Rxq9owic=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BMcP+ubnVilEBXEbruPQH7lhgDcY3mgDy+5+dHnBXrXNGRdVL8Sy3/wofpqX6Z5LwQVfIRlI2W18nNLCetSglypoDc6VgriXdoc9R1jvpDRc5xDgvDOm2fzEGZzvneq0HBVAwcOHCatxYyjVaya6qWx4BmZImymZeD4OBOVpbLQ= 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=hzxNXfHn; arc=fail smtp.client-ip=40.93.196.39 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="hzxNXfHn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=n6XMcQ8wamk99TzPvXbA/krtvQzSCjzJ9+ecvkeFWZYTN/quj/NLnOIsbua7TXSYoMoID5KEQgokL8Ui16ifpq8uya/hg8uA49Iy/159Xr1xbfbXRN84vVvfR9pxd5STeV5QKGBia5960CHwbFLcx2/u3vUw5M6gmFjTnxcqq1BEJONigxiw0rIhMa0YKnVWcD1BQaiGrXuHoF5huJlVg2G7PM9ukyCPE9Yt92J4DHBbw5t6nXcWgpMhxt8Tf7w5p1Yg9OhmoJRxXYCPKfRe4p5RdoMj24i7CH6eOTVw0BeJnTVGGnkTtc1E9xQWrGEsN1oFZssT8qv8BDp2L1gtOg== 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=n0pDnujbxihaJ9jacUUeRsP4e8AtFNDFw9OChWnL/PY=; b=O2G1vrmo0/9dWs3IUK8qdEBA3Quc4/BAjUkxHVzZaR4Xbi/HnO58FNWXycJddqBScA1wJQ9dGt/WShnNMCHH1XxS7tBPkvN+PHrxP/icB7kLMpnC97uJafx8OekFsk/vKuzUNGTujN0XunOKDJTElkOBL++Gb3BvhfMGpXvG+t3cCP4klU846EYUAnkYlm8ALVJefDDnytOWurrPUZ1L+U2I31iD9Y9QOngsciyqjn+77f3mtz/NeBJtTrdus5YEDhGSSzsPa1lqWVP4SBW56ag02dviKIKReCg0cI4pEWP8dZIGBQ5SZQHDZGBaT/jnZ6JyQHIIDv85z7muZg5M1A== 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=n0pDnujbxihaJ9jacUUeRsP4e8AtFNDFw9OChWnL/PY=; b=hzxNXfHn4nfKhmG3ghS1yIzm65tfuJgDJZYh5SDqr/eIEXbUtxBpsA01uMXA5zQEBCEiTuErLk2H3o3ERL4lM1UC8EuRUWCErmlH+SDQIbmEZyWA3GBAMJdYt6n/tvzSDECo3l+G7oY6zAESalvwul/39OHJ2zpcLTwZ53cIzHo= Received: from BY3PR10CA0028.namprd10.prod.outlook.com (2603:10b6:a03:255::33) by SA1PR12MB7247.namprd12.prod.outlook.com (2603:10b6:806:2bb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9700.12; Wed, 11 Mar 2026 14:02:02 +0000 Received: from SJ1PEPF000023CB.namprd02.prod.outlook.com (2603:10b6:a03:255:cafe::71) by BY3PR10CA0028.outlook.office365.com (2603:10b6:a03:255::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9678.25 via Frontend Transport; Wed, 11 Mar 2026 14:01:37 +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 SJ1PEPF000023CB.mail.protection.outlook.com (10.167.244.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.18 via Frontend Transport; Wed, 11 Mar 2026 14:02:01 +0000 Received: from BLRRASHENOY1.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.17; Wed, 11 Mar 2026 09:01:59 -0500 From: "Gautham R. Shenoy" To: Mario Limonciello , "Rafael J . Wysocki" , Viresh Kumar , K Prateek Nayak CC: , , "Gautham R. Shenoy" , Jonathan Corbet , "Shuah Khan" Subject: [PATCH v2 8/9] Documentation/amd-pstate: List prefcore related sysfs files Date: Wed, 11 Mar 2026 19:31:15 +0530 Message-ID: <20260311140116.19604-9-gautham.shenoy@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260311140116.19604-1-gautham.shenoy@amd.com> References: <20260311140116.19604-1-gautham.shenoy@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: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023CB:EE_|SA1PR12MB7247:EE_ X-MS-Office365-Filtering-Correlation-Id: 63853274-a090-40a4-c2c0-08de7f76c4e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|82310400026|36860700016|22082099003|18002099003|56012099003; X-Microsoft-Antispam-Message-Info: z21Tc6RZ1aj+eXBPJjtN4DzzPvxlPec7eBzkakQQZ8UBt+NoVpauforlvMRrHqaKgH2blaYTV/BAOt0D6xZ8X1ql2ZBnrrNtnZrwPpOnzQg7Lvrup4V+/wDWF9syGJuS0tga7yvqW03Z2oVSRZVe9NOVc60DjteVUo2f2koMC/ZHPEWQRmVfbGLoARWrVDhJ63eU3KTn0sfbBj7bK1wh/yLVb88eXjzIkedF8B9Q0eqF/A+EoWUeevzIe4AKI6CLVgrqxI29ogfLceHCrP0YSANsKhDga0+4pkzWCYicTPJhzzGXiYsXrR6BMLKd4BZ/4WfbsNF/R8bWpk/REJKZ0Lt12f4CmQGPVQklNdDAJXBv51L3Rs1OrQangOAL8Ju7AtcsTUkY6ogxP05HvMX39KRnBmjSCaMttACuiSTELP6V3ItF0FZUMqOWv9aejk0K6CseXkWyN/MigB6jLR0+E8guzbRkJ7naIpaB0FAFfIAxXS1lLroZPenA4VQXV5VXRw2O6uk7SUYRxU5ElNIEpn/hK+FfNKXa43T3YNZiMNrf0k59NCxcc3LcBhxIHryjoabCe7jiCBi6TjLH7+RzFoZOPwGV0o4/d0YFiO+TGNw9xluglfVIMVca6O3cy12v/TqSHWljAJrJr7bJrusnCbBZJB84vxrrbexRSneO2fc2qUzVIbu84wQs0toKgKqeZ6l2H+q0P/Z6Of4lsnEGuDxMphH6peJajUtZDxpFfJGety4axRU+4dwfwqPUcLY64PTII3WOR/tazMsGDulotg== 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)(82310400026)(36860700016)(22082099003)(18002099003)(56012099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ksr+QxfQIBfWZHqWmNkBOIC9STLfaYltk55GJlR99eu/xXU83j2oJGD1pg0QVOFdXS0TgD6x3Ku0ch5apIPSErenjhfLhxShoczzuHqqFy4RC+YgKI0xAJSZBNZrEArdos2XTMtZCFcK2XRT7G7OjwCWrsDlGe+0/gI0Lw5guqq3AXhlFRoNO40dJMTDD+Hf358NnOM0+faGEyaA33bKhGVNJkAQGyrWxFlqY5XKiU6U9XIN7DtT7htOx9gYZ0PdEh0DZ/akDaIqYSZqXa9NaCziKufmXQTvJ7+7SCMJ7mjq31okd0+msAP/FNo4hsyYjo+tn23HU3SERp/4efELKmNDcH+BBOWitrmLXPadOWUiNfblpqKIviBZ2pOku20UFH+eAksCA4516gSeF3iWfrX4B6Az8+Q3Tk9Jvogpv0mBbPJN3gkGjnC52b2b1bvB X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2026 14:02:01.8547 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 63853274-a090-40a4-c2c0-08de7f76c4e8 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: SJ1PEPF000023CB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7247 Content-Type: text/plain; charset="utf-8" Add the missing amd_pstate_hw_prefcore and amd_pstate_prefcore_ranking filenames in the sysfs listing example leading to the descriptions of these parameters. Signed-off-by: Gautham R. Shenoy Reviewed-by: Mario Limonciello (AMD) --- Documentation/admin-guide/pm/amd-pstate.rst | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/ad= min-guide/pm/amd-pstate.rst index e1771f2225d5f..f566fea6613e6 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -239,8 +239,10 @@ control its functionality at the system level. They ar= e located in the =20 root@hr-test1:/home/ray# ls /sys/devices/system/cpu/cpufreq/policy0/*amd* /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_highest_perf + /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_hw_prefcore /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_lowest_nonlinear_freq /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_max_freq + /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_prefcore_ranking =20 =20 ``amd_pstate_highest_perf / amd_pstate_max_freq`` @@ -264,14 +266,17 @@ This attribute is read-only. =20 ``amd_pstate_hw_prefcore`` =20 -Whether the platform supports the preferred core feature and it has been -enabled. This attribute is read-only. +Whether the platform supports the preferred core feature and it has +been enabled. This attribute is read-only. This file is only visible +on platforms which support the preferred core feature. =20 ``amd_pstate_prefcore_ranking`` =20 -The performance ranking of the core. This number doesn't have any unit, but -larger numbers are preferred at the time of reading. This can change at -runtime based on platform conditions. This attribute is read-only. +The performance ranking of the core. This number doesn't have any +unit, but larger numbers are preferred at the time of reading. This +can change at runtime based on platform conditions. This attribute is +read-only. This file is only visible on platforms which support the +preferred core feature. =20 ``energy_performance_available_preferences`` =20 --=20 2.34.1 From nobody Tue Apr 7 22:02:26 2026 Received: from SJ2PR03CU001.outbound.protection.outlook.com (mail-westusazon11012061.outbound.protection.outlook.com [52.101.43.61]) (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 759743C0607; Wed, 11 Mar 2026 14:02:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.43.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237731; cv=fail; b=Xkl8QI1J2HMCK52wpjTUNe6cvIE7L2j8euABJCjBPBe3VNqsfaSTGejwyWG85xEJs671974rj3l5YNRxQGc+3S6xv5ZJb+5neL0hXDSJZhq8bOKapc1V9/RpZBTodAnMyjXLfFej/eVy/mvuaFKtV5R/ZyjTsTBtQ3I9uKEDbJY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773237731; c=relaxed/simple; bh=eXJTKR8Nb9eX4QEH9d0mCZ0lAH2TIwNGOJ/dtCvfWM0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mxN7tFI5kh1NwCjMNwuNT5uzCLbJQGnTOhTcF/H9LGqGLySUPFr45Lh6QMqLj/rt5F5evfvvTYj20lRegHywIR74OJGwEMDJhWre709a4VFv5ns3xlND0ZZuweJq5s+oMLrE5pwKMrKjWbMyYvTzKFNXfIH0qYJdDK/kTpA01Qw= 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=g2d9sNdk; arc=fail smtp.client-ip=52.101.43.61 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="g2d9sNdk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JgHivEA2+QVTqgCxFlIulxKPoeD0eytLCcfXlMHWg7Yxtx9gu9H7NDhOmPnKCkgPBy0FIxkoVV9CgWTxksJa+XOP1HtH/oR5ig+4z/1IBLTOsmeQ/RxSEIG+jmVBFz6ID9kH6CgShcUOQDYkNxXm8g5iibfCkP9LzIse8MKyJiJLtwKw5yOeOn6uC4mv/l2xWC9xv4EdVplPOxiWmB/jWDLrLOPRhsf+y/W7/qTzQkO3HC2CaBdvGbN7NImEDyQz6OhAJ4NTmSAdhGaF5VHG64Sz13rHGi3x3nhksflN2dL3yEqAkXZusyyH2vz5jKopwl2edup+u5llt/B63QzoTQ== 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=+HJ1P1oBWTPl19WwPkFDpeACpQAoxlqO8fpx6Awg3vg=; b=OEwS47dymeYzvDtziAi3sWLRTPDQXUXsrPMBYTTX92I8r5fsug1W39yphk+wIt/r4uemvh5B1utWQDLBiphsbLk1EXzLfH7HUSrU0D1CzWvK71mr01IhKYBlITqshCxdsRZRDaweQOmkTsCA6xWsVcfu+DTP4xNRqDDf/w7MQh1pAqlQhp1YL/HvZ2H7BRETXDDD+DQyMwgrhOtY+sDi31F6R1Mx/RvuOOl+5KK08F5cdJHHY77JRHSHatEamgAy9HlhKYPP8qqV9Q+nwkAV6+klgXBKi8npv3LTmj22Vq6C+o/XuQXIIOX4A6keS3wpqyoazevr9CGIC6MkjO+YMQ== 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=+HJ1P1oBWTPl19WwPkFDpeACpQAoxlqO8fpx6Awg3vg=; b=g2d9sNdkUwlmppCHG4LGSk5/APZGFhHPaOgKNAgNkkjkYf8cAHCfDQ5R3KGKwXZG9oWwzQ+tJogKeLGdcjvSykomMrP/b57Pv1ZW10NIBgxx4qv+pL/LC6FeO/EblUjG9NI60s0JrJKxe0VlYjxliuRR30fqYkS9/UYA1njxMHM= Received: from SJ0PR13CA0038.namprd13.prod.outlook.com (2603:10b6:a03:2c2::13) by DS7PR12MB5982.namprd12.prod.outlook.com (2603:10b6:8:7d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9700.13; Wed, 11 Mar 2026 14:02:04 +0000 Received: from SJ1PEPF000023CE.namprd02.prod.outlook.com (2603:10b6:a03:2c2:cafe::dc) by SJ0PR13CA0038.outlook.office365.com (2603:10b6:a03:2c2::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9678.22 via Frontend Transport; Wed, 11 Mar 2026 14:02:04 +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 SJ1PEPF000023CE.mail.protection.outlook.com (10.167.244.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.18 via Frontend Transport; Wed, 11 Mar 2026 14:02:04 +0000 Received: from BLRRASHENOY1.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.17; Wed, 11 Mar 2026 09:02:01 -0500 From: "Gautham R. Shenoy" To: Mario Limonciello , "Rafael J . Wysocki" , Viresh Kumar , K Prateek Nayak CC: , , "Gautham R. Shenoy" , Jonathan Corbet , "Shuah Khan" Subject: [PATCH v2 9/9] Documentation/amd-pstate: Add documentation for amd_pstate_floor_{freq,count} Date: Wed, 11 Mar 2026 19:31:16 +0530 Message-ID: <20260311140116.19604-10-gautham.shenoy@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260311140116.19604-1-gautham.shenoy@amd.com> References: <20260311140116.19604-1-gautham.shenoy@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: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023CE:EE_|DS7PR12MB5982:EE_ X-MS-Office365-Filtering-Correlation-Id: 89696c91-96c9-4dcc-4852-08de7f76c6a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|376014|82310400026|1800799024|56012099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: OLFccsU2MjYjhSfyN2ADgN7HqLzia76FqCI4/23PxDURHWwYu+rqgxoDbTg5qmFeOyhPA8OO2/aZxYRwdYyC/vlsgy8jsCSc1kXkgrhONnjPJNTNj6Qf5aWCYuN/3G4EtQcfsEk0KVpNh3gUf90MfBKWOz4DpD0LN5TCaaLv/xuuKPw4Dev4bUPvi+9rOnTJ3gyic5ri8+zwijvHYyKpBYex3UIZ2ejRHAldoXqkfxyksNfoSrqr6LKLB/u3qLKdyRtaSmqg9//Uk4+7EyX1A4zW5SjcgAZVcy3ji9j1TgrUV0BjVMlcq4y5wgu0UyKvrrWGa9qsR9zn6WsM0ie/6eA+OuxZB3dJJWOa0Sj9iUsl2K08aNRJo4qLE/TaGSgzMrppXK/dcl9RwXV/9HovxHrYo/ss2vxi8H7er3T+YZxegM5aIlOE9MlSZ5PHno8x4nK0+nEKWXc+sw8za6s7UhqTrdReRhlkrv9iVnDSmTlCPD7+rCCb4my0NvBb/qY+YmVl81xN0pzV8VfGRtTbtzyJEA62hqHOQ/1PDmwh+2CXmHcV7mkUZJy0pK50vR4MNkCh2EjZ0rBhlJQycMz/vecE+jRqRIRxDWzclYOKkVQCv5BzMA0ln0XMJQFCJGJBgQ6U3sEVDIKg9z72UEC/tVPHuyNaJCZ+cZpsHZjXcmW7Z/K78Nf/GHBRqKfSwVfob/hBGdmmP0LJYrGHRZU8q07mY0CA7Y3TWpWnvyJWEvcLQkNjGJzYfVyMxO1bVFOYqqwarEETso8fH+IcQG/bXg== 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)(376014)(82310400026)(1800799024)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Sw6MpI+7GQ8Vp5k1harhSY3vBlMNrw37ONynNn7015VXlduKWLD9NDxxhrdWtnWdPUpt66gUxsW18aocanjXgcX+4/RGUmaVLmGlnIqwD78NZa2QLWfp8l1jOXZ+J1fxHR8iC1OjWYsBTbm/nPQFqLwYNw2VqR0RL3y6Dbnd0h9vC04YKfYgqewWM0vvPDATle58fg9tJ44rkJFDbl81WoZA0vZYGTmFnO+YT6jieT/GFaP6wuTSay8a4crLz5id8m9I7cirjMqjdMlORrMmdpUyEQXux9OFud1WCBCG73mnnEVSY51Jq/pyVa92dwhm5pjlGExHl8T9Vr9oLYNc0ybVyEtWN4RSTVsn9S76Qe+HhLKqhGE2ruzoJnKD0h6ZB4kUt5Ri531h/3vclVXrTZXundVQvz+qpo3QoHgMg0efurUZyGbUSsnlqhwgHtJr X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2026 14:02:04.7175 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 89696c91-96c9-4dcc-4852-08de7f76c6a1 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: SJ1PEPF000023CE.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5982 Content-Type: text/plain; charset="utf-8" Add documentation for the sysfs files /sys/devices/system/cpu/cpufreq/policy*/amd_pstate_floor_freq and /sys/devices/system/cpu/cpufreq/policy*/amd_pstate_floor_count. Signed-off-by: Gautham R. Shenoy Reviewed-by: Mario Limonciello (AMD) --- Documentation/admin-guide/pm/amd-pstate.rst | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/ad= min-guide/pm/amd-pstate.rst index f566fea6613e6..5fd2a36f8a4b8 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -242,6 +242,8 @@ control its functionality at the system level. They are= located in the /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_hw_prefcore /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_lowest_nonlinear_freq /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_max_freq + /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_floor_freq + /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_floor_count /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_prefcore_ranking =20 =20 @@ -278,6 +280,36 @@ can change at runtime based on platform conditions. Th= is attribute is read-only. This file is only visible on platforms which support the preferred core feature. =20 +``amd_pstate_floor_freq`` + +The floor frequency associated with each CPU. Userspace can write any +value between ``cpuinfo_min_freq`` and ``scaling_max_freq`` into this +file. When the system is under power or thermal constraints, the +platform firmware will attempt to throttle the CPU frequency to the +value specified in ``amd_pstate_floor_freq`` before throttling it +further. This allows userspace to specify different floor frequencies +to different CPUs. For optimal results, threads of the same core +should have the same floor frequency value. This file is only visible +on platforms that support the CPPC Performance Priority feature. + + +``amd_pstate_floor_count`` + +The number of distinct Floor Performance levels supported by the +platform. For example, if this value is 2, then the number of unique +values obtained from the command ``cat +/sys/devices/system/cpu/cpufreq/policy*/amd_pstate_floor_freq | +sort -n | uniq`` should be at most this number for the behavior +described in ``amd_pstate_floor_freq`` to take effect. A zero value +implies that the platform supports unlimited floor performance levels. +This file is only visible on platforms that support the CPPC +Performance Priority feature. + +**Note**: When ``amd_pstate_floor_count`` is non-zero, the frequency to +which the CPU is throttled under power or thermal constraints is +undefined when the number of unique values of ``amd_pstate_floor_freq`` +across all CPUs in the system exceeds ``amd_pstate_floor_count``. + ``energy_performance_available_preferences`` =20 A list of all the supported EPP preferences that could be used for --=20 2.34.1