From nobody Sun Dec 14 19:20:23 2025 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2071.outbound.protection.outlook.com [40.107.93.71]) (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 6B27F12B63; Mon, 21 Apr 2025 08:05:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745222734; cv=fail; b=EeB6VRjscArhr/QbIoifn7QSpU6jekYXAm103n+0cK92UU5r1PifYF/Vk7v4qgSEYGdzOfWJVYn4cSOCPqrbZ5RK5fx0czhM/duM8RiuHiJEsdOmKdXHlTnTHd2qOAPKv3/ImWxjL3K91813XoDui5BXS6jsNRf8qq1pW8cRX1E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745222734; c=relaxed/simple; bh=bqUtwFEN9ryEUuCMTCnBTcuKPgU+xEqdnus+dqPLoZQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Lb7t0qo7aHtzTImN67M5dSrWEnj7x3LYCI54oJh8RjySEW7st+nNo/26CMrNzfNg80wkwpW/c6zOBoD5p6iXxmXmzyYpOx5cE5eVEe7cmIgY55iayINv80ptErHmcZG9fuNd9GTT0+/7ppXuG4W6DJHrbtFeiWorAsU409PcGCs= 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=SgkvW/bo; arc=fail smtp.client-ip=40.107.93.71 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="SgkvW/bo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NMvxj0rQD1NtE6F3WIp94F5irp4F2m5zQHsImaWrDcz39VqiOcauJSflnPWFbq6wb1iaSc1/20pjnl7NupuhKXmumQ14CKOvfEZgl6qYOQQzFxwTccSWNwLVUGQGYUYR0Zq7UHI8pdeAUEK2F6UH1urC24cbe7Yd36OT2TRmVDyEccUrBlcSjsWLL6lKGgtxigqYKIudryxo+uHNZANDywf9G2wun4GKiYtBpt4KJ0dYdpDD5GjvDAPeKLxZdbztF6PN4GoY5UoMJnhAAVrikKfF8p0Ab13+oirigYZyIYbAO0vyfhumzmGl+xfXU5xH6u70D5WGsKgGmClSJjIN+g== 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=W64t4/OV+vWYwIaE4De2LX71D0qZW74dJFBFY6JHdBE=; b=yFYdlDrk1u64Jll1ew3WwFkv5lo9yzOW+GaW8eBo3IvKuxbUeDJrjetJfLm4h1bhObXReBnNdlk8nlapi6zAhJOPIk1TlzhSl799XLsa04njyY8Mx5MEcY8deYfEXg5jSSZR8VD56+sECWK1rFPZyUgzGeT+vAun1jeeeILaRQ23sGycUr9qu574hDoVHvKG20o8EBLOwLI3L5R/oKDrE0A0fkMVMBs8rEQqqQlxqMMZyTvRkz81k3H9Yg5ZPM9W25VAybYqjcElZWcQ25lywhSALX34jOLGzA9Ugh8dcnI4NTXsw8kHPMaHvKzJkhVSN1hLdCMHCekMvX62DEd3mg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.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=W64t4/OV+vWYwIaE4De2LX71D0qZW74dJFBFY6JHdBE=; b=SgkvW/bogQj1xW0TK3Q6qxVls9ZYTgvSLg0NhXUm9fh++ULystWhtkFQ1XkcRHSFDBFDlb3FKSJuYlF2TWnfNdSUIWDUO9mllWzCaLLqhBLXDq6erWPIRJIy3t/5DQuqNiAD5lcoJmqE1f0l/ArB1E50MWSL0iAYuGl2ahUoc2g= Received: from BN9PR03CA0962.namprd03.prod.outlook.com (2603:10b6:408:109::7) by SJ1PR12MB6337.namprd12.prod.outlook.com (2603:10b6:a03:456::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.30; Mon, 21 Apr 2025 08:05:29 +0000 Received: from BL02EPF0001A0FC.namprd03.prod.outlook.com (2603:10b6:408:109:cafe::6) by BN9PR03CA0962.outlook.office365.com (2603:10b6:408:109::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.35 via Frontend Transport; Mon, 21 Apr 2025 08:05:28 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF0001A0FC.mail.protection.outlook.com (10.167.242.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8655.12 via Frontend Transport; Mon, 21 Apr 2025 08:05:28 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 21 Apr 2025 03:05:25 -0500 From: Dhananjay Ugwekar To: , CC: , , "Dhananjay Ugwekar" Subject: [PATCH v2 1/2] cpufreq/amd-pstate: Add offline, online and suspend callbacks for amd_pstate_driver Date: Mon, 21 Apr 2025 08:04:45 +0000 Message-ID: <20250421080444.707538-2-dhananjay.ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250421080444.707538-1-dhananjay.ugwekar@amd.com> References: <20250421080444.707538-1-dhananjay.ugwekar@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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A0FC:EE_|SJ1PR12MB6337:EE_ X-MS-Office365-Filtering-Correlation-Id: d832818d-dba1-44b5-908b-08dd80ab4769 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lVCmLkLEIWybtV8Eome4gsyVB4VbqjZNY8HerFyv5ERJ+EU14w4I+RHJ2ys3?= =?us-ascii?Q?HI4VqzNkwVV7eNidvgDKNkDSpFQd0PvsfOY2eHP0nJSKpV34GoHb3J5TA6VA?= =?us-ascii?Q?GJw4cFzBNxKRoUMEkvpdeyitZk86RIu4EfVrGOV3k0L8fdSidN50NcGvHRYL?= =?us-ascii?Q?ToxPy06Cv5NZdYcAGyIgsamx+D6cX069c3XPmaY2aKJfR+HgdSyk9LPUI8GR?= =?us-ascii?Q?46wT0j/f+JnKoP/D6/khz/OvUEGvEHpGTqGdiAIPjubQrho6x7tNi0BF8BcK?= =?us-ascii?Q?hvsdCWJsUaGRF++LVtG07lNT5cEt7pgmJPy8AAtbO3c108IbbqhdV+XSq3te?= =?us-ascii?Q?JwN414VzMAP8gZOAbi345ym/ma5JVP0NX8JQLc6Si1ohlJqCSliLmbIudRyQ?= =?us-ascii?Q?91P2X0DftpV55Q+4yvc4ACxejxJql2RU2D+I4PWamCWQCd/3FB8ze8uvyM7L?= =?us-ascii?Q?lhfK0babNzImXGC1ITbMa8uIGesqUuGRQ1ELlTiO8AkI665DnnVTU3cHbtw7?= =?us-ascii?Q?dc58r12jb1rxLvfMFbqi6QjejUuNDz7u3UYYRXlzxSU5wk5C8SeOj36T4wTs?= =?us-ascii?Q?C2B1UVJed3JhwznmWbIW1lmdgZUs61815lgE7CA8gVtUP5oIgVlTUIqG1HMb?= =?us-ascii?Q?xIDjd6N2HIqFW4di6NTdIYmUTcDz2Y+GLi/y5avd0+jmZx99MLPBdurKKYIi?= =?us-ascii?Q?+pRc+2cZEvox/UEvTslEx/RWaRoxGmhAR04IllrTrJcoyVRtSXGK6Gc4tcYz?= =?us-ascii?Q?xZVTes8wBKKDFt7fMu6h9uOS3ft7D94Pb8mkXiClMsTawqK9oHjDjn1DtAgG?= =?us-ascii?Q?Vr+lKIrvF3OO96LXSGac+NORGQSkAr4Z1y1zRePVdEzCvvVryHIjK2rjJktL?= =?us-ascii?Q?yRvxHdmD4L2W6E4KifcchDhUQt9bBq5IecT47qsRA3WXZqkjgam17cA39YBl?= =?us-ascii?Q?Gz4lYofWxAWfmI2m5WnMIAvsai2sIymA+n5UitMk5oLX1Q3gDYcAEPXP5QhY?= =?us-ascii?Q?vxA+c9z18THjGl5gAQHAvy9FcP/PFoVHK+3NqbGmetVSrYKvfNHH0UJHxr6/?= =?us-ascii?Q?XqCF1NIQvIEL/szVzh1dSMbRVGv01A1KaFnq0xyUT23EYNlB8yHPJ/jhGR/J?= =?us-ascii?Q?N87FZ2pwdQU+RaJbp9ehxlDz0ydt/BZaPdRcznTSryCaedtKvsKnf0xDqT6g?= =?us-ascii?Q?79DzcjD9FVubeT4cM9VftaKLljAo3f4NjG2MtE5DEpRkGBZ6Hr0Qt8618gi4?= =?us-ascii?Q?iTsQulMqP+FdB9U0VIL+WiJD7kRbgGC6pMVj8Y73g/Pcn0tnlVtxKJVCfBz7?= =?us-ascii?Q?oTBqTm48KAavCwqTJhU76EGEMfl7TtWoNN80meTJcRZBRAqYjF5uWb14Zcgk?= =?us-ascii?Q?cvBdx4ab0cWWLHuwWnDOoiyw0e5D476J1NMdDZTVWrw2uwZm+M4vu6yqMdLA?= =?us-ascii?Q?dt2zuMBF6QZjtQyRJvDwcN6c8V/1bNFxaTHOBlGxy02dvSiUpQKnXIWxgrnk?= =?us-ascii?Q?JtuTX/UpCQzk7LnKfqkY40YQraynDMjzYIHo?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2025 08:05:28.1873 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d832818d-dba1-44b5-908b-08dd80ab4769 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A0FC.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6337 Content-Type: text/plain; charset="utf-8" Rename and use the existing amd_pstate_epp callbacks for amd_pstate driver as well. Remove the debug print in online callback while at it. These callbacks will be needed to support the "Requested CPU Min Frequency" BIOS option. Reviewed-by: Mario Limonciello Signed-off-by: Dhananjay Ugwekar --- drivers/cpufreq/amd-pstate.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index c29840ba3b30..02de51001eba 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -1568,19 +1568,17 @@ static int amd_pstate_epp_set_policy(struct cpufreq= _policy *policy) return 0; } =20 -static int amd_pstate_epp_cpu_online(struct cpufreq_policy *policy) +static int amd_pstate_cpu_online(struct cpufreq_policy *policy) { - pr_debug("AMD CPU Core %d going online\n", policy->cpu); - return amd_pstate_cppc_enable(policy); } =20 -static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy) +static int amd_pstate_cpu_offline(struct cpufreq_policy *policy) { return 0; } =20 -static int amd_pstate_epp_suspend(struct cpufreq_policy *policy) +static int amd_pstate_suspend(struct cpufreq_policy *policy) { struct amd_cpudata *cpudata =3D policy->driver_data; =20 @@ -1618,6 +1616,9 @@ static struct cpufreq_driver amd_pstate_driver =3D { .fast_switch =3D amd_pstate_fast_switch, .init =3D amd_pstate_cpu_init, .exit =3D amd_pstate_cpu_exit, + .online =3D amd_pstate_cpu_online, + .offline =3D amd_pstate_cpu_offline, + .suspend =3D amd_pstate_suspend, .set_boost =3D amd_pstate_set_boost, .update_limits =3D amd_pstate_update_limits, .name =3D "amd-pstate", @@ -1630,9 +1631,9 @@ static struct cpufreq_driver amd_pstate_epp_driver = =3D { .setpolicy =3D amd_pstate_epp_set_policy, .init =3D amd_pstate_epp_cpu_init, .exit =3D amd_pstate_epp_cpu_exit, - .offline =3D amd_pstate_epp_cpu_offline, - .online =3D amd_pstate_epp_cpu_online, - .suspend =3D amd_pstate_epp_suspend, + .offline =3D amd_pstate_cpu_offline, + .online =3D amd_pstate_cpu_online, + .suspend =3D amd_pstate_suspend, .resume =3D amd_pstate_epp_resume, .update_limits =3D amd_pstate_update_limits, .set_boost =3D amd_pstate_set_boost, --=20 2.34.1 From nobody Sun Dec 14 19:20:23 2025 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2045.outbound.protection.outlook.com [40.107.92.45]) (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 CA5241C8603; Mon, 21 Apr 2025 08:06:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745222798; cv=fail; b=IUlobuJmgc9u7uOapu2KD/Q+K84KWVc7wijdb9ONlY6WkIEzZarns0aABFW0kWf9xYD9XNMteetivxIffzstdJgPrROxZqoWx9Cv4vJagGzOgHCrIYpV5XNURPQQdoNZyvNA6WanP8wFOX1QCKKPMdGnS3FAwrs/rerMM6n+z7s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745222798; c=relaxed/simple; bh=oXRqXzli1e3zqQQsN8LGLSYH5zC02RbNgNZV0GtBidY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J+ETVk7tt38jvWFj+a/98h0E6iBYk2q8eWxYVOI6NrcpVyUfvB8bVcLTQ+RuND9RqfZA+SVzRvtoL5oTQj2Keg3Sa10lbdpeAB1Gr4//kSMedyhfycLX11NP1+hqT4AmSUg8OpcCeXsg3BhD4TITyr2Z48wY3qMBgEh8a2a/UkM= 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=EDhJZxaJ; arc=fail smtp.client-ip=40.107.92.45 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="EDhJZxaJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ClimDFXZKAZ88JsLCmFoDocErtPifHsdR6IuUV/+F3/1OqR3ZqBSUprQJD6o1c1yevuzjH9XKjZouscunT8INKwypugldUBWFUJzwR7GvnOhfaqXBDzy670WpXuRV9KPrMQGW+G3/BNmnqtmgBnDhsyKnv7KZHXXAajdhzRlLtcrlTFKfZAC5n+WTsXj2vdUYUm/xyxL9+3o/yEi//rdgwjZN1E8hsLBazROHEortt0tjE8awMhjIxZnpNAkOamPnSD7gtGZMt3F2F9OxYRZijW8gM8q9iqzE0jujNXSDiRETYK7jg5VfYyQ0wKvC4eZKh0/yMSia/od430+EwEOvg== 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=r1ohd/StRaShZ+XJESL5bdL9YkShURIQ6t6CbejeHhg=; b=tciTjoWXybSeDKhSecQlcmKL6j1Vxo0yJ3CXNaR6knFOGYaWoeQvxIDFbfNuIhLBxf+bJ+3z+uyoZNJAPf6E/F8ErdI906Tv3X5QigxvLNxHwqFKB1SVv2kK9zUU+wau7yuVEwKyDFPnXpgss5w6FUUuC3tRsMVLpx+T4n8PFEnKOCPlIkmPlOw7Lf1CKx/mpZOdtaJm5Fzml8Xa6AZmhvoEmQtSW2uKeL7Q72pYr/+YboqvXskBWaVWGPmzAY8FbcRNfC/Bpwkb9jRSjfYYlyUXQDcl1HF/9DDlNILNLZ9IMiCYUln6djhP1be0oXyXscse7SxBsU4xmdWNb8WmgQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.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=r1ohd/StRaShZ+XJESL5bdL9YkShURIQ6t6CbejeHhg=; b=EDhJZxaJ+8OfsOtkVTOl9W3kTCz9GzQCJjkgtxjmTedcVn9HfqaITh3xn9Ij6u5lFhi1fCXjVNJp6MStwGPdttXcEpe+e//nL9w1jG7379NmSzY/el2Xz40C8DS1J7mlGD7vTxls2l1T/WuVkdwFTizYA2y0jFvY/x3xSTHvDL8= Received: from BLAPR03CA0009.namprd03.prod.outlook.com (2603:10b6:208:32b::14) by DS0PR12MB8528.namprd12.prod.outlook.com (2603:10b6:8:160::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.35; Mon, 21 Apr 2025 08:06:32 +0000 Received: from BL02EPF0001A0FA.namprd03.prod.outlook.com (2603:10b6:208:32b:cafe::9e) by BLAPR03CA0009.outlook.office365.com (2603:10b6:208:32b::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.35 via Frontend Transport; Mon, 21 Apr 2025 08:06:32 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF0001A0FA.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8655.12 via Frontend Transport; Mon, 21 Apr 2025 08:06:31 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 21 Apr 2025 03:06:27 -0500 From: Dhananjay Ugwekar To: , CC: , , "Dhananjay Ugwekar" Subject: [PATCH v2 2/2] cpufreq/amd-pstate: Add support for the "Requested CPU Min frequency" BIOS option Date: Mon, 21 Apr 2025 08:04:47 +0000 Message-ID: <20250421080444.707538-3-dhananjay.ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250421080444.707538-1-dhananjay.ugwekar@amd.com> References: <20250421080444.707538-1-dhananjay.ugwekar@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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A0FA:EE_|DS0PR12MB8528:EE_ X-MS-Office365-Filtering-Correlation-Id: ea07f414-2711-427f-f97c-08dd80ab6d68 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?7qfQh9x8RSPUwItNDrDQM1x4KFpRJT68YF6ON4twJ6gwoOY2/zSTdv16hVAJ?= =?us-ascii?Q?FhvqKN2mSS+3G8bI7HgDeK8hgNoEUKmKp5trY4p+nfW5rn7EsQUvKnEYGcHn?= =?us-ascii?Q?jcpBNU5lbJ/ZkV901PAWyM9sB0LiJnXXb2AosaomZVbPRbs2A9wA5mSBTWSd?= =?us-ascii?Q?8MjcEevNF+UOjyFMKK3SG77Wly0jSTmVwZWU/UJEt4lH55YBgSJbZidJtNgW?= =?us-ascii?Q?a9fchh2sjSgT7WH9fCbb7BeQl+S9W2lhcs8tAFxv97DFKH8frPso4aprvyjF?= =?us-ascii?Q?8rYh0L8793ToJo+2LxADjUswC9czaddQjVxIApksRzj0dL3Xj4srZzKUVjbF?= =?us-ascii?Q?WxhUOgfYwdnrWnwM2SrSvaVNeOxLH/6Niafz9Xp0HwWZ1lA2LBX5bxaO2qhS?= =?us-ascii?Q?/sPcFD2vi0k0e0QOQQaWRNQETjTH+e+f/zDMtbem9pn6TWg1+gxvYO5/ec+Q?= =?us-ascii?Q?p5Oj9N7d4uztBYU1KOhVkHE71khP+4dfyqyBXALDwqkA4oNpkOCjf3j4dzD5?= =?us-ascii?Q?wj8Gh9g48pQbAw1+dENHrw/P6OJ6jyFuBYtgjcoDunNwFJNNiPzTHFWvR+Mq?= =?us-ascii?Q?M/oAfNjSa2dtrxXQ49zcs0XmK30nY2Jnr1xoICn+HSiSG5BRmoQsOkEbyx+b?= =?us-ascii?Q?FATLt3p/f/MStigp61VbrQRUF2b11VIhNWZDKyLoMYeac2qtBVTiWOwI3I2N?= =?us-ascii?Q?Ivb/Tkc/S4VkOFS8fm+iacYIObOoh6kHhz7QzSEm9rCF5ZGxtqY6AijyyHqL?= =?us-ascii?Q?cQnQbS9xUmblnRIqW3h1wwIeJ3G1p95KP/xq/bgi09TlK2ixDK1B+qjmP7/u?= =?us-ascii?Q?0oSXx19Q/Z651KB/nsAg/xM09rv7ddT+jvv7Nm1PGXSxcOJQoTwg1a+NiZN6?= =?us-ascii?Q?xcq5uC0fcdAojdUKS/58/gwDvaockYLWss5qS+yiAdd6m/LEpCDB18pGezBb?= =?us-ascii?Q?ivih9sqjl3d7r33+zJpWuLGWnsEVrCdShIDK+SRv8j7Lr+wqxobJNH0mwk5e?= =?us-ascii?Q?AwRdB1wnhFZ0wU02kpvRULfm8rdM0c/WPEtsyJs/XteFnJUKTdOq56LlKUIS?= =?us-ascii?Q?f7+iI8vvXMzy0eBnaGy6UdhV5oluwjL6MxDy+RoAShDgCdch6w8lnR4US74w?= =?us-ascii?Q?VH088gS4QwNmt4J8mxgiJTEtccWDE5Irf+QhvekkbtEfYWqGn1syS5v43OkN?= =?us-ascii?Q?mTVoyVK3r6U1huiyuL0dyjcnPiSLFGhhnVXcfsmyl6WJGs3xJfQsy++oZ/X1?= =?us-ascii?Q?/DPOp65NzWAWIkwy4iDPJUMcTKIU7BDVTH2I6Nm/CyQSOucFoQ5Vpf+lifgj?= =?us-ascii?Q?N/0dQYRoCt73nlbKjA/HMpDhtsj63K7qedvVsvrkz9ajTUxtwTe3NddUfmT3?= =?us-ascii?Q?0XH/5Izjc7NL4ZxjZF4ExIQ0/KGMq/CnUW+D2pM0szfxdnpzEgZx0y0VKQkV?= =?us-ascii?Q?RSQynlYpkk7PWMFguZwCW0unkHLEBi1NX4QkW6MEaRDeoS3W1EMof+NJBG/q?= =?us-ascii?Q?jTwNcXSQT8YreCUaCXEl6bpzUHAND3x/VI05?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2025 08:06:31.9368 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ea07f414-2711-427f-f97c-08dd80ab6d68 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A0FA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8528 Content-Type: text/plain; charset="utf-8" Initialize lower frequency limit to the "Requested CPU Min frequency" BIOS option (if it is set) value as part of the driver->init() callback. The BIOS specified value is passed by the PMFW as min_perf in CPPC_REQ MSR.=20 To ensure that we don't mistake a stale min_perf value in CPPC_REQ=20 value as the "Requested CPU Min frequency" during a kexec wakeup, reset=20 the CPPC_REQ.min_perf value back to the BIOS specified one in the offline, exit and suspend callbacks. amd_pstate_target() and=20 amd_pstate_epp_update_limit() which are invoked as part of the resume()=20 and online() callbacks will take care of restoring the CPPC_REQ back to=20 the latest sane values. Signed-off-by: Dhananjay Ugwekar --- Changes in v2: * Modify the condition in msr_init_perf to initialize perf.bios_min_perf=20 to 0 by default * Use READ_ONCE to read cpudata->perf in exit, suspend and offline callbacks --- drivers/cpufreq/amd-pstate.c | 67 +++++++++++++++++++++++++++++------- drivers/cpufreq/amd-pstate.h | 2 ++ 2 files changed, 56 insertions(+), 13 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 02de51001eba..407fdd31fb0b 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -389,7 +389,8 @@ static inline int amd_pstate_cppc_enable(struct cpufreq= _policy *policy) static int msr_init_perf(struct amd_cpudata *cpudata) { union perf_cached perf =3D READ_ONCE(cpudata->perf); - u64 cap1, numerator; + u64 cap1, numerator, cppc_req; + u8 min_perf; =20 int ret =3D rdmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1, &cap1); @@ -400,6 +401,22 @@ static int msr_init_perf(struct amd_cpudata *cpudata) if (ret) return ret; =20 + ret =3D rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &cppc_req); + if (ret) + return ret; + + WRITE_ONCE(cpudata->cppc_req_cached, cppc_req); + min_perf =3D FIELD_GET(AMD_CPPC_MIN_PERF_MASK, cppc_req); + + /* + * Clear out the min_perf part to check if the rest of the MSR is 0, if y= es, this is an + * indication that the min_perf value is the one specified through the BI= OS option + */ + cppc_req &=3D ~(AMD_CPPC_MIN_PERF_MASK); + + if (!cppc_req) + perf.bios_min_perf =3D min_perf; + perf.highest_perf =3D numerator; perf.max_limit_perf =3D numerator; perf.min_limit_perf =3D FIELD_GET(AMD_CPPC_LOWEST_PERF_MASK, cap1); @@ -580,20 +597,26 @@ static int amd_pstate_verify(struct cpufreq_policy_da= ta *policy_data) { /* * Initialize lower frequency limit (i.e.policy->min) with - * lowest_nonlinear_frequency which is the most energy efficient - * frequency. Override the initial value set by cpufreq core and - * amd-pstate qos_requests. + * lowest_nonlinear_frequency or the min frequency (if) specified in BIOS, + * Override the initial value set by cpufreq core and amd-pstate qos_requ= ests. */ if (policy_data->min =3D=3D FREQ_QOS_MIN_DEFAULT_VALUE) { struct cpufreq_policy *policy __free(put_cpufreq_policy) =3D cpufreq_cpu_get(policy_data->cpu); struct amd_cpudata *cpudata; + union perf_cached perf; =20 if (!policy) return -EINVAL; =20 cpudata =3D policy->driver_data; - policy_data->min =3D cpudata->lowest_nonlinear_freq; + perf =3D READ_ONCE(cpudata->perf); + + if (perf.bios_min_perf) + policy_data->min =3D perf_to_freq(perf, cpudata->nominal_freq, + perf.bios_min_perf); + else + policy_data->min =3D cpudata->lowest_nonlinear_freq; } =20 cpufreq_verify_within_cpu_limits(policy_data); @@ -1040,6 +1063,10 @@ static int amd_pstate_cpu_init(struct cpufreq_policy= *policy) static void amd_pstate_cpu_exit(struct cpufreq_policy *policy) { struct amd_cpudata *cpudata =3D policy->driver_data; + union perf_cached perf =3D READ_ONCE(cpudata->perf); + + /* Reset CPPC_REQ MSR to the BIOS value */ + amd_pstate_update_perf(policy, perf.bios_min_perf, 0U, 0U, 0U, false); =20 freq_qos_remove_request(&cpudata->req[1]); freq_qos_remove_request(&cpudata->req[0]); @@ -1428,7 +1455,6 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_pol= icy *policy) struct amd_cpudata *cpudata; union perf_cached perf; struct device *dev; - u64 value; int ret; =20 /* @@ -1493,12 +1519,6 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_po= licy *policy) cpudata->epp_default =3D AMD_CPPC_EPP_BALANCE_PERFORMANCE; } =20 - if (cpu_feature_enabled(X86_FEATURE_CPPC)) { - ret =3D rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value); - if (ret) - return ret; - WRITE_ONCE(cpudata->cppc_req_cached, value); - } ret =3D amd_pstate_set_epp(policy, cpudata->epp_default); if (ret) return ret; @@ -1518,6 +1538,11 @@ static void amd_pstate_epp_cpu_exit(struct cpufreq_p= olicy *policy) struct amd_cpudata *cpudata =3D policy->driver_data; =20 if (cpudata) { + union perf_cached perf =3D READ_ONCE(cpudata->perf); + + /* Reset CPPC_REQ MSR to the BIOS value */ + amd_pstate_update_perf(policy, perf.bios_min_perf, 0U, 0U, 0U, false); + kfree(cpudata); policy->driver_data =3D NULL; } @@ -1575,12 +1600,28 @@ static int amd_pstate_cpu_online(struct cpufreq_pol= icy *policy) =20 static int amd_pstate_cpu_offline(struct cpufreq_policy *policy) { - return 0; + struct amd_cpudata *cpudata =3D policy->driver_data; + union perf_cached perf =3D READ_ONCE(cpudata->perf); + + /* + * Reset CPPC_REQ MSR to the BIOS value, this will allow us to retain the= BIOS specified + * min_perf value across kexec reboots. If this CPU is just onlined norma= lly after this, the + * limits, epp and desired perf will get reset to the cached values in cp= udata struct + */ + return amd_pstate_update_perf(policy, perf.bios_min_perf, 0U, 0U, 0U, fal= se); } =20 static int amd_pstate_suspend(struct cpufreq_policy *policy) { struct amd_cpudata *cpudata =3D policy->driver_data; + union perf_cached perf =3D READ_ONCE(cpudata->perf); + + /* + * Reset CPPC_REQ MSR to the BIOS value, this will allow us to retain the= BIOS specified + * min_perf value across kexec reboots. If this CPU is just resumed back = without kexec, + * the limits, epp and desired perf will get reset to the cached values i= n cpudata struct + */ + amd_pstate_update_perf(policy, perf.bios_min_perf, 0U, 0U, 0U, false); =20 /* invalidate to ensure it's rewritten during resume */ cpudata->cppc_req_cached =3D 0; diff --git a/drivers/cpufreq/amd-pstate.h b/drivers/cpufreq/amd-pstate.h index fbe1c08d3f06..2f7ae364d331 100644 --- a/drivers/cpufreq/amd-pstate.h +++ b/drivers/cpufreq/amd-pstate.h @@ -30,6 +30,7 @@ * @lowest_perf: the absolute lowest performance level of the processor * @min_limit_perf: Cached value of the performance corresponding to polic= y->min * @max_limit_perf: Cached value of the performance corresponding to polic= y->max + * @bios_min_perf: Cached perf value corresponding to the "Requested CPU M= in Frequency" BIOS option */ union perf_cached { struct { @@ -39,6 +40,7 @@ union perf_cached { u8 lowest_perf; u8 min_limit_perf; u8 max_limit_perf; + u8 bios_min_perf; }; u64 val; }; --=20 2.34.1