From patchwork Mon Mar 18 10:11:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 781014 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2089.outbound.protection.outlook.com [40.107.93.89]) (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 AB8E2381D2; Mon, 18 Mar 2024 10:11:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710756701; cv=fail; b=WZeM7QXNOSZM0tMRHYVSRjgscqF6I4G5zoWsQqpLRnr5d5RpumZh8Vh70wkGqZNZSObvV5xY115GNsr66byHIj3X8GIFP8/iIe9HBO2DlKLc45s8ms8EJ1KRz40hbb3QheWel3YZxCXeihA+nCOYK4lgGq0ARvhRVe4OUsC5HGw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710756701; c=relaxed/simple; bh=hIgkKPGWKmHXc+BKPCad2ibEcDx3MTToS1XTi/GgqfU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=T7f60wXxK++gjKt6hGflPZdtchdMER1LIfa2OIv5/OZPtV932x6BR8orLnYmUeUpJTKt/wotJ7FJYGgWlqrBmTjQ2TpLwZdbB6xlZMD1FkKkQTAoXUs2edHp8nN/EcIpzVdGaZ7jpZ0u0nnGEBYRPC8RR1GUohMd0X2/lL4EvYY= 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=oSQNbFGn; arc=fail smtp.client-ip=40.107.93.89 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="oSQNbFGn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZkQ7PMeAny9sxmrvK0E6Xa3Pg/tGMinpU1/OOFFw8p17OpGuBL6iK4FPvyh2U4OKfCIo8D+2G+fnCR5DAMGnUQfDWcHk2hGXVjIL5Xq8N51Hv8OQu2Itb293urUDIPa+6F6zvXi3laxW07yC1ZBHe++G6mU8I4jESV3kxD0YL2daqVt/0ha38mTCb+dBaABfjp06qV2oqXyeTm0+w/bn2Lu0gsfzfhv4xhRo/JoJ9v5BxkjsTsCce4vMGySFMDlx8M1U4hY27PIcFX22HxXyXpvzosBu6W0Wcv6XiNcEiKy4ZmSfx/hDyDwVpxtIMxIAWLWfncrFazH2hYHab52Mlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=EMs0KvCpm4U0E+rO8pCfFaT8EYmEqu7q3795v0kApnQ=; b=jEb/CjI20N2i0K6bZeT1+fpjWowML9h+rBE50+Dx0oI7K9vCRjV0EDk7XJL6etY7lhMzVB5eQdaRLyD6qxylpdNYmdqTaFZTmSCSBNmWlZrdW4Ql9UbwpTTSkdiKdIHu/BjmzXKPZuse9IGsWmuZzDnO+nR1hYgsIfYE1p/lNqoTsRQGjtKl3hg7DNvSeCTJ7bAit8p62ik3grv6vWNrB8A3EbIrW6Yn1Hofli5W2ii7WZsICNk3ubQY6p2NgveFvzphG86ObTQI04Ehip5TKdMJQqmC4HX7FIW2E2jt/F8mjoTo5nRNZnU4sOH+M16pJfv/OWp698zR+ewSFKhjuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=EMs0KvCpm4U0E+rO8pCfFaT8EYmEqu7q3795v0kApnQ=; b=oSQNbFGnPKSNaJ6+NYDJmYM+1wURCvKu+wF45eYqqGo07xV3MEtfBFFqYZGbrX+UcXZGjcdm6LGZFQPpiGRovRn7rA5OHyFOS+N0oaf1bKLPRGTTnxHjM9hN0Wa7gQfNBBRYgV1uQUxi6f+ItddLZbNG0hSDDdM2lO2BVD8SZ8g= Received: from CY5PR15CA0185.namprd15.prod.outlook.com (2603:10b6:930:81::24) by DM4PR12MB6424.namprd12.prod.outlook.com (2603:10b6:8:be::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 10:11:37 +0000 Received: from CY4PEPF0000E9D4.namprd03.prod.outlook.com (2603:10b6:930:81:cafe::99) by CY5PR15CA0185.outlook.office365.com (2603:10b6:930:81::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.27 via Frontend Transport; Mon, 18 Mar 2024 10:11: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9D4.mail.protection.outlook.com (10.167.241.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 18 Mar 2024 10:11:37 +0000 Received: from pyuan-Chachani-VN.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.35; Mon, 18 Mar 2024 05:11:33 -0500 From: Perry Yuan To: , , , , , CC: , , , , , , Subject: [PATCH v6 2/6] cpufreq: amd-pstate: initialize new core precision boost state Date: Mon, 18 Mar 2024 18:11:09 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: CY4PEPF0000E9D4:EE_|DM4PR12MB6424:EE_ X-MS-Office365-Filtering-Correlation-Id: c76b125a-38da-4c3e-4125-08dc4733cc11 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HRgioViBYGVnmG0VhC8K28h0JYfkCFabTc0iAy9jiDe4e8Onnw4QoO4pRylFSpwS3nfUjVLS2bYRceHZLE5COTg8qkhOyObYoPpijkkIkToAzno6hViwpS1thxSN17pNRdb0/DQO6B7H6+GwnrdawJtneIP1b8ivpQ1D5A5uJ47DSu9EcoFDL0Bgu6s2C6Wxz+Ohij6iJtTS+CfSjee/Z8WqajsUnbjRcnHSeMjZ8VUb0EW3zw9UfnPuZ076qgdtIXqwzA61mhNIiLRzInEUJWNnpG7zCDyJX2pXgK5g0Mb6HC/AGy1PjWSydvmNRSqP48KxIvOEnUvpvksgcGbBpGd+EIhsDndzRS9iq/3+HNAAaqNcbblmD4LznNmZHvJFQSTTYO+FG/Xbc3wVMdiDZiF/FGoHaOV+QhU2+Y0Mcng619msbBZKxKvUQiplYX3tOSOyOqUXPDVrx6+8VbCIQcVlrFNjz+Xkj7ab3g81H4No4ehqHnnvhkK85pYGxc0bnOK52isBpgxwjfToUW+G60orT3SXZQWs4DjKDk5kkTGoBE0Oyrl5iIg1Y85aktla/Szqe34PCK+yLje8Or8DLMVm87mXUgmoB8PUV0+h9TSqdxWB8KgWwLLt2AmIc6oh1OOwuq2rnoQUL809G7KLVGGipQmE8aR8VaHMawKCU9sAeKsCQdB94OE5bdrLA4zQ6G1lr4/fUedcRC/dIUv1JA== 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:(13230031)(36860700004)(82310400014)(376005)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2024 10:11:37.1261 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c76b125a-38da-4c3e-4125-08dc4733cc11 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: CY4PEPF0000E9D4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6424 From: Perry Yuan Add gloal global_params to represent current CPU Performance Boost(cpb) state for cpu frequency scaling, both active and passive modes all can support CPU cores frequency boosting control which is based on the BIOS setting, while BIOS turn on the "Core Performance Boost", it will allow OS control each core highest perf limitation from OS side. If core performance boost is disabled while a core is in a boosted P-state, the core transitions to the highest performance non-boosted P-state, that is the same as the nominal frequency limit. Reported-by: Artem S. Tashkinov" Cc: Oleksandr Natalenko Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217931 Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 39 +++++++++++++++++++++++++++--------- include/linux/amd-pstate.h | 13 ++++++++++++ 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 59a2db225d98..81787f83c906 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -68,6 +68,8 @@ static int cppc_state = AMD_PSTATE_UNDEFINED; static bool cppc_enabled; static bool amd_pstate_prefcore = true; static struct quirk_entry *quirks; +struct amd_pstate_global_params amd_pstate_global_params; +EXPORT_SYMBOL_GPL(amd_pstate_global_params); /* * AMD Energy Preference Performance (EPP) @@ -665,18 +667,27 @@ static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state) return 0; } -static void amd_pstate_boost_init(struct amd_cpudata *cpudata) +static int amd_pstate_boost_init(struct amd_cpudata *cpudata) { - u32 highest_perf, nominal_perf; + u64 boost_val; + int ret; - highest_perf = READ_ONCE(cpudata->highest_perf); - nominal_perf = READ_ONCE(cpudata->nominal_perf); + ret = rdmsrl_on_cpu(cpudata->cpu, MSR_K7_HWCR, &boost_val); + if (ret) { + pr_err_once("failed to read initial CPU boost state!\n"); + return ret; + } - if (highest_perf <= nominal_perf) - return; + amd_pstate_global_params.cpb_supported = !(boost_val & MSR_K7_HWCR_CPB_DIS); + + if (amd_pstate_global_params.cpb_supported) { + cpudata->boost_supported = true; + current_pstate_driver->boost_enabled = true; + } - cpudata->boost_supported = true; - current_pstate_driver->boost_enabled = true; + amd_pstate_global_params.cpb_boost = amd_pstate_global_params.cpb_supported; + + return ret; } static void amd_perf_ctl_reset(unsigned int cpu) @@ -900,6 +911,11 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) amd_pstate_init_prefcore(cpudata); + /* initialize cpu cores boot state */ + ret = amd_pstate_boost_init(cpudata); + if (ret) + goto free_cpudata1; + ret = amd_pstate_init_perf(cpudata); if (ret) goto free_cpudata1; @@ -956,7 +972,6 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) policy->driver_data = cpudata; - amd_pstate_boost_init(cpudata); if (!current_pstate_driver->adjust_perf) current_pstate_driver->adjust_perf = amd_pstate_adjust_perf; @@ -1363,6 +1378,11 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) amd_pstate_init_prefcore(cpudata); + /* initialize cpu cores boot state */ + ret = amd_pstate_boost_init(cpudata); + if (ret) + goto free_cpudata1; + ret = amd_pstate_init_perf(cpudata); if (ret) goto free_cpudata1; @@ -1417,7 +1437,6 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) return ret; WRITE_ONCE(cpudata->cppc_cap1_cached, value); } - amd_pstate_boost_init(cpudata); return 0; diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h index 6b832153a126..c5e41de65f70 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -134,4 +134,17 @@ struct quirk_entry { u32 lowest_freq; }; +/** + * struct amd_pstate_global_params - Global parameters, mostly tunable via sysfs. + * @cpb_boost: Whether or not to use boost CPU P-states. + * @cpb_supported: Whether or not CPU boost P-states are available + * based on the MSR_K7_HWCR bit[25] state + */ +struct amd_pstate_global_params { + bool cpb_boost; + bool cpb_supported; +}; + +extern struct amd_pstate_global_params amd_pstate_global_params; + #endif /* _LINUX_AMD_PSTATE_H */ From patchwork Mon Mar 18 10:11:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 781013 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2083.outbound.protection.outlook.com [40.107.96.83]) (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 7BA5F3A29A; Mon, 18 Mar 2024 10:11:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710756710; cv=fail; b=O620yhF61uaeOcIhN//9y8wO+o16xmEigu8KdD7B9uutwEk/avv/gn0N4ohuP5P0uzDs+ECUweEDkDy0DXNI/mKmTeoS/uxaRPi5GbPsEYC8L8ETCjJLB+VWyAEB57TE608q0Vx20Zmv4QanntBOxXWK/4JU7HGyPqiSMT1Cv/I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710756710; c=relaxed/simple; bh=m1QQ+FWWV3RUDF1uvHRUYpoh0aRKA7LM8m6KCGCSsdc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IPaBmOwWEiZukwq/9d4Ijx1nPXRh0jXHNgeAQMT8H/99OofTSJWqyp+W8cUZ/Om9KRbnkPmEXdLJw1C1c1FgddjjEqZU6EbQh+dj7kSyars24dBTiA5h/I7D1wB39FtwM2pbWsKFOqWNd7lsBcEDG9j1JCzzDGuQY9VqQ2lxe1A= 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=bhZikUVz; arc=fail smtp.client-ip=40.107.96.83 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="bhZikUVz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PG3t3fZ8yBAqkkHI4zNlmO0siAbr120bm5f9XN6Xuge4VrU2gafrD0Ie1kMIjKI5Mr+gESTKhtb19/LZ5nf7pzAfw+qdgfgVh3Zf82k6QpBdIsjI1NyTgrxq2Pn0vqZuYmSZCUe0rFwnYyFvo8a4B1fENIyK6lznpoySh0GOUxN+Feko2JQTecxuyX7/UnlKeybVA08ZBPbyFYr8qTiS8nPK4KXM71WfthMd1gPmawcjfRDl9c9vARVuZVL1CB6D9VMO/+ycfuEXO5pWyGpoK5ZmNKYH1L6R6jD50B7BSR6tU8BjlEB7hn2qKyYsTHoB7Scmb01kQc4cdyOqr2kMxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=Dg669zp2or/DzO43fJYX3Hpy+TmMmMMi+43WGH0vfC0=; b=ZKrBIwhHgtdvMGGq6iiNySSpYJ70BCyVp0Pwk85fXfSApEgyA1p/4drI02myUqXn0qXhhIonmAzvfYM1rE9xHU0omLVfauPe2LuyLXgrqv/OZkF3pmiWgZ73h0AC55YocGoDHwXXQ0+LlD8KNcsh8f7INywYx3o4sPeu7AM7x7S7CxZOVJZkA6VSibs5KtKGpIAQCX/OlCYFERnsNiwrx2EEALH3sCRRS5njvzAqi0kXKQkFMGwpV5oLJUVpZAchopjNorcW5eTTQ+5QHwDSeCkmtTpfQI3/voHFHUFlC9FHoGIiHgtY+kg2EckyV6A5VdrKZxkbgLjU5JaDrClNGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=Dg669zp2or/DzO43fJYX3Hpy+TmMmMMi+43WGH0vfC0=; b=bhZikUVz30h7PY6fyw3+X3mSc530jmNl4lBPeVRKqRaXF+y61d27XzdFjzfuqiaSx5N6hRN88SJ7AAI4y5HWnA6UqfS86EOD5E4N5SSErIFcRAASgM0gj0vXBXpdrvIjd9kvWkUQlXAAtNJX8x/xARX4rR612G4mSgHF+t+6Mx4= Received: from CY5PR04CA0025.namprd04.prod.outlook.com (2603:10b6:930:1e::28) by SJ2PR12MB8135.namprd12.prod.outlook.com (2603:10b6:a03:4f3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 10:11:44 +0000 Received: from CY4PEPF0000E9D3.namprd03.prod.outlook.com (2603:10b6:930:1e:cafe::d7) by CY5PR04CA0025.outlook.office365.com (2603:10b6:930:1e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26 via Frontend Transport; Mon, 18 Mar 2024 10:11:43 +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 CY4PEPF0000E9D3.mail.protection.outlook.com (10.167.241.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 18 Mar 2024 10:11:43 +0000 Received: from pyuan-Chachani-VN.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.35; Mon, 18 Mar 2024 05:11:40 -0500 From: Perry Yuan To: , , , , , CC: , , , , , , Subject: [PATCH v6 4/6] cpufreq: amd-pstate: fix the MSR highest perf will be reset issue while cpb boost off Date: Mon, 18 Mar 2024 18:11:11 +0800 Message-ID: <8e04afd3f5f8f9f9aa1a4b7954ad4b8946d11d31.1710754236.git.perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: CY4PEPF0000E9D3:EE_|SJ2PR12MB8135:EE_ X-MS-Office365-Filtering-Correlation-Id: e79d78d6-d818-4d1c-008b-08dc4733d009 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mWZKWT1Ekzh5O508Jma8MRPno2l79nNZ0mqy9AGskdRRIG+q9JaYeYgNsmc/iY8DpAAa42smCm9fQyInKdOj0K/AFC6ykZL09fGnBKsB49Rm7atx74DOuW8M+Oh9wJBLzQjh9CCsgWbCXtencUFJcFI562vBz8Ahl6Ims3bVddlqgsinvZ+Dba8I4wHRiQJKsM1vYk+BahB4FlZLPcPXY7Z8iflfilGmDPhITcBkbCUkrqtSXLgpMN6EB1XwPi2Q0om2huIoRS9iA1GrFnc8B77Lmo3KlvQ9UAS8ro33GY+BYU/On+5FEFjl6NGj3U5c9iocMypMC3TM7Ms5L7yPo4mEZXHSPP+a+H+saVt+WhVc7WLCdKDs7lOUIrzhzlbpP1c+ndMrnbZeqKGUtXBEUdelxC4subWrX7DFuslyEvhU6r1zrcuzrfS8TdtZ7tTIhKhTAfdAVWDdTH+UNIuiEaBwgqiW2sU7JGZr+DRJ9wxlp1Bk4CI6Fn0qPQKhvKg0/A+5ZnGEh7YyrZWoo3IgP98JbXp3zxK7qxACwZMps9gVlvabqRGPLVswMn/Sk87HNjP4E00djRdgpJsuV76C4SPb7VTqxIw/RWy+9JKnTxpqOj0mj0iu4XlqekTyDgQ+TGZmu46o1Yt7W32/vH8FC8yCDfnl4y6HPeuTdulf4SJxueunNwx8WNppUPk7X3baDRLhavTNu8gFCxr2qY7PrJvqLccKFOUiFnaQRM/fQPHUCoNRKlWZedDTc2Vjsoag 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:(13230031)(82310400014)(36860700004)(1800799015)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2024 10:11:43.7829 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e79d78d6-d818-4d1c-008b-08dc4733d009 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: CY4PEPF0000E9D3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8135 From: Perry Yuan Select the min perf to fix the highest perf value while update pstate CPPC request MSR register, here we need to limit the max perf value when CPU boost is disabled in case of that highest perf value in the MSR will be reset to original highest perf value which cause the BOOST control failed. Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 4cd2818045c7..513f91611cd5 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -476,6 +476,7 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, u32 des_perf, u32 max_perf, bool fast_switch, int gov_flags) { u64 prev = READ_ONCE(cpudata->cppc_req_cached); + u32 nominal_perf = READ_ONCE(cpudata->nominal_perf); u64 value = prev; min_perf = clamp_t(unsigned long, min_perf, cpudata->min_limit_perf, @@ -495,6 +496,10 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, value &= ~AMD_CPPC_DES_PERF(~0L); value |= AMD_CPPC_DES_PERF(des_perf); + /* limit the max perf when core performance boost feature is disabled */ + if (!amd_pstate_global_params.cpb_boost) + max_perf = min_t(unsigned long, nominal_perf, max_perf); + value &= ~AMD_CPPC_MAX_PERF(~0L); value |= AMD_CPPC_MAX_PERF(max_perf); From patchwork Mon Mar 18 10:11:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 781012 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2062.outbound.protection.outlook.com [40.107.96.62]) (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 5EE4D3CF4F; Mon, 18 Mar 2024 10:11:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710756714; cv=fail; b=gq0nXnxfK8+RJIJfWb5XcJHutLwlp3dxi66mnvu+8Z9YPyhBv/Bz4dviZCGEiKm6p9QuJjIBP+2jLSjJYN0zzcdVJNQTzvxQiTyeHLL7sAA1UtjrFw1S/Sc+bXXnlieN/hwIa98GnItOMFIAZZ5p1MJXxfJg8SooJGefgdLvjaQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710756714; c=relaxed/simple; bh=W+dCh9C8EntywcvXhSubkaBnZJJuzKjsF7idcfLgto4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IDbuPK7c0SA7NTcgq+JJUprTvq1PCd9r62ev+9f68sFC01ew10dXEscvrkMRFlJVFGDWYBCIz38afDZXqaQp6EI6pPdOMkd6KY/IOuuVMmmfpv/tF+E1YX9ao79Dirr0GZHXWVfCkYb+9gDGMZPx9OKCPHtgBhGn9TQj+H78Maw= 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=OFMf/xoJ; arc=fail smtp.client-ip=40.107.96.62 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="OFMf/xoJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UoMaU+oD6EqVX3wLO0MeAKadS9i0GRNpNe21Ob9NmTbGzguIuIXV9mlc/+Qbk9ikSiB+2r2Kf+0PDo+llE2KCtRyTXt2GpvNvVO26yF81FpBD34NJ5c9f2nBP6+PAJYVTEcrYR0DrU36CBDrEI0uUYqvU/ceTaiwBdmgv0Xh9ymeKA76tc2HagyycEDlYnXcAHUN5B8EufhgRr0+Lyfsil3ALZqYzuzkruaXTnxPM2Z7P0yIeA9A3KrYODAkht3O48jL2zQPz1sCpSAyjPSe1ws3DUYX63eyefEuJ1n82+wfU5pgYyPZBPhIXSnv89pUK/NIg3T9W47wcPxUpT2mNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=o8EDLYk3NSyioGPjxU+pIEAuL4I7f4cRvkuByN872I4=; b=jXsF9maqbZlFcik6+dZK4PCT7S67SPp4WAOcQ1JsgRC89gNbeta1Lw4oGr7t1pitIGrZUKvMP3P1gxSGkEpapUPJvnhbnUPPF0pMXNa9DpSb3ZHaas8GS1mvSbqPad7NKFcrVqT4qtb7cS8fU4oCytIbXv3wUrzXvsD1s85M3U3ChD8ls9bPpE/oEDErdmp+43oqlHJckvYPX6JSrcyMaU5cdZFLcNTA75qcFbEkT8KVOORoYTcWFPHcd4Qo8P58GZx02YpVSZ/rWFXaeEZ6xdtK0SAQRVcH2vqzN/oX4PBjBcZy9DZKot5ReH2YsgqClkL2cGBmV+2Hxxa6fM/wiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=o8EDLYk3NSyioGPjxU+pIEAuL4I7f4cRvkuByN872I4=; b=OFMf/xoJ+zE3a0QeUiiamITwLJwwHLF2RYPj6GEGSiS1kv0LhEhkdJRxrjCQ1H3obPTqAWEfPE+1XOqsZaR9pecdjdaZcUMZ3M7X5A6oM9UE/ATgvX70eomfuI9rjX5TT6AGTYHAQB6gSnZlZSRVYQD1H+7/dVsccQmYEJft2OI= Received: from DM6PR18CA0024.namprd18.prod.outlook.com (2603:10b6:5:15b::37) by SN7PR12MB8819.namprd12.prod.outlook.com (2603:10b6:806:32a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 10:11:50 +0000 Received: from CY4PEPF0000E9D3.namprd03.prod.outlook.com (2603:10b6:5:15b:cafe::cf) by DM6PR18CA0024.outlook.office365.com (2603:10b6:5:15b::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.27 via Frontend Transport; Mon, 18 Mar 2024 10:11:50 +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 CY4PEPF0000E9D3.mail.protection.outlook.com (10.167.241.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 18 Mar 2024 10:11:50 +0000 Received: from pyuan-Chachani-VN.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.35; Mon, 18 Mar 2024 05:11:47 -0500 From: Perry Yuan To: , , , , , CC: , , , , , , Subject: [PATCH v6 6/6] cpufreq: amd-pstate-ut: support new cpb boost control interface Date: Mon, 18 Mar 2024 18:11:13 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: CY4PEPF0000E9D3:EE_|SN7PR12MB8819:EE_ X-MS-Office365-Filtering-Correlation-Id: e0991a4a-d80e-48fd-e593-08dc4733d3dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RI2ZaYE9JFPH1Y6Fq8Y0pXUXz9SGVBQfRl5VXMgCtdzIRScqFHbvNwf7rdKeKAwyudslHz8GJQtv1BjvAhjhG3SBvg8VjpX4KdP/0JKuI52cVyEsFxgnErbchXVt9yaJvW/tPMhWKU5yc2kmvB2MP/apliKP5vgtgJExWmcKuhRL/qeKBtJbV4txdBoWiHOBLLVYx39nK367Bdpx/bdDD3bT3DtEoj3MDzWox7NxQ8Snn/r55GWFk33/+o6orl82akct3VUN1xwBAzXcA9o+Xb8miWeO4Whc55g+Qdtl7ofmCCEPs0HAt6coJObswjQAisU5rQylNsXetM/5FXfvY3ooXpF8i8OdikOe7EU1mqqrekBJsSAC0Io6lMkFKv5mbdIAAIJk6EnhU898a21YgaO8XN7C8yVTKj8gfQuS/zBrx8eo3K4FtcXsbDH3+Azue9q6+HaIzTvZ1OZXESoZLvoV9INJ80h1YD2jWTMDzqYZYzhsgrdHVyU7ZzZ0D/56qntqVuYxps7m8dGm3T7NnTbVL4jY6JVauLJFrsnBZc38mqKtRdvvSkAsUNhCwEjao4DgWLenTsYxOB9bV/QJR5wa0w3isLnxWbmASltwVR5y31h6ORbO11XATzAuQqoDm3+GFmC+krm1UzmW2svPUdb/KavvFdchaSGzhE0t5BkoixD4fGfwOCgFI5ZYOB9AvPZzSksPDnSZN13bmN2tjLxZqQL1wXw2KC5Swg5QHUOdmWs1gKVmEM+eV2G4uv40 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:(13230031)(82310400014)(36860700004)(1800799015)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2024 10:11:50.2047 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e0991a4a-d80e-48fd-e593-08dc4733d3dc 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: CY4PEPF0000E9D3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8819 As the new CPB boost control is enabled, pstate unit test needs to remove legacy `boost_supported` check and start to use new CPB boost control interface `amd_pstate_global_params.cpb_boost`. Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate-ut.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpufreq/amd-pstate-ut.c b/drivers/cpufreq/amd-pstate-ut.c index f04ae67dda37..b3601b0e6dd3 100644 --- a/drivers/cpufreq/amd-pstate-ut.c +++ b/drivers/cpufreq/amd-pstate-ut.c @@ -226,7 +226,7 @@ static void amd_pstate_ut_check_freq(u32 index) goto skip_test; } - if (cpudata->boost_supported) { + if (amd_pstate_global_params.cpb_boost) { if ((policy->max == cpudata->max_freq) || (policy->max == cpudata->nominal_freq)) amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS;