From patchwork Sun Dec 8 06:30:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848406 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2040.outbound.protection.outlook.com [40.107.102.40]) (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 521C71E86E; Sun, 8 Dec 2024 06:30:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639458; cv=fail; b=bkL/7BZKKA1Tr755546W1YTyIglZAbRvn8vOho9HHos7gPGfFiRtUXGrBf3O7fxNVpe0D1KVV02MgL5EK2R5EoPvgVWBN5bszOw4Fi6GWNspPMgw/uPI05z2hsf+eIUndg/yKOK084vhlEZbm+SbMxbrFwCNG+kd/yn5TZcYAiI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639458; c=relaxed/simple; bh=UeYbhWvQcmWInVcHnNY1JbEhvvPPfHrL8JLlYCSFOJE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JAlU7zucDg7AKplVIUKCQ/htkzk8oKMva4TWEBSzpM6ZfYMJ2hGvHxUQxmxVZq9Y9Ye3QHMyGpZ6NLpRpocT9P2F8lwfkiTuWpC0BwJO4TcNGYR+PANZQgV7jATufceik6wsOgCHcF0B3HZ+W1wLDK6wtma2L5LLe/3KYo3F/lM= 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=QwYWZDxT; arc=fail smtp.client-ip=40.107.102.40 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="QwYWZDxT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F0pM/eCsepYnHU2aA42rCTZ+ff9snM/CZiocIJjk80h0FJxbMu4mPDkslGZ20+0z4BTfPAmZzU284VQm3na+Wy2IkpeZjEbLmiAh7Lop67hROin6vbOvBSOL+Eru8+TSgHjJzTi7b6kC0XrDAN9mgWilG98j96/xKU2doUO48ibQX/6jugZzkiwTTuyWznmbj9RKmZTToxVkvCmHVhwdD5XlNp6iu5rH1qrrqHQLk1/aAjMyCsmY3PzzrfTIWnigmFfK/fgxsDXzogm4G7YRZiCRTtUp7LjYpynYDe4dknCefLzaL9ZpS46ZL8AYswVU2jHqFaOVf+jGKxKy7URSHQ== 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=GFQ7YJImPddudTRBlzJyzW4I+aKSrlmWqIIyVP4Ca9c=; b=qt9I28755lhJrBbwgLSQmk0Rhy1roAaY2BRNCZzDgT5iZNEX1rzcmTVoP/rgd1OVbCmAviaJH26FvKwa/0MDOZe5aP9tPWg8wP60/hD+D880j4aaBPk6tLDcSqXKsPee28m4ZJh7xBGPpNrlStD5+YwCJvQgom2UEMMoJca/fL5oTa4IMxumHMbnTJJZ2KP2XUgUjjycn2PYtAHu2MUgADBjO1v1EduimeRWplF0F1VzzvQiF2o5IlA4UPqbGHrw73ZQ6NAMdvIIW56EkIa504L2ZMsr4WgMWxi+0/YgyLDHxMfm9iHYpc1HSP2luE0i0ydu5Zp/VatisakvCDraqg== 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=GFQ7YJImPddudTRBlzJyzW4I+aKSrlmWqIIyVP4Ca9c=; b=QwYWZDxTNjVYCDBFPU1Kz0PdSSSdTa7ZjwHjGYSyvgaA2nu+ySiotXrBZQ5pZlS3Iq6JxlKH4X0C4mGLvLfVFXOpqcEADrmjoQwtgVSeAaLCzM/tc0TfijxoVEtGq6gedrrHQ5wWyg0aY57mpXYdf8IMFP3T0m8qbH1TYIZTK48= Received: from DS7P220CA0001.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::6) by CY5PR12MB6249.namprd12.prod.outlook.com (2603:10b6:930:23::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Sun, 8 Dec 2024 06:30:53 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::f6) by DS7P220CA0001.outlook.office365.com (2603:10b6:8:1ca::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.14 via Frontend Transport; Sun, 8 Dec 2024 06:30:52 +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 CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:30:52 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:30:50 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello Subject: [PATCH v2 01/16] cpufreq/amd-pstate: Store the boost numerator as highest perf again Date: Sun, 8 Dec 2024 00:30:16 -0600 Message-ID: <20241208063031.3113-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|CY5PR12MB6249:EE_ X-MS-Office365-Filtering-Correlation-Id: b75a59dc-eb1d-4582-ccc9-08dd1751dd3b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: pJHhY14kuL47hNNC55dKY++Us3M6jeWRLU5VVW7lqWwH1UphH/SaL8Y3rc05l0ErAXaofbglAZ/c5rxIeu9ti2j3lUumWzMm4P2MCn+57OEmM1hHUxyvA4pkQCBHb13zBoXE2Swy523l2dXsgkW6c3rwcBaFLDA/bOb6sCvss3jpwvVer3EtAa8Rc1COTrhepPZLvFC30C5AtKM+RSARFR6H1d3hfVMFvrD2Rts6nHHtoDMHdlztrppAsMvcaS++/v2F9scwnDMS87ncq0yNlnjqFEeqhzPfyBAnfpKT6fDRV62jMIYG+GaC4s5T3v3iFcgO5ibMx3lyE47QQHnA5V6Wayz2oibH1k3NwUz2vxtxfZ4IuxOXPZ2TIFMftOJcAgIRB5u2NZeWTKYFLnRkPDIA1IR6aFPSJaaO0G7Y9s2wAv4umrpsHEsG2EE+yjwBNo6+gJZh9EgO/mxomhJidzCiowOYMm3+cAgwRy9BxYPutZA1e9qgKZzwXwxqfUr6rPdlQFYJGhS32m48HrnOD/jTurGESa9bgoGu8G1zq7RIMAfH7PF+nCSOfIh/daiTg9dFVmIGvsDQBMGgrsPR8QoQ/s/j7M5LMe7JeK9cYoMih+dwCxtynXvGgDEMe+S+UsrTcs8oXZspBaeTgQXbaw8eUz1MAvjrYdST+aYoZ+kuzSH280P5FTYZ6p7/Og7qbiQHnyA0X4BWxhz4tMJj73WstIBrRWqK+seO5fyystlV4iLQdzX1JPG4DRAh0PR3MjNOzJFl5Q5ccw+ZrqL5XhM8lcl8UN+QLO/78G3L7tIYRVBodWPAT3HACzQDXm5AMCONJN0frhNvi6bd4htySVe7ClzbQXdY9fgAoCqY1xHil6E40BjvC/MSF0LZ0uhFiUiyYzhL5EEzUt+DG3LOA7h2PWrkYC5/u3jc75Fay1Fu4RkR9DLCHgpFGCdZ4+mcm9BS4ahYwk7TP6RtYyM8yX5mur+GE+p8I/b+tzExp3DXnQQYiSCU1WRqs4f66Ax6MdrD4HoOimyiC7Nds+UOtTdynrvf/d8hc+QYNpmK35LqNeXFY5MHbFeTijYvCA8JYOdRPFgrxapL/NiHpptEO/idSVe9UhoO8juVBq9tny0M9Quub3cXotAZgDxrc+d4epcXeNvhrk2AmTVISEqM2KR2YlGfoxjeBMKaSlPpaZXKls1kc1WaFBPnfVylrbjlNkW2jjKe/KVXYsc9HUvDeyew0PY3BTlFYS9ORXbU+nrJxTnvRjxW0ugyMXEvdNEA+TjHQXuOpmb58/anxrC2+Un4UqZLDVTDkwu5ToWTxxWTTN/8K9FnZ4Z+bv22iee62y7fNkQkHL/rxvfonQo+S2dWJfl3E+IfQfeXdoYmAQAfE/cW7021nBthkUEH0lqAZ+g/bQ9gaCBySrsKlZcqMea3l0J5pKTfNzxvaZUW0quEh8A+74wu3/o88LGWLEHK 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)(36860700013)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:30:52.6233 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b75a59dc-eb1d-4582-ccc9-08dd1751dd3b 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6249 commit ad4caad58d91d ("cpufreq: amd-pstate: Merge amd_pstate_highest_perf_set() into amd_get_boost_ratio_numerator()") changed the semantics for highest perf and commit 18d9b52271213 ("cpufreq/amd-pstate: Use nominal perf for limits when boost is disabled") worked around those semantic changes. This however is a confusing result and furthermore makes it awkward to change frequency limits and boost due to the scaling differences. Restore the boost numerator to highest perf again. Suggested-by: Dhananjay Ugwekar Reviewed-by: Gautham R. Shenoy Fixes: ad4caad58d91 ("cpufreq: amd-pstate: Merge amd_pstate_highest_perf_set() into amd_get_boost_ratio_numerator()") Signed-off-by: Mario Limonciello --- Documentation/admin-guide/pm/amd-pstate.rst | 4 +--- drivers/cpufreq/amd-pstate.c | 25 ++++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst index 210a808b74ec2..412423c54f258 100644 --- a/Documentation/admin-guide/pm/amd-pstate.rst +++ b/Documentation/admin-guide/pm/amd-pstate.rst @@ -251,9 +251,7 @@ performance supported in `AMD CPPC Performance Capability `_). In some ASICs, the highest CPPC performance is not the one in the ``_CPC`` table, so we need to expose it to sysfs. If boost is not active, but still supported, this maximum frequency will be larger than the one in -``cpuinfo``. On systems that support preferred core, the driver will have -different values for some cores than others and this will reflect the values -advertised by the platform at bootup. +``cpuinfo``. This attribute is read-only. ``amd_pstate_lowest_nonlinear_freq`` diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 66fb7aee95d24..c51026fe636a9 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -397,15 +397,19 @@ static inline int amd_pstate_cppc_enable(bool enable) static int msr_init_perf(struct amd_cpudata *cpudata) { - u64 cap1; + u64 cap1, numerator; int ret = rdmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1, &cap1); if (ret) return ret; - WRITE_ONCE(cpudata->highest_perf, AMD_CPPC_HIGHEST_PERF(cap1)); - WRITE_ONCE(cpudata->max_limit_perf, AMD_CPPC_HIGHEST_PERF(cap1)); + ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator); + if (ret) + return ret; + + WRITE_ONCE(cpudata->highest_perf, numerator); + WRITE_ONCE(cpudata->max_limit_perf, numerator); WRITE_ONCE(cpudata->nominal_perf, AMD_CPPC_NOMINAL_PERF(cap1)); WRITE_ONCE(cpudata->lowest_nonlinear_perf, AMD_CPPC_LOWNONLIN_PERF(cap1)); WRITE_ONCE(cpudata->lowest_perf, AMD_CPPC_LOWEST_PERF(cap1)); @@ -417,13 +421,18 @@ static int msr_init_perf(struct amd_cpudata *cpudata) static int shmem_init_perf(struct amd_cpudata *cpudata) { struct cppc_perf_caps cppc_perf; + u64 numerator; int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); if (ret) return ret; - WRITE_ONCE(cpudata->highest_perf, cppc_perf.highest_perf); - WRITE_ONCE(cpudata->max_limit_perf, cppc_perf.highest_perf); + ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator); + if (ret) + return ret; + + WRITE_ONCE(cpudata->highest_perf, numerator); + WRITE_ONCE(cpudata->max_limit_perf, numerator); WRITE_ONCE(cpudata->nominal_perf, cppc_perf.nominal_perf); WRITE_ONCE(cpudata->lowest_nonlinear_perf, cppc_perf.lowest_nonlinear_perf); @@ -912,7 +921,6 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata) { int ret; u32 min_freq, max_freq; - u64 numerator; u32 nominal_perf, nominal_freq; u32 lowest_nonlinear_perf, lowest_nonlinear_freq; u32 boost_ratio, lowest_nonlinear_ratio; @@ -934,10 +942,7 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata) nominal_perf = READ_ONCE(cpudata->nominal_perf); - ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator); - if (ret) - return ret; - boost_ratio = div_u64(numerator << SCHED_CAPACITY_SHIFT, nominal_perf); + boost_ratio = div_u64(cpudata->highest_perf << SCHED_CAPACITY_SHIFT, nominal_perf); max_freq = (nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT) * 1000; lowest_nonlinear_perf = READ_ONCE(cpudata->lowest_nonlinear_perf); From patchwork Sun Dec 8 06:30:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848405 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2063.outbound.protection.outlook.com [40.107.243.63]) (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 256824174A; Sun, 8 Dec 2024 06:30:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639459; cv=fail; b=qVVggnkiyYcB1xz1novcTMiH9MsqlAs5zOLyXc8TfTxeyHTsxWzrqoSu2vYHf7kbfUeQaSrPLXwLSaWxMuDat/W0Sw/+BnHySMuiPuot3TMrHjT9DxxUIKeqNo+oa0nDhVt5X1xKMjo1CervbhYdegA4wxnSHGZ7PAhk3wtXSw8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639459; c=relaxed/simple; bh=1hJEV4TDhoGWDNUVBi1hBVjXPxwh22hJPz7IsiVQiEM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dbVdvizZxjrBznMUiglN0+WG12pDEts6GlYtcXly3dHvrl8nnLGU26qtkyKrIPOI90VL5sF7KNdoceQDDFO/JeJqiynGujbBmFLz9ZDmsiugaxjCy37M6Fz5osggAJeWov3kpfZqqD7PcSAO5DUrkgpFzNeJBKFNUuBc30rYCeI= 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=XO+71rZr; arc=fail smtp.client-ip=40.107.243.63 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="XO+71rZr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=u3a4ok4Mfw8+m1oKd1/N84o4O5F8+ZIxBJ8FuCUXoEelL2sAKVUezBq+Giuj85xvDn0wa5OoDSgY/agccdR4Xk6PFN6sJooCfFX5ec8eoHkR78zgSrrl6K+fXqC8WLA4SH6wDmCS0Bf10HKOF7ld89Ix+krFwvTolwB2i/aof7xH9XI/+sPxlbovFnGmym3b7DEs/hPRTWhiHv8lznFRZfnKGU1HGvkwljdhdJfU1hGZiiNdTiBLlRuXlEZktkmYQrJYhmVh5+bWfxR3cPCDGtgHWK579+FoCP1k1+TpczCgSOwOFbKQqo6ld9ly1METZ8XVjZGw8kXLbG5ZYdgCEw== 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=ucqe8HPLacp3VkKxDehsSMBwOsryPZmCHnwY2O0VS3Q=; b=nl0ffdHNIyyt3+XZMapDiAgPr8WKYeIZra5B17pni1jAlsLbRs3O7qbFBHCqCKCrIlWbScNgEau0GYLH1PhHQB1EoIZisLbeXk8Tyww1R+Y+lpz/ktzuATXx9fXJA+S6ohvIW6gDXfkKqsaxp5dP7pcBoe4iLGNI0ghvRAfFFJHCbTtUlgWhumhhtQxgiqOsA0l46n3sZb4GmR0ToTua/7WEQ4VxRay99xVqSybV5JZBBfmV9WwsaD8uDicqblMtUzIrPrxs8BRBEQCSG7j1QxwVFFX1hJKhnkqKWENPJtXQ8W5BBEoBCJ7mTt6kkF7H+QCMy+wHWMZ+LrgNwoV+mw== 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=ucqe8HPLacp3VkKxDehsSMBwOsryPZmCHnwY2O0VS3Q=; b=XO+71rZrWE48w0uxzA/4YrvT1jpBuM/9L6k3fMJTb9e5+aVUAmBjn+F6/d+lSHU94IJLUJO4L5T/IrF5LXp1/H4OCZEpmkMkBOz5ZN8gD8uiuSx+087Dee26zmTFtAR31n2JUYclW6DThOJ6InqR8mERn3rPrYRQTR/sq0HzrCA= Received: from DS7P220CA0006.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::10) by SA1PR12MB5615.namprd12.prod.outlook.com (2603:10b6:806:229::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Sun, 8 Dec 2024 06:30:53 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::b2) by DS7P220CA0006.outlook.office365.com (2603:10b6:8:1ca::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.15 via Frontend Transport; Sun, 8 Dec 2024 06:30:53 +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 CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:30:53 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:30:51 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello Subject: [PATCH v2 02/16] cpufreq/amd-pstate: Use boost numerator for upper bound of frequencies Date: Sun, 8 Dec 2024 00:30:17 -0600 Message-ID: <20241208063031.3113-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|SA1PR12MB5615:EE_ X-MS-Office365-Filtering-Correlation-Id: a5c81229-bffd-4476-3db0-08dd1751ddae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: ncR+OsL7/qNA2raQnaUjXjHylzGbXq/9M2w+Mm/QhzJdSdX90niSduLmcvFtxWo4WIJcN3qjL/7pM92hV1jd5isbWWrdGR1aiPVXE3ZMKizwBHVHvV4VTJGFJlNdf3SmALLnPR0vnKzgdFk37kKhvaaX+fbc2nlug6A4mN4hXHJYFtceC5OOyHjZ0N3hBztNnoW75zM5zMhYArf3X3cHKUgYo8qXqIHFaB0eliws91e1C5V1ThWdKtfBSHTDBpWNLl4wf4D8yfwBN8IbQj/woKX5USQwmCqTrJ0QXAMzwrr8gLWGxiXfoJbP6Ynt9nYlHG4MUYgD/mvqcvZOcJ3x+soVCuCQewcSPKc3WuMft1Vm2UlNg/Ip7zEBKyO5mCdG6TL7hC5yIM8MGH76gfADBJCQLkF6fTJsi6wlhJkh5luffN7L88jQIPuJaEQ5DKeasKFGPOM7FdBRtHN8cgH9L2Mj5DybnS5KBbviMJGNUrmCWU28wUoHkm3QuTtnaWHL/Vtz4mBNXSLMPqwVfaQCOLlEMTZZhogM1vNpG3ts1gayzQp3Vlcvw2BDrgMC7uLaK5atCkVrpgOQM8vigvWPDHgA4clLtChF+a8/VWsrRGt/EI3WTnniQOK+mxGU9yolZATybf2/WFSaQN9nxgvkeZRF6Nzp52PEem/8QBXG/Qb8X4tW5sxsEX321LDjChmy2lB0VoMPWliBDtnUgW+wZKEEtoiIYONSJSMPuG6Tr6EZ2S2XpaiYXeCLiRQcHyGo5SEl5HvN8VqBv6kiyvw64quiPuF6UKSzknvmPVIYg/U+oVSt2rqOJP75EJUexvSVcDfnpN/Ls68B/4J1NBGX21oODEKnZYMNehLMbIl66yK3VzWL8XsW5xL0/hganBnIWayPp2nR1Md4zRCPBWpvYhQF9FK35WGTuFojvHlderIKIPOHZ5qcOdrk8Hgn9ayfef5D2v+7vHAZQKFpuENFB9vEkS7IPwFdiLsb1ou1nvDFfQa84TxvVwYM2sZj057LlNlmz+ikwV3g1S2RxqhT+33dUwfJ43PwzeWrGgqiI8DF1Bbs+l6E0NP8kqPo97YKMgkzaVFjNjowmA3stFr4CojSnNAetXHze3cFbNepjwl0HRr0ZEUW7n2VOX1vJG2PkD7ZU8iijGbHq3GuJGnPrfkxJ1C0MuTt9AB8KIJGjSP4PK4XM4+UT64KiRAau0kGirfKwKTmFmm/HisFeg4WjoIjn+5qgQSscipyZRIn8QGl0DgJLeMd2bWXpeXqI8u68l75oSRQz7LKBY+mJVJUd3xzUlenIF6irLf/svJQSxyloNYaj4lRSzK0qoUMUfiSqymkT+8LDVIRAw5bDFRQCC3Ag4zt362y1MOhDDtKxFQ//Bye1ZzGzOqLt0Cdqxjs3zMt1SRj8xUlWMhSKZLEZhD2o8thNB4toU6K0t4NTUDw7UpP7C5LdQReB78xq5cr 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)(1800799024)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:30:53.3733 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5c81229-bffd-4476-3db0-08dd1751ddae 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5615 commit 18d9b5227121 ("cpufreq/amd-pstate: Use nominal perf for limits when boost is disabled") introduced different semantics for min/max limits based upon whether the user turned off boost from sysfs. This however is not necessary when the highest perf value is the boost numerator. Suggested-by: Dhananjay Ugwekar Reviewed-by: Gautham R. Shenoy Fixes: 18d9b5227121 ("cpufreq/amd-pstate: Use nominal perf for limits when boost is disabled") Signed-off-by: Mario Limonciello --- drivers/cpufreq/amd-pstate.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index c51026fe636a9..5e0edb65de32a 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -593,16 +593,13 @@ static int amd_pstate_verify(struct cpufreq_policy_data *policy_data) static int amd_pstate_update_min_max_limit(struct cpufreq_policy *policy) { - u32 max_limit_perf, min_limit_perf, lowest_perf, max_perf; + u32 max_limit_perf, min_limit_perf, lowest_perf, max_perf, max_freq; struct amd_cpudata *cpudata = policy->driver_data; - if (cpudata->boost_supported && !policy->boost_enabled) - max_perf = READ_ONCE(cpudata->nominal_perf); - else - max_perf = READ_ONCE(cpudata->highest_perf); - - max_limit_perf = div_u64(policy->max * max_perf, policy->cpuinfo.max_freq); - min_limit_perf = div_u64(policy->min * max_perf, policy->cpuinfo.max_freq); + max_perf = READ_ONCE(cpudata->highest_perf); + max_freq = READ_ONCE(cpudata->max_freq); + max_limit_perf = div_u64(policy->max * max_perf, max_freq); + min_limit_perf = div_u64(policy->min * max_perf, max_freq); lowest_perf = READ_ONCE(cpudata->lowest_perf); if (min_limit_perf < lowest_perf) From patchwork Sun Dec 8 06:30:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848646 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2053.outbound.protection.outlook.com [40.107.94.53]) (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 7A65822F11; Sun, 8 Dec 2024 06:30:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639459; cv=fail; b=nNjucJHv6vmZ/we3eODHZ+YNs+uuogQ1V9Gnq3vuEaDjRuNhfQ/etUEkjs1sG/PGt1GsgxkWrG/ff8dYOj/vZ1XZzfJ+TdbnmUnSmXfjYbV7U8EB+Sstw5exAycHzDZLW1HmCCnyuYqScZ5NoDpLRnO7KzNp3e81cplL/P+lbLc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639459; c=relaxed/simple; bh=mbGSROJp4wSwquZuym2lRA9xfWQ7OOjejKLhk3ZWCuI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c6Ik+hdBoZrDhl9Y8PObz8e5AL/FZYC2aCEUdvrxE36H1o0RZh9oowuuWS/6OowGlKfnMxa+xclqUjF7gdSxT3I1Wl+EE/lgHQ3HI0HSiu4MUepiRpc04eHXcjxDQwP4xyYNaSLfN4hS0AS5EyDMWBbXmtvem5kjLoaZaErBK7M= 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=W6XZirBs; arc=fail smtp.client-ip=40.107.94.53 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="W6XZirBs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ubq5JJ5am7tFSLPyInbpW0t0aG/vF6wJzH9qWLLtMX/BNA3Hm6CVDr0MWrPYuNxowobgAyjsTo0XjWdFtLiLaJHHLEViGZ3bo9ksysPo0kzVxT5+vYAFIYA+LtT0axpcsH7U6swH4rNUhEjiQWkYcMwv+75E3CoX4T31/qUWZkQikt9Lz4XoDlujzSe7I9yne1RTSsz9XLdN5XHU/NP7tl7M+gyOgb/WKL901CAdD4gud6CpNZONl6yEvT78pFskqfdG+Jyya2Ox33kxLaB534SIh8DRVBhPlzm47+y0b44ouydGCMnL6LNAJWib4eyHiNwjjQbv8npGEK4ohPgT3A== 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=lo4tJVtZZmMIBRDMm+wEsoDtzBFcHTiYqL96ys7GfJQ=; b=DUMPtrUjhmWNzjdbW/e84chzZRev9ItSc1dmaGSNXU1LwCNvDPuBHr3s8BIJSnu/j2v9T172sH5HzyEDprKKvNKPq9jB4TgOJYJrtPKOwFSGmkkU/5/Iggeul7wLmXJ0k1fzcBXRI4d+/T8S2+FVcqD8IkJdurHCCppUHTNeKJBF17qJrchTJQ1Xnf2pbDubW2w+0FtJrt6w0I1xWg19FmArjc3KxGP20+l3Y9HJkv1+Bpw2EkPIY/G8hJN0+TIJ1edRX4l8+GITu1QSyn4S1TPyB40W25JoOtkqMplnjZXcpw+h9w7D6Q4CRJyLeBGjT50ztn8AVaKb5oBSsbSmGg== 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=lo4tJVtZZmMIBRDMm+wEsoDtzBFcHTiYqL96ys7GfJQ=; b=W6XZirBs9hZxyCP2ULDw1CkCCifJwjVuZZT7dkcTB3o0Jmq+ys7zkJS0MPGlurKnPko9Ks9nDHw7xmJ/vWuY6a0mJoAeNpm8H67NUhNxewu4JqPnTGIqoIWn3fr2d6CKhZnRT2QgNcA/fE4O3MF1WJjmSibwuRNmUwUMUYVHGos= Received: from DS7P220CA0002.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::12) by DS7PR12MB6286.namprd12.prod.outlook.com (2603:10b6:8:95::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Sun, 8 Dec 2024 06:30:54 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::e8) by DS7P220CA0002.outlook.office365.com (2603:10b6:8:1ca::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.14 via Frontend Transport; Sun, 8 Dec 2024 06:30: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:30:54 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:30:52 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello Subject: [PATCH v2 03/16] cpufreq/amd-pstate: Add trace event for EPP perf updates Date: Sun, 8 Dec 2024 00:30:18 -0600 Message-ID: <20241208063031.3113-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|DS7PR12MB6286:EE_ X-MS-Office365-Filtering-Correlation-Id: a9b69f3c-83b1-41d5-aec2-08dd1751de20 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: NH2cCVF9ajQXUrqDSLry5FGQP+y7+/gTVRcelbvrSkHiOblJWrSsPSt8QorI6kVcf2T/H3eG97PFqKPnZ8qi/YWpyjqn5SgNFFDebybODjd7ufmQ14KP7gRIVA8hjfVB+yDmIAAz0wfSWvOjF0pozpGB7xJ6zN/t+R3wfc5hp6JD67UGouhvjmkKeDCJl9Rc0DCmRMdjrSG5bvR5ewz86cwSU+afQv7qYYjaz8in2H15t2P6B2D6935/kLgmwFT/xna6jJX+30SYBzzYon830nUtwYPnQ8iW50HqJhCcSqWprZBe4Mt1FiOulw38wiR+Mxymhaozdm87NWnSUch/96Oj6rPsDh2I0+IxdqjvXFSn+8r6B8TLjgd2ZJ0NBd4bv0cBCg+OWNgfuB1Hzz62tpH07lcKI6BvVeXqNV/jwCHZRArQrax/pEvqZxT8B7Uzs7rxTs/zELZlgh2663Mh90JDgAesAQQu1knT5okI3WSEYPq3rNkxkyuDfBZNOqluUVWIKHuY5McgLHmdUNYLFTaWy7A4S63Z3iWIwYAi8T0NNvQAALXtZabSahMvLsu0JLDecXuZRaDy5yOZCU4jK9aZ3ejvsyvDaeVe0xg6w0BOUbiYdSs5WSV5ld/l9zohsQQ4lOYzxe5ooigHPh21sacjoqCS2RXORmJIHeX3I2kCu/2tvMkcluId2y754Be60E95lhZXNL4y6nygl3a/bAuHei1WVUyTplwR/ouk4dMH29wdZWTPoASoyORGNNrECw1wV1YZco7G/OhLKx/b5ANOOVJ1sPUqb6mg1tddBtdVniIijyPJGsFUKuHjxq4gR3FUwkiRq3d9RIsGdMFdiukvTtNr/W1iLre3LWGIHNx5+/vcPGhPxD4inVZRkNETPMoV+qlpgIvj106QMUm3jLqDUI3NluG6I6q+QbC6jZwWms8ERS88SY7TWAN+kSGkLpiLqqfMRWfYuJcJMtZPnxB7mh+rFIFVKLBph6uynE/i7QYIMg7WhyY72cDQH+gwdrKj995jsQzZSrP8zh9RQDmajK+IPv14xNEuddCT5F9QfbS1zPLSN7Wz1HvnWv6hjqZ2fGr1AFjU4wPR7Sj6sZWusJ9UDq8OD4iq/WunjmXrxCb4HQPJpJ8ABCNXFwtKocX0JXjSSCSDU2NZ8GZWt3wv15DO9uNlmn7foFa6R0y4AyjwbXWp4i+TA8WykndOpPE/Xse+RlvZuBCTODKO0NYFXxVmpkdi3daNHyu0PpNMorj5B7FccSpU0TgmKQhd69VK4Y1JQ1a33wsGI5+5AS2taAIO1SsH5ABFCX5JcE+vijohjJqWymyvyEflxBrSngiBDgQvtc6YOcs9HRkOJ+qkRGz0WBJxb12buTW+hy7RDSAAELyrxaO8F4PxAzozWSTr6sLg0zzVFzosj3AD/cHU0VBxV3QcHC/0CfcaJPvRCGXC3czj00cjzlVe/Xph 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)(82310400026)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:30:54.1389 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9b69f3c-83b1-41d5-aec2-08dd1751de20 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6286 In "active" mode the most important thing for debugging whether an issue is hardware or software based is to look at what was the last thing written to the CPPC request MSR or shared memory region. The 'amd_pstate_epp_perf' trace event shows the values being written for all CPUs. Reviewed-by: Perry Yuan Reviewed-by: Gautham R. Shenoy Signed-off-by: Mario Limonciello --- v2: * Fix boost in some calls --- drivers/cpufreq/amd-pstate-trace.h | 45 ++++++++++++++++++++++++++++++ drivers/cpufreq/amd-pstate.c | 28 +++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/drivers/cpufreq/amd-pstate-trace.h b/drivers/cpufreq/amd-pstate-trace.h index 35f38ae67fb13..e2221a4b6901c 100644 --- a/drivers/cpufreq/amd-pstate-trace.h +++ b/drivers/cpufreq/amd-pstate-trace.h @@ -88,6 +88,51 @@ TRACE_EVENT(amd_pstate_perf, ) ); +TRACE_EVENT(amd_pstate_epp_perf, + + TP_PROTO(unsigned int cpu_id, + unsigned int highest_perf, + unsigned int epp, + unsigned int min_perf, + unsigned int max_perf, + bool boost + ), + + TP_ARGS(cpu_id, + highest_perf, + epp, + min_perf, + max_perf, + boost), + + TP_STRUCT__entry( + __field(unsigned int, cpu_id) + __field(unsigned int, highest_perf) + __field(unsigned int, epp) + __field(unsigned int, min_perf) + __field(unsigned int, max_perf) + __field(bool, boost) + ), + + TP_fast_assign( + __entry->cpu_id = cpu_id; + __entry->highest_perf = highest_perf; + __entry->epp = epp; + __entry->min_perf = min_perf; + __entry->max_perf = max_perf; + __entry->boost = boost; + ), + + TP_printk("cpu%u: [%u<->%u]/%u, epp=%u, boost=%u", + (unsigned int)__entry->cpu_id, + (unsigned int)__entry->min_perf, + (unsigned int)__entry->max_perf, + (unsigned int)__entry->highest_perf, + (unsigned int)__entry->epp, + (bool)__entry->boost + ) +); + #endif /* _AMD_PSTATE_TRACE_H */ /* This part must be outside protection */ diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 5e0edb65de32a..a59c897dd59c7 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -324,6 +324,14 @@ static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata, return -EBUSY; } + if (trace_amd_pstate_epp_perf_enabled()) { + trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf, + epp, + AMD_CPPC_MIN_PERF(cpudata->cppc_req_cached), + AMD_CPPC_MAX_PERF(cpudata->cppc_req_cached), + cpudata->boost_state); + } + ret = amd_pstate_set_epp(cpudata, epp); return ret; @@ -1598,6 +1606,13 @@ static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy) WRITE_ONCE(cpudata->cppc_req_cached, value); + if (trace_amd_pstate_epp_perf_enabled()) { + trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf, epp, + cpudata->min_limit_perf, + cpudata->max_limit_perf, + policy->boost_enabled); + } + amd_pstate_update_perf(cpudata, cpudata->min_limit_perf, 0U, cpudata->max_limit_perf, false); @@ -1641,6 +1656,13 @@ static void amd_pstate_epp_reenable(struct amd_cpudata *cpudata) max_perf = READ_ONCE(cpudata->highest_perf); + if (trace_amd_pstate_epp_perf_enabled()) { + trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf, + cpudata->epp_cached, + AMD_CPPC_MIN_PERF(cpudata->cppc_req_cached), + max_perf, cpudata->boost_state); + } + amd_pstate_update_perf(cpudata, 0, 0, max_perf, false); amd_pstate_set_epp(cpudata, cpudata->epp_cached); } @@ -1669,6 +1691,12 @@ static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy) mutex_lock(&amd_pstate_limits_lock); + if (trace_amd_pstate_epp_perf_enabled()) { + trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf, + AMD_CPPC_EPP_BALANCE_POWERSAVE, + min_perf, min_perf, policy->boost_enabled); + } + amd_pstate_update_perf(cpudata, min_perf, 0, min_perf, false); amd_pstate_set_epp(cpudata, AMD_CPPC_EPP_BALANCE_POWERSAVE); From patchwork Sun Dec 8 06:30:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848645 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2059.outbound.protection.outlook.com [40.107.243.59]) (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 05B2683CD2; Sun, 8 Dec 2024 06:30:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639461; cv=fail; b=JBNPhVg+JtD9ZaULLCF0Rj7QaRKvlvN61rhL0W9Vi9JCx2EskJvhdXJ0g7XtoZw03uiOVI0bEKW703b7yWEkbpVrkDZyBFSm1pGkTgU9uLNo9XsbSuVs5ZYnUsitFvHGFoYv35JjnE0Hw5+naTl/szpnvnho+Iod6iTbytQy50c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639461; c=relaxed/simple; bh=8IcjiCBRBloocPYDiXM+yy0x6VYm2tN+z9Yn19WjWAs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XpLHDr+wSjAwbdkrgtdvxiToAMSzxXZG1iRYYpFVEhkf6UlYo0NhnuvIRcywnYuKy0VTBQagIayvyNIzh/M82Ff4urzVEv5uEoEla8V2AOGqKs8jsAEEPFsPn/PdYBwKa7EjWQ4MWaC6AVQ28j/yTyiLG40+1Sa39qOrju5/bDw= 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=MmrZxJHQ; arc=fail smtp.client-ip=40.107.243.59 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="MmrZxJHQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KDJ25I0uDTvz3dIRjo7Tmm2JFv8owr5AoiXDLL46VxOWYHretWvWX0tM/d4l6CI/W2biHTGcDlnpTieUydR8UUhHRVmTP5N5ROB0vuxJAsp8cyf0ZaRGUVty/RrOy5tZJ0xH9IHagGaAfkVpXnMqxRSMVTuoZTRR8iLK99ipGrF0qmRHqMGIxJp1lDwGF+nYshPVVTuEU5XTpl00Lol+3Biq9JP3pltlb2IrwwngJo339grgbVnsxVYtWw9M4frnYRcVHQ8V+fH4imLf9vGX9+OufAxtNz3WT8zq+ANCgQiIxK/KREW30nSlSyUMzj0WX87F3KR5MifLonQKf7s33A== 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=b9okcBsyNIrSTLz/dzY0VUNNUwo9aBdy5mYXE/fMqWg=; b=pdN8QbcYy4pa790RX5Xuoeod0s5WEobdifosxzLNA4pm1bmVYhdDr1bjgij1/jmUuqKORST3CVafJfuhaxUXl3ml+S/PMOs8hw2znlcI+yK59JnccSfIUoJ0EBEylKik2cWdR9k7ONUqK04XS90REB33pHiF98NVRZxYMMby5WzLe9036kLWgrmC6+4t2T9oGkdVHUg/kRRco1OD/VGdGgqf7xmQtkhcP2zouEkIhaPoHSHbQVeWRzpKLQ271b2HRyx2FxxAGzGPWvrRicR4rMWncuIgpTNUTZKvUghbLCw+P42XeWJvDBRrskg1iQ2hQd9/Bp+yeOEH/kijsZPaOQ== 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=b9okcBsyNIrSTLz/dzY0VUNNUwo9aBdy5mYXE/fMqWg=; b=MmrZxJHQnEmPLEF+i8zAT586oz2smYInxjO1vZqQQGngKNxDCRapwUziExxSAosMMbVRdFHFfsz7fIyfoscO9Yep9nM3/bPJByKXDlePJjXiMFU0Oivv5B+HvADqlspH1nyfmoyaiW96lP/5ohThIFF6s34MoHizZqK6pWBjHfU= Received: from DS7P220CA0003.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::17) by BY5PR12MB4289.namprd12.prod.outlook.com (2603:10b6:a03:204::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.17; Sun, 8 Dec 2024 06:30:55 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::25) by DS7P220CA0003.outlook.office365.com (2603:10b6:8:1ca::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.14 via Frontend Transport; Sun, 8 Dec 2024 06:30: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:30:54 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:30:53 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello Subject: [PATCH v2 04/16] cpufreq/amd-pstate: convert mutex use to guard() Date: Sun, 8 Dec 2024 00:30:19 -0600 Message-ID: <20241208063031.3113-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|BY5PR12MB4289:EE_ X-MS-Office365-Filtering-Correlation-Id: 03609699-0f0d-4ac1-aa3b-08dd1751de7d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: uSaBRfH544oeuHTUeiQr0iNFeF+BW75fvNzx6RMcnTcXiOXWVpjsx9+XRMB0h4jDfORKUL8RjAN7GDQs2c7Te0K6nM2HSZsowFThuZZof6FOApXPx4LDCsfxG1q7vpbWBYmSeGV468ePwPKYXwv70JefImWrPykcP1DLJ2DImZlfMgKbiFVd2ZGADw0E0QHmMKfzMd/lsSvVZIpyD1ntA+0Mv/oFJgBt+5qnOWnL0rOfBf4g1TUQ3IGMSSMzZ85EfwOpLb95yHOAcpE6EqLsinGkDU4POCLrL84fZsRqO+czutwrEwXHVQlSnr9yKvL3cTxUsJuCYS9qc+u+iSBhK9iC0Ue3LeIMiq+IpzIkW1EgJL5P++gBOg+AN77HaopNIoe4/YUezFH7bgd2ttdXm6oGqkvIB6ZZlgE8o/ie9jVZE14J4QPoCEfYpK51AutjWbAY/K20q/3Jzj0dsd5ow2wY0LwNUMyKq0YhyMd/ZAdi3E/yjeWQI8C4CtA3GFxWsn9yptVr2WBlDht5kAO+qTrDTTD1LPNxQ7sRmMMjSlcWMKHPR4agSX90+50EsGSf24nXHXR9gknj1ICWTDaA5a19MowselvIfcrGcWqe2PsWToBGnoYfzYj3agD7zB8F4zfugv0U1gUepXguz7G8bVPOhEN2F2wQfIF+OvB0zBOQ32BNd5yYWayTbsaryev16tk/fzk2qqykVniQFbpJQU+hOh2KaT94/go/i/uSJ42t1/n6Lvu2i3Sm3KsvyKV0xsUwigk1ANFalpKODdbYV+hAsQEz6CaHMwBIBVYOndtlvxZNifFYRY/FBFVgDtS5eo3Z1rfrVcIlDVKXtxn2K/fQN4ADIxDcMcjkntF/Dh8EVjvBEQaQiJSjXadAGehDB6hGovE2JtqJifDNA/tEoUo0EJ/KM29DRxao8Cyx/jrkkV5Xft2RwHZTB3MVqxSEAiRLBIu/YviANWI8f7jbfng+mjRS6WAa07wgXqjNf3UuuNTdd4aN7BlnrjpO+wpbMwz4yRWgtxiHpMZg+0miRlq9sQLKJ6EsLOjLTd5KA1vhJ9ThpPAFqHvZuVsBuVZnqkRwc0JOcXvXcvgCX+s9ZTrFbdhCRWsVdAvhp7SmOObKDtJsatgJHnGGZ1CIpYug9K0XOgyvPFOMXm5EMSV+kmLOSJ3EX378VBgVRg27pp8xtyv/2wwDI5+Ycr7u4eP+BTdos9xXMY4YlQulYbf59LKsLZNXN94qdP18zIu34HF+PsG6QOoI4aSYv4GUXzAeN+31jEkhLth4rxZRpeigKiAYUP3WaW5Pr5JjHaWopllKJMe1ZN+gTXmA3olt8Du7KwXXSIgleV+wORZuqndlZ2JrT2e5viNfyYzFCL+8tU51bn6bS58o87T1ektGkuz5Q4GBhghjqi9b2tK++fFVKAIhjYVDkRzQrkmPMqL9hShcqGZXL2m6Z5o39Bn5Tx84 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)(1800799024)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:30:54.7483 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 03609699-0f0d-4ac1-aa3b-08dd1751de7d 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4289 Using scoped guard declaration will unlock mutexes automatically. Reviewed-by: Gautham R. Shenoy Signed-off-by: Mario Limonciello --- drivers/cpufreq/amd-pstate.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index a59c897dd59c7..6a96d3a24c77e 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -758,12 +758,12 @@ static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state) pr_err("Boost mode is not supported by this processor or SBIOS\n"); return -EOPNOTSUPP; } - mutex_lock(&amd_pstate_driver_lock); + guard(mutex)(&amd_pstate_driver_lock); + ret = amd_pstate_cpu_boost_update(policy, state); WRITE_ONCE(cpudata->boost_state, !ret ? state : false); policy->boost_enabled = !ret ? state : false; refresh_frequency_limits(policy); - mutex_unlock(&amd_pstate_driver_lock); return ret; } @@ -854,7 +854,8 @@ static void amd_pstate_update_limits(unsigned int cpu) if (!amd_pstate_prefcore) return; - mutex_lock(&amd_pstate_driver_lock); + guard(mutex)(&amd_pstate_driver_lock); + ret = amd_get_highest_perf(cpu, &cur_high); if (ret) goto free_cpufreq_put; @@ -874,7 +875,6 @@ static void amd_pstate_update_limits(unsigned int cpu) if (!highest_perf_changed) cpufreq_update_policy(cpu); - mutex_unlock(&amd_pstate_driver_lock); } /* @@ -1203,11 +1203,11 @@ static ssize_t store_energy_performance_preference( if (ret < 0) return -EINVAL; - mutex_lock(&amd_pstate_limits_lock); + guard(mutex)(&amd_pstate_limits_lock); + ret = amd_pstate_set_energy_pref_index(cpudata, ret); - mutex_unlock(&amd_pstate_limits_lock); - return ret ?: count; + return ret ? ret : count; } static ssize_t show_energy_performance_preference( @@ -1371,13 +1371,10 @@ EXPORT_SYMBOL_GPL(amd_pstate_update_status); static ssize_t status_show(struct device *dev, struct device_attribute *attr, char *buf) { - ssize_t ret; - mutex_lock(&amd_pstate_driver_lock); - ret = amd_pstate_show_status(buf); - mutex_unlock(&amd_pstate_driver_lock); + guard(mutex)(&amd_pstate_driver_lock); - return ret; + return amd_pstate_show_status(buf); } static ssize_t status_store(struct device *a, struct device_attribute *b, @@ -1386,9 +1383,8 @@ static ssize_t status_store(struct device *a, struct device_attribute *b, char *p = memchr(buf, '\n', count); int ret; - mutex_lock(&amd_pstate_driver_lock); + guard(mutex)(&amd_pstate_driver_lock); ret = amd_pstate_update_status(buf, p ? p - buf : count); - mutex_unlock(&amd_pstate_driver_lock); return ret < 0 ? ret : count; } @@ -1689,7 +1685,7 @@ static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy) min_perf = READ_ONCE(cpudata->lowest_perf); - mutex_lock(&amd_pstate_limits_lock); + guard(mutex)(&amd_pstate_limits_lock); if (trace_amd_pstate_epp_perf_enabled()) { trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf, @@ -1700,8 +1696,6 @@ static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy) amd_pstate_update_perf(cpudata, min_perf, 0, min_perf, false); amd_pstate_set_epp(cpudata, AMD_CPPC_EPP_BALANCE_POWERSAVE); - mutex_unlock(&amd_pstate_limits_lock); - return 0; } @@ -1730,13 +1724,11 @@ static int amd_pstate_epp_resume(struct cpufreq_policy *policy) struct amd_cpudata *cpudata = policy->driver_data; if (cpudata->suspended) { - mutex_lock(&amd_pstate_limits_lock); + guard(mutex)(&amd_pstate_limits_lock); /* enable amd pstate from suspend state*/ amd_pstate_epp_reenable(cpudata); - mutex_unlock(&amd_pstate_limits_lock); - cpudata->suspended = false; } From patchwork Sun Dec 8 06:30:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848643 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2082.outbound.protection.outlook.com [40.107.212.82]) (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 A31E7145FEB; Sun, 8 Dec 2024 06:31:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639465; cv=fail; b=SXv/aO2vUsA2aJ9ul6UxRBtH0kViBHdzCAmc52CQHQZLlqweMCTLWQtFVGFhM+uIx8mPDJhLeb5FZ5zD5UsMaqfTXvPcSkV8GFFgwJ3iG/rORM2XQweZdFMZdFc8/wsyhKC6TWLWaG8RihZDupj26aeZrY5/yioefTMWor4VNVo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639465; c=relaxed/simple; bh=6MTHRL5MHUSp36pwBet7p28UW/1GIbDwH06pyPCfy2s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fGY1P0kv+w4wvWO9gUKgv8DRGf/uSQbfM6pKos+7iE2GVamP2IxaTBwiL7x0BEm7T3M2/GWypppGwzo+5IfXUInTwoMPgepGzKtKZBmaWeSCuNYrxKYLb5Us6nxaFlHbPVlJ992kgW9jmIHFToKhNNL+yzdxRwaiu6zqlKGoJdc= 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=orwbi/MW; arc=fail smtp.client-ip=40.107.212.82 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="orwbi/MW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=orjMCa2o4IrM8ziN+W8/pOsCTn8pbiQEO5dEXwyBx/t5OA0FNZX6nZQ3que9MKGNl7JA6TwQym173iu/0qZ2H6Eby5i+b0/H0+XScGrE2D0tx2x5O4bvPhv+zGglPDR3jLGKEJe/Gx8yk5tvsQfxpMnK3zKucqYLcY8gCTPRIs1LwmDdn+uZC7vLvSD+wRf9pTHveKdUuEKCOESe2QqkDAba1zAWw4saWq+TPlCnNbQEhNZot5uYB7j6J7NQbQFZht0PG9x8T9IbG256esm8tTQG0FlOg1Eo1tegmOg4mFwNLxtk3Gk01HNlUEdzKst1CPMhlqA6HwBSK+x958+OHA== 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=saJk+iuS5VELA3XAGJetWjnvUPeLQzFGvShlQkEJD4k=; b=VtGjtr1ynVbgq+2J0BIbX0wzX2Q3LgGMxs4PfXb/a6BilThawpPy6ulk3hsPxApCiMUdxGgcplB16U+Zxwj8f+AIuY73KLOISCLPvgEkm51BN+N3mQArocE+WuBAUaKu6GI6k2uruHVfPVcis8cbrgIpnogXkntOUXON2iL2fF60hZplk2Ifxc3L+WOGZd5ZOL0fTpRNumub5Z2w4+6oPSPI/U6xvewCWPqsNXO7WBnuAn3m3oQUogZP8GGP4w5dLNEBZMmSVbJGAALlP5NRphxk4JqGPrhoktZlUgCDlC5xFPQWPyaIKlj7hQMMRc/SOP5HxwZ65YoXtvs30NlawQ== 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=saJk+iuS5VELA3XAGJetWjnvUPeLQzFGvShlQkEJD4k=; b=orwbi/MWzVa+rX1Z8LZr+OsfVDrA4cNrUJjF2QwaMzJVtPIzLfRSkD2bgzMGl2oTnCrdD2gCQVe8dxCJ82ptq98DYIhEc0xSv25sypRucWDg6ihwKskPvGPIepSP2WA+DsF/RwfqyaAaOjSr9cFJOm4iw9WC3wJflID+xSNeFrI= Received: from DS7P220CA0002.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::12) by SN7PR12MB6838.namprd12.prod.outlook.com (2603:10b6:806:266::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Sun, 8 Dec 2024 06:30:56 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::22) by DS7P220CA0002.outlook.office365.com (2603:10b6:8:1ca::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.14 via Frontend Transport; Sun, 8 Dec 2024 06:30:55 +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 CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:30:55 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:30:53 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello Subject: [PATCH v2 05/16] cpufreq/amd-pstate: Drop cached epp_policy variable Date: Sun, 8 Dec 2024 00:30:20 -0600 Message-ID: <20241208063031.3113-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|SN7PR12MB6838:EE_ X-MS-Office365-Filtering-Correlation-Id: ab363126-cdff-455a-a485-08dd1751def9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: AQAzv7bXDYluqLL7FmXIsDuWvXfRiWe4ZYakwffNlCiGDq+vN4tRf+vIapWsdfoz9nLs31X3SdLElAPy1WwJwTUrBarGteq3cm5IMGDm0T4exPAtQHG1qSw5grzFePyFnRKuCpn9rMGr8ri9ydzlgAvuQLWHvPdixMrAmHe73/fVg+8tFaqYPhy5yVOETZs8HytxTbt0c/ZoxMUtkrNdHUR524Lgr2D262EB71hnwwrTBwHm0ONyvM1FNbfiLW75uhTZDpFKvS/ifkZpPdUmKs03UIXSHs6S1Tqqcp6SgXJfSj4t0guXY6DqaNK/XzhSoLmYy9QhV0XFj+rlLgr7eLG5zUY54BoeDJ/u6TDNtR7x8qQKVu4PQCjRL6D86+Rt5EbsnkDNiRj0mLUKi+Bh5fCLw7Y5lExnRiCkXm9BroVq05FL2SMjSGRh3z7/4q7amf+lFCvOLkLwfeisMVryTuAdqw4wwTgY1kYTuxyRS7dSaQkpyx6AeLNZi8yfjlt9y30zUQosIWSeEp7j1Bz/X/ooQu/xJLKE2hQj/2QWYS0v30Ph8HVZ4DESSxv2NsQEVHMOZB+BukAQxGXOhDTVT4ekYO/0VDr2SaJMkMSBjzTfjbTpaW1XzBdJETf27oMURf7JvdVPFqDoxUYLUQJqgy/owiPQHoo74slDgN0L0v2J/3xWC5e3VawCp0Go23Eb/gnlv99UOrDAAXwDEEsHPunj7q1+7SszP4dKd6QesjasRsbg2PdFXknKG3qTXCiD+BUB7VJQ1Fn8nIwhn2XZhmUDEIjMzOa24ldeIII+tTh914xVFlRCLYVKK8QyPh7Vov5TeIocCjzoBHjdvTxGLMp7t6lSZmHP9w8lBcdCrQNrZ5ONky/qVpJuhx+sZG4u287yIhwj10alU2qKBbRm/agPxBP6YhWy2+6Bm58WXtnPhNr+vL1qLOOkZnz0wkiwdH9ISn3np/4XNoOjpmMNoF9TfMIkZKUcymeIzuvt03bNs04s+AkbQAeYCgJ4tUULtAFEgZnfG8zOaMMR3v9enLXE9qGhtzGepSJvLipvqZr+m0c/5r0gsMRa3Nl/RsRsypnq3kcpKKRbBn93pXeEZaSb63lOjCatWwTBoP6V3UkDt91YWwFnREHCOaVg/ZbWldEFr1V0eVvu8llVhoHV1XlGQbLTT/i1o9r/CAsLbuaeO26gEQBpH14PbHmELTAfFbukofQJ+wTCxyQyklABVpCY6i28V6GSeh5LWXkj1rXktohu+j9oi4+iIcdiSy8KyG7pRXdTYIHa556lDoUHCnRZ9wIOiWbPe4IzWr/M1jKWAL/FF/+aUPBQlJr4pvTwfqDuNqZ5MxaW7RnC1J/7rxgqZ8jSW0SQgCB9zl+OItfoz2U3KmXaeiQ6hGrM8eMOHCN9cw65yzQuRJkZJAbTMkYduKXMaAYwij5NEC8uBMaV7ZNgg7q0JwU/SNJ3CsGj 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)(1800799024)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:30:55.5452 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ab363126-cdff-455a-a485-08dd1751def9 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6838 epp_policy is not used by any of the current code and there is no need to cache it. Reviewed-by: Gautham R. Shenoy Signed-off-by: Mario Limonciello --- drivers/cpufreq/amd-pstate.c | 3 --- drivers/cpufreq/amd-pstate.h | 2 -- 2 files changed, 5 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 6a96d3a24c77e..dd25e7e615984 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -1478,7 +1478,6 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) return -ENOMEM; cpudata->cpu = policy->cpu; - cpudata->epp_policy = 0; ret = amd_pstate_init_perf(cpudata); if (ret) @@ -1585,8 +1584,6 @@ static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy) value &= ~AMD_CPPC_DES_PERF(~0L); value |= AMD_CPPC_DES_PERF(0); - cpudata->epp_policy = cpudata->policy; - /* Get BIOS pre-defined epp value */ epp = amd_pstate_get_epp(cpudata, value); if (epp < 0) { diff --git a/drivers/cpufreq/amd-pstate.h b/drivers/cpufreq/amd-pstate.h index cd573bc6b6db8..7765c82f975c6 100644 --- a/drivers/cpufreq/amd-pstate.h +++ b/drivers/cpufreq/amd-pstate.h @@ -57,7 +57,6 @@ struct amd_aperf_mperf { * @hw_prefcore: check whether HW supports preferred core featue. * Only when hw_prefcore and early prefcore param are true, * AMD P-State driver supports preferred core featue. - * @epp_policy: Last saved policy used to set energy-performance preference * @epp_cached: Cached CPPC energy-performance preference value * @policy: Cpufreq policy value * @cppc_cap1_cached Cached MSR_AMD_CPPC_CAP1 register value @@ -94,7 +93,6 @@ struct amd_cpudata { bool hw_prefcore; /* EPP feature related attributes*/ - s16 epp_policy; s16 epp_cached; u32 policy; u64 cppc_cap1_cached; From patchwork Sun Dec 8 06:30:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848404 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2083.outbound.protection.outlook.com [40.107.223.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 8E12F13B280; Sun, 8 Dec 2024 06:31:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639462; cv=fail; b=enWwzQJCh9JsPCnob9KPsz4oyI5Em/qR/Z2JCLgBjTFVRD6UMJBNITd4ghzDTfAnbVM3k/flsJnKaTw4WwG3iAGkkRvM/0lPZ/Dhtif5cq9j7FY/fGfkZwM+M65ajD/PRQj1Bz7W63mQ77GZhN6GhvUl/Xh+rLC9yuuZdF+cTiI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639462; c=relaxed/simple; bh=bIwEkB4RisuaBUId95SyAh/ypfFCch8mxVSwKmvYZ4g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=s1epgRZ/E6nkxjQLhxNZ5BKIZMTeDIA7mfDSrQSW8fWeJp9OvAYyYhFkr4i//z2uggCuGenTs8cZ8kq+wmLLlgrqX7JKNgwi71xm/8SL+Jsie8TzX27c2tV5HZ7URNE/2kOn1EcDqWRMy6GnKaZw+/QhDc3K8yv4xFk4ooXsn08= 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=WX4H7RI/; arc=fail smtp.client-ip=40.107.223.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="WX4H7RI/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jqSybazk/6r4N0C3r+PUZuEzIPegcARsIiR5Ayk2Lg6bkqJ6ZHGhcw08Ub8FfZXL7I9pyXYsSvaMmbLZ2RzMCKcsA+01xhTkg9TIU5sdLEGcJz3n3JxiAhEz6R6aVIo2+MZOrrEWQrBprQjwdsW+tnol6Lm30zidLab/ZqwUzVGnEBGaVBP1EDmFXUnhuAlOTvFO+fW130bDnhkSaYVDKlKlLXKtLwSAOQEm+T8MX345cQbzaQZz1AvvfYSgV2z6/R9RzH4HAXytm02PwbiAisAxXzxsIbCRogr9x1qc8iUCrbg0yywh8fKrYrPfaFGTnOzQyOeHZSM3PB6DeDwZjA== 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=58MdHhkW1tfwOPWWvmX8ZgK7hZsGT/j6kAdVv3nR6ZY=; b=rzSobRA1iAHXvWXnuZ6uGTTOV8XI9W68x98+XeH1eX4yqAzo/5rItvRMvEgV/iJHfmNDile/vGoH1WgdIJi/y5C0jXGpRJIqdop6d0eiFvXu6IXbOxo+MfoYFGvcORobQW+sD4fzvzKcFmF68OWexnThyxtgn4SrOli7cq0gQR8lpFtzS9DPinj9VwM6czRSXc/yrLXlMrP37Gga5TZUsktBs4due8K8e5LEnDvUAQLnSMRJHo5hhxnjma983Z6+OZ//0GGHhiNSYiEPwbBJvjEOAwb0XnffejncD+02fyqffE9ZqdTR67shpNB5DT9llzbrJuKGGW5+72oWo4IN8g== 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=58MdHhkW1tfwOPWWvmX8ZgK7hZsGT/j6kAdVv3nR6ZY=; b=WX4H7RI/1uF1uU+EzAKhx2NfZe/ureYOrPDXB/kX7jfzN0lSEdcgp4YgKKClZJoomD4PacNWBoA5F+9dLDAp3cpoDSo43FAtIcf9ZjUVnhkBtkqO/kvuda5ZVYFB9cbHC0zBY2F+HJIQz1H1Y9vgyLaprqFfhh33+YPXl2FVHAc= Received: from DS7P220CA0004.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::11) by IA1PR12MB7520.namprd12.prod.outlook.com (2603:10b6:208:42f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Sun, 8 Dec 2024 06:30:56 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::b4) by DS7P220CA0004.outlook.office365.com (2603:10b6:8:1ca::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.14 via Frontend Transport; Sun, 8 Dec 2024 06:30:56 +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 CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:30:56 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:30:54 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello Subject: [PATCH v2 06/16] cpufreq/amd-pstate: Use FIELD_PREP and FIELD_GET macros Date: Sun, 8 Dec 2024 00:30:21 -0600 Message-ID: <20241208063031.3113-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|IA1PR12MB7520:EE_ X-MS-Office365-Filtering-Correlation-Id: d1f493ef-5b00-4cab-639a-08dd1751df7a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: w//cFdOE37yygib4glWmp59LHx/f0xvJ6LeWKeCLc4uAjbmn52phyr4tP6QQIqofBGuy5yeKJ2sXH7trOv39UQO4AbvAlrtHiea64WzNznT03CfaL44lJ76ixgUX35DNp9I3b76Ez5IcXYZcz0mNCAZ5KqXhpwvaUF1o1bHATKVlJ9eiKwb2qPBO2cjYmaBRSDyMeYJjDMmbBtQHwxpm+4KRwlQFoH0MdDkEucL33H61T0pvfHo05jVStSZnaQVRJKcjFh5n5wiBv/YucEkFFWq6nqqzCYjm8HWjRZ4ScknCrjdqaq4RDsObH7w0nWWcQvmopCRrNDe3JoRSPpEA6+0p/oLDzP8lCp6W9/7S4Zk4faQbySibhOA/6318APDodzrdw6PRBUsSYYaf9Akr8ZUzWRTQKR1hHDW6PFnAytji3gPJdE5K7+4jb9UMZUqNdnchuiQxfhmRB6QiywMI1paDA8DVY5lUTx0bc7ObSVaBLKPTRhRAtqkObV7MybOLAu4Dg3vCiKNjIrW78FX91dgFjrilH0rCpxdqH6ix1KpPNHyNg4RAcOJwgzPDQCUqwr+pEvKREmGeoYs3iBGTMyyLeb8IjshXMvoOxbnBt58YyUlKR/8b4qWyGpewbpOqNiQEgA8saVFOSr4vnqakO83jt3v06fTXb28dxfj6xhSBPJohmiXzOXDVJQ+HHf5Q1PTV/6UjoFvCQyqrHxrw5oGmRQNZoofuixH1xYuQmNA60dc2SnZOS/oFCW1bVheBOPfdev3z/XuCRil3iNMLCpK9ZpAeFGTpGHZtJbVAnpwQa5FA3Yp/wKkxIl89s6kmawA40qgIekf57Z6vz6MiPtO6IyPWEcIFELTQEhYIvzlqqpUZGgpkQTI1p4XWVA/fsnEIDkxF/nAq088QKD+2UvNW/64WoZBrbcXO0DYrB+ql8DJHhS02NOJryG2O27zquAEBNUWP1WyBxLopRNRo3NfYblbO8HyL8oU5IvjKpenn2uQxPJH926VwuelLZOOsaWE8bR5N1ZO3QuJccfvtXRuKXP4gfnitBG0lUN8vqOkHOK9QQKdKWQsvtE7qfS+YL7zbPIU0JsRUTTUEV4OWAmmKURQgygewO8r/LjR9p5cq+F1x86P7TzcCmoPxOdX6lv5K/d5OPFji29OML5lIgMVUlrJalvJfZtW28D8Is+gQD5k3rTMRU9/t8VbANxGep8Zl722OIVocV9DDviRzgWWEhU52yNXLxXW2HKimsYXbJQv85LVoRU52Jni2dhnZ1eJOhC6Ykl+Hix8TvJbPALRgi3/o2yA3qOsNVW2iyQ/Kl1UMSwomLpVxSjr0F9Hfs2zuQ4iBWsTGOv2Bf2xAyvoKVMBCydyzl4HQzKh64x9HHjHDFSuPZm/6dErAwKUhqo2ESLft1LzP5vC0OcTMpyqeE4G4O8o15Xhf3NAcC+w3VQpQvMAGm2w7BpVNNXow 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)(82310400026)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:30:56.3889 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d1f493ef-5b00-4cab-639a-08dd1751df7a 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7520 The FIELD_PREP and FIELD_GET macros improve readability and help to avoid shifting bugs. Reviewed-by: Gautham R. Shenoy Signed-off-by: Mario Limonciello --- v2: * Add a missing case to traces * Use AMD_CPPC instead of AMD_PSTATE --- drivers/cpufreq/amd-pstate.c | 51 ++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index dd25e7e615984..0ed04316a8d80 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -22,6 +22,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -88,6 +89,11 @@ static bool cppc_enabled; static bool amd_pstate_prefcore = true; static struct quirk_entry *quirks; +#define AMD_CPPC_MAX_PERF_MASK GENMASK(7, 0) +#define AMD_CPPC_MIN_PERF_MASK GENMASK(15, 8) +#define AMD_CPPC_DES_PERF_MASK GENMASK(23, 16) +#define AMD_CPPC_EPP_PERF_MASK GENMASK(31, 24) + /* * AMD Energy Preference Performance (EPP) * The EPP is used in the CCLK DPM controller to drive @@ -182,7 +188,6 @@ static DEFINE_MUTEX(amd_pstate_driver_lock); static s16 msr_get_epp(struct amd_cpudata *cpudata, u64 cppc_req_cached) { - u64 epp; int ret; if (!cppc_req_cached) { @@ -192,9 +197,8 @@ static s16 msr_get_epp(struct amd_cpudata *cpudata, u64 cppc_req_cached) return ret; } } - epp = (cppc_req_cached >> 24) & 0xFF; - return (s16)epp; + return FIELD_GET(AMD_CPPC_EPP_PERF_MASK, cppc_req_cached); } DEFINE_STATIC_CALL(amd_pstate_get_epp, msr_get_epp); @@ -269,12 +273,11 @@ static inline void amd_pstate_update_perf(struct amd_cpudata *cpudata, static int msr_set_epp(struct amd_cpudata *cpudata, u32 epp) { - int ret; - u64 value = READ_ONCE(cpudata->cppc_req_cached); + int ret; - value &= ~GENMASK_ULL(31, 24); - value |= (u64)epp << 24; + value &= ~AMD_CPPC_EPP_PERF_MASK; + value |= FIELD_PREP(AMD_CPPC_EPP_PERF_MASK, epp); WRITE_ONCE(cpudata->cppc_req_cached, value); ret = wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, value); @@ -327,8 +330,8 @@ static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata, if (trace_amd_pstate_epp_perf_enabled()) { trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf, epp, - AMD_CPPC_MIN_PERF(cpudata->cppc_req_cached), - AMD_CPPC_MAX_PERF(cpudata->cppc_req_cached), + FIELD_GET(AMD_CPPC_MIN_PERF_MASK, cpudata->cppc_req_cached), + FIELD_GET(AMD_CPPC_MAX_PERF_MASK, cpudata->cppc_req_cached), cpudata->boost_state); } @@ -542,18 +545,15 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, des_perf = 0; } - value &= ~AMD_CPPC_MIN_PERF(~0L); - value |= AMD_CPPC_MIN_PERF(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 (!cpudata->boost_supported) max_perf = min_t(unsigned long, nominal_perf, max_perf); - value &= ~AMD_CPPC_MAX_PERF(~0L); - value |= AMD_CPPC_MAX_PERF(max_perf); + value &= ~(AMD_CPPC_MAX_PERF_MASK | AMD_CPPC_MIN_PERF_MASK | + AMD_CPPC_DES_PERF_MASK); + value |= FIELD_PREP(AMD_CPPC_MAX_PERF_MASK, max_perf); + value |= FIELD_PREP(AMD_CPPC_DES_PERF_MASK, des_perf); + value |= FIELD_PREP(AMD_CPPC_MIN_PERF_MASK, min_perf); if (trace_amd_pstate_perf_enabled() && amd_pstate_sample(cpudata)) { trace_amd_pstate_perf(min_perf, des_perf, max_perf, cpudata->freq, @@ -1573,16 +1573,11 @@ static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy) if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) min_perf = min(cpudata->nominal_perf, max_perf); - /* Initial min/max values for CPPC Performance Controls Register */ - value &= ~AMD_CPPC_MIN_PERF(~0L); - value |= AMD_CPPC_MIN_PERF(min_perf); - - value &= ~AMD_CPPC_MAX_PERF(~0L); - value |= AMD_CPPC_MAX_PERF(max_perf); - - /* CPPC EPP feature require to set zero to the desire perf bit */ - value &= ~AMD_CPPC_DES_PERF(~0L); - value |= AMD_CPPC_DES_PERF(0); + value &= ~(AMD_CPPC_MAX_PERF_MASK | AMD_CPPC_MIN_PERF_MASK | + AMD_CPPC_DES_PERF_MASK); + value |= FIELD_PREP(AMD_CPPC_MAX_PERF_MASK, max_perf); + value |= FIELD_PREP(AMD_CPPC_DES_PERF_MASK, 0); + value |= FIELD_PREP(AMD_CPPC_MIN_PERF_MASK, min_perf); /* Get BIOS pre-defined epp value */ epp = amd_pstate_get_epp(cpudata, value); @@ -1652,7 +1647,7 @@ static void amd_pstate_epp_reenable(struct amd_cpudata *cpudata) if (trace_amd_pstate_epp_perf_enabled()) { trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf, cpudata->epp_cached, - AMD_CPPC_MIN_PERF(cpudata->cppc_req_cached), + FIELD_GET(AMD_CPPC_MIN_PERF_MASK, cpudata->cppc_req_cached), max_perf, cpudata->boost_state); } From patchwork Sun Dec 8 06:30:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848644 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2042.outbound.protection.outlook.com [40.107.94.42]) (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 195B513E02E; Sun, 8 Dec 2024 06:31:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639464; cv=fail; b=U/WdzAHgrdV9nWQHdQ+SnpBmdW/PAPWZqynJpl9XMSwuiQTurARHRKaB640f3ppxtpypVAYxN5a6hXXeRRnPjzLCoyhWajsP2DBN1uoVd1PIjundGkP2wXQldFGxLRShArQrbvKoC3YkIHKYWAuSod6CZ9YCrnT26kAY0iZ8+b4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639464; c=relaxed/simple; bh=8rrIrjCDFbNsIF6xmI6OBAOMh30oWMQvH3qh+qoEXk8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WpMdGaqvHZ5MiKJBVCoPMY6iVJv5iZ2mrRn7N99//s3CBc/BPRL93got/FKvVpKliz6lqN+iUa/H+Sv/HJlWZZ+ti3vf5Q9ZQ5sz6qSIfeVXo9V0StoAi2tXboq/iArwqC1w2Zakloh3mGwhYdBiNSHv6AMYDrMGe5ge+AChT4Q= 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=eolPT3aH; arc=fail smtp.client-ip=40.107.94.42 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="eolPT3aH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Vg+d+Z/0S6zbEvh857jUxE/R/+24fToR47hNVFmR9uEnRnBZ30dpm7QdtPXtuiabgRn5gehw0GIN+0WDCrNfhdd878Nn+S6Bp7S/j6W4hbyK4ookHeLmFbyzWMaC5nw4o7dfJKrOeJRwpc4yC+elmijQboiS/9d/oxxYBEHhAj63Ar+V59sVQ+zy/cjWtabzqzB60/Mu3jxRNrECZnsL9pv/lKYskkG167+OeMwtrjiryoOjsyz7Af8NkfN5mW+7u1NpQMFIVxlZrHQKis5zGtyi2mRTcN6uukRiMLX4fdgXzdh5jNoAlLoOuBGLXFWRe40MC/vdLS88fpl78Rb3Fw== 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=eroh5IEn3WgUrc3OYPL2JcIXey2+LfsFTzzdzmAMo+c=; b=k8VVH/PAt5van+7bypJTFjXZgW7dTywE62PvK/wIyi3p8kF3wgm+4fiB52Bjqi8WjC5rMiWBI19er56S20NXIW6oBP7A1fToTmTLcbXfOyQWxWpDh/n9bak7IlLQE+I5SdccWPIXy237A6rmAWu4lRbpToSsx905x2ZeZklOeYIJbXSK9tHrVBA03aoKK0wt6WnH/JgihHQG50+o8SQb/ShH2zh0ZneugnaAc8eov3XX6pE5cemRU4gP12qNI2lIaeNR6prx7b0JxdzLMLxSyyzUdgOjNOS/eST86wszXODL/DIR2LnmW/Q3tyDSx3WnzYPs0eXORUEbWH6IdstVog== 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=eroh5IEn3WgUrc3OYPL2JcIXey2+LfsFTzzdzmAMo+c=; b=eolPT3aH62bxW8LjaHTF6jgnXVDWfeRMND/dMj0yEnbU44MIihGHrFJ7NWl/3jxAYvapih1/HmKgC+3WDUajMJwAQCYaZX8M6M9a9wJkciBd4kRx6P3xHEbdF/rVUJE67rreVHFM1BrHkDqPIWRYYbta9h4kimx2576jGcY57JY= Received: from DS7P220CA0002.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::12) by DS0PR12MB6583.namprd12.prod.outlook.com (2603:10b6:8:d1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.17; Sun, 8 Dec 2024 06:30:58 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::c9) by DS7P220CA0002.outlook.office365.com (2603:10b6:8:1ca::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.14 via Frontend Transport; Sun, 8 Dec 2024 06:30:58 +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 CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:30:57 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:30:55 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello Subject: [PATCH v2 07/16] cpufreq/amd-pstate: Only update the cached value in msr_set_epp() on success Date: Sun, 8 Dec 2024 00:30:22 -0600 Message-ID: <20241208063031.3113-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|DS0PR12MB6583:EE_ X-MS-Office365-Filtering-Correlation-Id: 19e78c13-6e81-49f0-4535-08dd1751e05f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: vE6pUVhptpb+UgpfQ32GjWJN454eXYFXagD77Hbm9FUJEsUPwqQp7Kzj5MKq7HAgR+ZsNY6ljolo114cGIg98WfhQ+ZNgJQ/V1mCDItbgVX8WRPJ2wqznOSGy0C9fTUqaObCWkBoXlsf8co8DVsp6YuMUQkbh2wGLWr32kT33rYayEQImSwr6k1Lh1g3v3W2/yoTnPQcEYCBlmgDaY3ior+o6fvd3aMHYkFFXKjUhTcGAhxGf16nq++J0Tkhdb4NPfMR0t6q00GW8xJF8EnyHeH2ojf3fxbK01E596jc1uGzhbTDDiQSztkvEZRcKCzb43GKu3jSeB1PJun6XiTwcvNhgdtScV3DnhMf/Bw3+LVNJwVr5YsjkfzV3pLY7K18ERqRU+88W3+PQxLhFakmzCsoxMnA8duRoNTcRO8YYH6C5Am12pU0JReiyyRE9rLrfxrfNafw6iYyfLB3Ov7hAt6tanuF8Mmv5Lwq9bvrIIUidwELPz3ioDwDI4dFGtUa1JDvpmJK5Fwa1K/YdfcP0eATCvcDW+hfgSL+6TeduFivjzcslhUbzJPhNJcF/VMa1xoYKeup0LkmUcVHGe4oATcfWKO9hQjPcfpOzi8qWvN5JVlsU3QwWBalOq7tBgKHP/0tp8dMqgcpLM7HgnLPAGrmav7zQJcFgFkvnIu8l77QzADTMuyE0GPfeddUEMO+3V2vAGXiw0bfpDjHyqNHWxA1bYw3VloIZKZnQL6qKr6t6mu0rSILdTUUXz+eC1BCUtijEcztkYvXmphELvbfcfIbgC+XgRYbhCAXaRDYeUrMSFRsi0FD1ETKBS3458mx7AYQaC5bD4z3aZKQ/gS/1eIP87q35T6jDrrbbES4GWKXDyS1/DHENkg4WppLclOEeX4XiCdq1eoGusSVaRSEJnp9QMo6erHuRiuFFliillYAHzwECH6zqRKPuiLQf64q4Oahq2jeNv1jBohM4//4utJWeUjCznIub3X9wtHqVIMkditWK/LwP+YmW4h7TRBWaKcfW9TXayct3aIaglrW1WJj6Ctz2QIbGljGTxVpxA6L2bC8suk6LwSMHwEk5UQmYqVj74lgxZ5LOVI1iJFmwHjP3vSALUnxADj2fbkoyMjZNbS3d/EVqLW8fMd/rXe5/sedMhfVPc1XpZL+i+bf731RyHeL+V4ol/ZurUmITaFdvVGeWpHNCiKpx1FOBMr94ceYGmvHkrRvekwoAKPkDekBs2u/+pyWq+gtXCEw+2367d5g8T0glmBqNwLn/JEzpTqWYkk0C+GfZLfEHt95HwktGuXwuzoMImh4HaFMzGUyK8aw3QCDLRzG2MRWx7kZvWWNJrHHQCuol7gkmrsQG+QXyFaHHl3lhFBub3pMyKWJAUbIz5IwM89qecwdJVNrKOch4U/ZsEMoHXwjXwgixx++k4TgwoQgjcccXiIzEWr33Np1ZMMI1FKqJxo4/U4w 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)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:30:57.8889 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 19e78c13-6e81-49f0-4535-08dd1751e05f 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6583 If writing the MSR MSR_AMD_CPPC_REQ fails then the cached value in the amd_cpudata structure should not be updated. Reviewed-by: Gautham R. Shenoy Signed-off-by: Mario Limonciello --- drivers/cpufreq/amd-pstate.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 0ed04316a8d80..263acce2f4b0c 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -278,11 +278,15 @@ static int msr_set_epp(struct amd_cpudata *cpudata, u32 epp) value &= ~AMD_CPPC_EPP_PERF_MASK; value |= FIELD_PREP(AMD_CPPC_EPP_PERF_MASK, epp); - WRITE_ONCE(cpudata->cppc_req_cached, value); ret = wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, value); - if (!ret) - cpudata->epp_cached = epp; + if (ret) { + pr_err("failed to set energy perf value (%d)\n", ret); + return ret; + } + + cpudata->epp_cached = epp; + WRITE_ONCE(cpudata->cppc_req_cached, value); return ret; } From patchwork Sun Dec 8 06:30:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848403 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2074.outbound.protection.outlook.com [40.107.101.74]) (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 75481145B16; Sun, 8 Dec 2024 06:31:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639465; cv=fail; b=Om20VB79nVUxGxoi59HoK/cOxTK9kaYqUz95J+0t0YL7FrRj/NSl1BtmlvIcWI/aBtHMH23zGKCklsO9AR8I97fxkrDnOam+DdY9SHF24n6vL7lHZMqqyQerrEJoVTYn3XFZFbm46LzDiNIKDZCxA9pxDgRySEoO/iVlVP13PvU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639465; c=relaxed/simple; bh=e/nZKuKpmaNRiIN279sc670kJiapvYTx0Nn8QYHyYVw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OssDIUepAYQ46QX8N5iekFG39mWRKkj9UOrncQ9R9ZtMDMC7/SoAqeTq80oH0pwkySbRrqzVa0SzFZJpk1rmYjUswu0M6ZOSIplhLjBRLfRmbQl+47fgVKndbEPSfavIGMKPyq8w451mu6Bdx30e3LHxnF6ccLpeLzm+4DHZDik= 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=bZlsY4ET; arc=fail smtp.client-ip=40.107.101.74 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="bZlsY4ET" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=P1eRlaJsXU3iILpSCCKul/L7PEy1oCgicIyKbdQvZRvDRzrh1cy2wf5dTMqGlIgVR8ORfLEogyXUl52Ha/IU3lRZWvLnNxGcfMPcgyBdv8AAFvXThLj7Cv2mPXvaURq23Pd8huzlsQPlsN+ZshUav01P4tE0FsOvAM0FyCAjU3YvkYCLBmQ9poA44beV9x3YGMnLp/LmMsGaF0PR48WUIXqxR/4+G9kXXwutxncT4liHAZ/CjeCw/bPHJcUlUsefOptAgBqgnbic2E7u9JfUhbCA6rLTvozwJQicQxHHHADfih8+SqKVuKqgCKxL3pELeqnXajWPxDruKhIab9b/DA== 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=tdiBQkzENdfUo/VGDk/Uh8zIgQac56a333fBQCDwRRs=; b=uni5sUS97yxWBs9rrZppj1n1T58CRyzwJfxk8tC1iRIiLgHg+S0+UJHRCh/LLJppLC7dKdFfXqWVcA46qd+GA7ehpbmLO7eiGa2glYk+OnAJb2aMStoJye/tMnB7DODNPEK59z4kTgKOJ4JYzM24Q7CTfYyMHALJfsIuZgvxSYkQCQtwEKCC9/n6P/uDqIjhBa9DlayLINSIZNRZnKvnopRFvHILwhDN5Qh8bbh83mzsMh8ZXABD4PPs4Y8hgboAcp74jBpQ1F2QdxsdFPRZoSvyxUWxaWKza74mZ+B/nH8o7rA8NdKjMahRMhwmvNxGMxcnj5CuvZql/PUbJGkXNA== 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=tdiBQkzENdfUo/VGDk/Uh8zIgQac56a333fBQCDwRRs=; b=bZlsY4ET0XBwAx3FVXw+bKylMJis8PLRLHe6XAh9UVYnnXl6W1its2B9izxkadrGO9KB03Zgt7MzGjTQT5Q213uXnMiTEegGrJdJ3D7IyUbJpMBecNgLnU7JvabAsF+VyfmYtchNGZhhh2TPhcT8SWyoJuwaaiul9j5tYoKnyi8= Received: from DS7P220CA0011.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::16) by PH7PR12MB7356.namprd12.prod.outlook.com (2603:10b6:510:20f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.23; Sun, 8 Dec 2024 06:30:59 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::12) by DS7P220CA0011.outlook.office365.com (2603:10b6:8:1ca::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.14 via Frontend Transport; Sun, 8 Dec 2024 06:30:58 +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 CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:30:58 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:30:55 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello Subject: [PATCH v2 08/16] cpufreq/amd-pstate: store all values in cpudata struct in khz Date: Sun, 8 Dec 2024 00:30:23 -0600 Message-ID: <20241208063031.3113-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|PH7PR12MB7356:EE_ X-MS-Office365-Filtering-Correlation-Id: 99f56ade-561c-45dc-b616-08dd1751e0d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: lwAgSYhD5cH1KqCOCZtUW6QnbcnFxMYmHHEMKr+E0i2ISt0xAvHELG2FYq95fSEK7CVx3SZg1llYGq7cHrPXV5VV5NzOtE1Q1U48k+83G/nbvQKpQlCPVt1egKIsTVzARqdtgGbOIb9YNG/mXGLkbus4JRycPw65KXx1uE5n+z/IGl9LE16S+QRax9UBeuBwo0fs1XIDhiYtmd3cob10m7T9iQVz40glMjLi5OH7N0Pix0GCVdJ3S6eDQkacqQo7gTERZf3DBiQopVzDYwYFiqUaCEOVcZS42Iy+0S4zOZXuyh9q2h0IY0jHwlwOoJAea59ZFeNYYv9j8TBfuQ8TXamGqFaKBTO5qzB51JeY8DcHcIL02RPUHAJZ1NAvtvC4yuJQo6EguHmKP56xUkarIft+9jz9Y4Ioh/r3UmGqhS2ARLW2Ani71zpeHVlMoS7P2JEMiA9BXuTu/T6WGuAZsonRgAv49ct+FuHSWdxbIMdzsKrhekaOCOK0cr9eNhvBO69sgVXUalGGqK34kQWSpWGjP1a4CbJrvrfrw5ljbH6ZN0ZrQKPQmdRvp8Bq7H9tUd9cM9u8a/KnYZ44FiqzMFkNgScMOuRIFw1VWg+5OR2iTo9AWciaypYz9gcwPIFeYUtMFUcHCeTxFxwGZHU9XvRQQ1GLbziwmOEjPnbxIArHya6NVpju1dZ94PvpeMePJLHmFB0+p3yIZt1hQKTvxMmqrfUJcb/GqKn42VR6FjlJ4V8o54DXbUPmaVKzumn3QlbvK/Y4L3N4k1YPuppvaGPE91VQYjY1XFPynbgHaIP5ErmbokWOGZQULeS7yt8HvOP90zpTPDeYUAkP5sBB8ZYbT41YtuxyLwokTkMWjEHyponp4CpFBO5Hrd3kSzIxsZCMDbNQv2+x0t8Q2P6OHY3M1GQD0HPPFsARHFCLcnN4paM4dcKwVOaMNMnWI9771vYSPriU4Y+sFPFMo/V5DmVqEpAQmTdhD8rkhc/kPXG6Cbl8atQWm1B97eam//B/7a6Dxk6WzB0pqd6B3CXkhoRE56OWNLMf0boAbimBhD+6h/Zw9TAjeyxpBwBf34Ldhzrm5p11+sJMhGeLu9BV4aWTuGqnzPmMZNEKEpjdd9Z4nGMz0AM0rxbi1eBJxxdjXyeRJLD+7oDKTfQ577xq6e2vlH01va3fbEDqRKtecfzDgyr7G3neXrxSMvnXteQqUYEjCKfhjl4xNEIon3ipl3bv8sToKp388xsSXOtXfX4E2bbvmtOtirP1jqKszdmyuvkXINWXiS73FqRf1qryD0B+BVr71axPJVp1D5OIDVgsz4ImW1oq+0q92fdzjP3hU7IAzUJXLPXiz1yfl9LqKGjVDFBTWF2d3iJoQW0ltPkjoE4PUbkuUE6ck/1DxB88SxW8MId1iP0qe6csS1A+XWUT/418YQeA9B5EOHuIt3HpBjm8qLJ9PTIOS2JkWTMw 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)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:30:58.6389 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 99f56ade-561c-45dc-b616-08dd1751e0d1 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7356 Storing values in the cpudata structure in different units leads to confusion and hardcoded conversions elsewhere. After ratios are calculated store everything in khz for any future use. Adjust all relevant consumers for this change as well. Suggested-by: Dhananjay Ugwekar Reviewed-by: Gautham R. Shenoy Signed-off-by: Mario Limonciello --- v2: * Adjust checks to use nominal_freq for consistency --- drivers/cpufreq/amd-pstate-ut.c | 12 +++++------- drivers/cpufreq/amd-pstate.c | 28 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/cpufreq/amd-pstate-ut.c b/drivers/cpufreq/amd-pstate-ut.c index a261d7300951e..3a0a380c3590c 100644 --- a/drivers/cpufreq/amd-pstate-ut.c +++ b/drivers/cpufreq/amd-pstate-ut.c @@ -207,7 +207,6 @@ static void amd_pstate_ut_check_freq(u32 index) int cpu = 0; struct cpufreq_policy *policy = NULL; struct amd_cpudata *cpudata = NULL; - u32 nominal_freq_khz; for_each_possible_cpu(cpu) { policy = cpufreq_cpu_get(cpu); @@ -215,14 +214,13 @@ static void amd_pstate_ut_check_freq(u32 index) break; cpudata = policy->driver_data; - nominal_freq_khz = cpudata->nominal_freq*1000; - if (!((cpudata->max_freq >= nominal_freq_khz) && - (nominal_freq_khz > cpudata->lowest_nonlinear_freq) && + if (!((cpudata->max_freq >= cpudata->nominal_freq) && + (cpudata->nominal_freq > cpudata->lowest_nonlinear_freq) && (cpudata->lowest_nonlinear_freq > cpudata->min_freq) && (cpudata->min_freq > 0))) { amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; pr_err("%s cpu%d max=%d >= nominal=%d > lowest_nonlinear=%d > min=%d > 0, the formula is incorrect!\n", - __func__, cpu, cpudata->max_freq, nominal_freq_khz, + __func__, cpu, cpudata->max_freq, cpudata->nominal_freq, cpudata->lowest_nonlinear_freq, cpudata->min_freq); goto skip_test; } @@ -236,13 +234,13 @@ static void amd_pstate_ut_check_freq(u32 index) if (cpudata->boost_supported) { if ((policy->max == cpudata->max_freq) || - (policy->max == nominal_freq_khz)) + (policy->max == cpudata->nominal_freq)) amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS; else { amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; pr_err("%s cpu%d policy_max=%d should be equal cpu_max=%d or cpu_nominal=%d !\n", __func__, cpu, policy->max, cpudata->max_freq, - nominal_freq_khz); + cpudata->nominal_freq); goto skip_test; } } else { diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 263acce2f4b0c..8a173359c2754 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -739,8 +739,8 @@ static int amd_pstate_cpu_boost_update(struct cpufreq_policy *policy, bool on) if (on) policy->cpuinfo.max_freq = max_freq; - else if (policy->cpuinfo.max_freq > nominal_freq * 1000) - policy->cpuinfo.max_freq = nominal_freq * 1000; + else if (policy->cpuinfo.max_freq > nominal_freq) + policy->cpuinfo.max_freq = nominal_freq; policy->max = policy->cpuinfo.max_freq; @@ -940,29 +940,29 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata) return ret; if (quirks && quirks->lowest_freq) - min_freq = quirks->lowest_freq * 1000; + min_freq = quirks->lowest_freq; else - min_freq = cppc_perf.lowest_freq * 1000; + min_freq = cppc_perf.lowest_freq; if (quirks && quirks->nominal_freq) - nominal_freq = quirks->nominal_freq ; + nominal_freq = quirks->nominal_freq; else nominal_freq = cppc_perf.nominal_freq; nominal_perf = READ_ONCE(cpudata->nominal_perf); boost_ratio = div_u64(cpudata->highest_perf << SCHED_CAPACITY_SHIFT, nominal_perf); - max_freq = (nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT) * 1000; + max_freq = (nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT); lowest_nonlinear_perf = READ_ONCE(cpudata->lowest_nonlinear_perf); lowest_nonlinear_ratio = div_u64(lowest_nonlinear_perf << SCHED_CAPACITY_SHIFT, nominal_perf); - lowest_nonlinear_freq = (nominal_freq * lowest_nonlinear_ratio >> SCHED_CAPACITY_SHIFT) * 1000; + lowest_nonlinear_freq = (nominal_freq * lowest_nonlinear_ratio >> SCHED_CAPACITY_SHIFT); - WRITE_ONCE(cpudata->min_freq, min_freq); - WRITE_ONCE(cpudata->lowest_nonlinear_freq, lowest_nonlinear_freq); - WRITE_ONCE(cpudata->nominal_freq, nominal_freq); - WRITE_ONCE(cpudata->max_freq, max_freq); + WRITE_ONCE(cpudata->min_freq, min_freq * 1000); + WRITE_ONCE(cpudata->lowest_nonlinear_freq, lowest_nonlinear_freq * 1000); + WRITE_ONCE(cpudata->nominal_freq, nominal_freq * 1000); + WRITE_ONCE(cpudata->max_freq, max_freq * 1000); /** * Below values need to be initialized correctly, otherwise driver will fail to load @@ -972,13 +972,13 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata) */ if (min_freq <= 0 || max_freq <= 0 || nominal_freq <= 0 || min_freq > max_freq) { pr_err("min_freq(%d) or max_freq(%d) or nominal_freq(%d) value is incorrect\n", - min_freq, max_freq, nominal_freq * 1000); + min_freq, max_freq, nominal_freq); return -EINVAL; } - if (lowest_nonlinear_freq <= min_freq || lowest_nonlinear_freq > nominal_freq * 1000) { + if (lowest_nonlinear_freq <= min_freq || lowest_nonlinear_freq > nominal_freq) { pr_err("lowest_nonlinear_freq(%d) value is out of range [min_freq(%d), nominal_freq(%d)]\n", - lowest_nonlinear_freq, min_freq, nominal_freq * 1000); + lowest_nonlinear_freq, min_freq, nominal_freq); return -EINVAL; } From patchwork Sun Dec 8 06:30:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848402 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2055.outbound.protection.outlook.com [40.107.94.55]) (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 CE40F3C463; Sun, 8 Dec 2024 06:31:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639465; cv=fail; b=eR33LCS+dW7xqbmTk/xfeAub+ttuYjZ3rjr6qogl4qkFAbnaHczbYvVoSsGKjyZ5hUgmeeFlieVl4NKl8y50yrF73PxgcdH8CyV8tDokYiSIfIjmLjPSDuL7DtwIqmEk2Zuqu1VhJswwuptHvaCe7wxEDpy7jfWoc6xXHsB+NAE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639465; c=relaxed/simple; bh=cMivOQWZogQBB05LU5VTBgcnzLFViRdZ6a1taO7j+7w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kz1BgRC+9QHNCKtq9bUkKz1+U5VOJnGuKRRu3Bhc15fbeNEdkowcEOm6v8CA51bvpF0trRBdAiWuFjXbxZ6m8R2g/g88AbXbC+0Gz0bGmoYZCY1YED8uKNCslwieHQ+IC5DkXmQdBCr1Hst//nQ2OILY5vjubst4tl8Pc+cK1gA= 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=jvgv5nay; arc=fail smtp.client-ip=40.107.94.55 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="jvgv5nay" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IWFMa9xPRs3ZojqVdz+WnzSuAZNBPjGB8mpNk/2AljIMKrq5M7Tb8zAA9r3KMPrqv1ArY07B5YJISx2Ydv/GDvoe51FqddWJqST1PnBNIzeuxJqnop+SOk/ofVQHRyzH3Ku57tPz0E3j2OrDeeN9xxr4f6rAnv0Ymq4N1Kx+L5aShlk9W9C0k2iRjXJInjK68k+Bg+WAwq+rR0L55xLXj1d+oMbpk4xlFaNdP8OtHBESjgjJ1hbcGCUc/iMOo30OsqQGUTpynq3Ad4tVsR+ZM5DgBQd6QBiwhO5ir2ueuQvzlMu/KTz18eMVr0B7N85Nz9wBWoioGGYsSlIlO/qi5Q== 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=jCd4s0IPHxRfilvupvmiDEaJQouGx2yoyCLixWtybzk=; b=LspVZUzlo6z3kKm88PozK+AGVrHrlLTeKlEyi6uP+Tp4e+HuVzvY4xdyhf7+bRQcmg/wHG7oncoT5Y/i36fdhiiM/fSRk+pt9qOQ5UzhzZP/CRyCvVp5hnnmXp1klyxV2lPcIOoc84BpMoM2p9z/ztidtYit9nfghkVx1osg8TCe/cR4JyigfsJmCaRsWdcyxQ9OHsBOz8hO9SgSAKQMOjuPaqTUu1tJ19HDpbhVQieD3b5v+Osx1FE8d6d3U6t6TmmlUGLqnS8giVEF+pJFHoiHwBM4JiZEC9jruIn/7EeFEacqMnDF0t1PbVasnigNTCD7CJRBXObkVNpUtTyihA== 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=jCd4s0IPHxRfilvupvmiDEaJQouGx2yoyCLixWtybzk=; b=jvgv5nayNvxV4oFzqMoJzx5KX1+2Xn71XgxNFQyqwL9uQG6vCeoA84lZulAeQ/dyAOBf+Xx01gcKsmALSqR+4lGvqgkoMcVFwP3QyuptpodfGyvSJyquW4VueV8JtEBcG+05bf2J2PRkNe578J8Apxlm+rDI84dUHBagyus3Q+8= Received: from DS7P220CA0002.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::12) by CYYPR12MB8961.namprd12.prod.outlook.com (2603:10b6:930:bf::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.12; Sun, 8 Dec 2024 06:31:00 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::c9) by DS7P220CA0002.outlook.office365.com (2603:10b6:8:1ca::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.14 via Frontend Transport; Sun, 8 Dec 2024 06:30:59 +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 CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:30:59 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:30:56 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello Subject: [PATCH v2 09/16] cpufreq/amd-pstate: Change amd_pstate_update_perf() to return an int Date: Sun, 8 Dec 2024 00:30:24 -0600 Message-ID: <20241208063031.3113-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|CYYPR12MB8961:EE_ X-MS-Office365-Filtering-Correlation-Id: 84af7816-0a79-4030-d606-08dd1751e173 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: dK3br9Z11K7Ow1HCXvhG1lTSby3rSwhKdf1TAvz7PMMFcDjREINjAKgRPbivU5P7DblTbMo77f1tCGT70vOjTj17SlRuQlfS6QaXrQXml0xYYZnPncwVZnlFpnzQAncOYg9cViLTxC6dU5NH7evehLvHQ3lNwCpibpU2r5zbVsUnpW8eJslD3+6LUb+njUK9SySGWceQwyOnH6BjwmBzi9a+HNwHZVK3X+W4Mi9R+20WVAW19uECPWJVhciNYciVMAlszdBr7ngWWFGIkoUGZ1MgcDQikh22TSeZeCTBfbmZ/kR2CZ2r8amscFue6/0V2rEAXvQMpX0H9vxa8XCa38SD/4CZuCZgf9gUiya137b6GVBT2C1wL0QLXs11s/u9Y3l1W/hucXf4E8qAO8AQgnVzdcqeCPRHxfDDL1bPaIVPy0sPhIwZ368o1CSlBxglFvCKNr459PqS7AX6BtBJR+jsy2ALkTdgmQShMW8eczLUsMyn45m/aAHrlPzYVABmkhvC8rOZL+2y5TG19XO+o5fRkHjed5EuzQfaW8uSq6hvYhFNnR4nLflLrzexpxFnG+KRcontVmI0KDnih6xYugFeLDGogAr7drkGLp6zHct9LwwL+ry/mjdJ6JH/TpBm9zKY5Tm1kyVczOWVPIa/kGVrkE0p2XqqeLle7CF4wNUZW3KlXTodjA4bjYvOsxp0SAbcSSIDBdII5WMuUA7CCKI+MhaEJI715gcZd5ly4K89ByrLFfpo7JBnUBDomqy0ZKvPSuZviO68I3lPl4SkOdG3sZouarT/SMA06Bnw80hFKXzEM9WYAJJdRBf9gV1FL0AOn0NddnUw3UmeKJ5CcUoIiL5ThzM53JYdjeX9abl9gXrhJwBFurmlCkxub5Hw79k5tODcdam5iuGQK//e0pPIX/WUA5oFP30JmgrJexi/EDWciqOKb3ZPQ4IU5j7h4CpY//bnWlvLDcZxueBRKOn4lvjBzY5PIM4854i0NZA6Lru0KEMCLVQDeeSjh7nIf/5H6o8aLR150oiBC7urHmQYRfyRfxevOIZAbCEY0PgkmFu0WRpR8LzqbUJGydNYgJ5P8hQ+d/ekwSvTO4kOCpRwzVQCUAETZFQsRKn2oNJkXNhOtk8F+rmjR5CTNz/qxmXzxx5a8phTNio7ozz8nYxSYprc93I33aQHDPlOvfgi35kxETjTKnhByitJbv18kcBZ0jQkfQt1p4Sr8Yf8JMgTamO0VmkJnQ/dLfwAhQGQK1HcKttD9ZdObCc0jfl/ahgam/04csSSx5salf7gMxzUgZftJlNLCUnIpZCf1lsm1briJ4ibaxJkil4/PJtOuygpipoJ6qoUj+YfzTfq/Z1yb9GWmblwtYbnUs+dMmtZadYs2VB1WaN1h5p5mPBfnLtgV5ayeegmv3kQRwsxTqludIZvt4H6OtvEoappr+aYU2S6OYZB/CCSU5NXxdgH 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)(36860700013)(376014)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:30:59.7014 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 84af7816-0a79-4030-d606-08dd1751e173 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8961 As msr_update_perf() calls an MSR it's possible that it fails. Pass this return code up to the caller. Reviewed-by: Gautham R. Shenoy Signed-off-by: Mario Limonciello --- drivers/cpufreq/amd-pstate.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 8a173359c2754..3a3df67c096d5 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -251,24 +251,26 @@ static int amd_pstate_get_energy_pref_index(struct amd_cpudata *cpudata) return index; } -static void msr_update_perf(struct amd_cpudata *cpudata, u32 min_perf, +static int msr_update_perf(struct amd_cpudata *cpudata, u32 min_perf, u32 des_perf, u32 max_perf, bool fast_switch) { - if (fast_switch) + if (fast_switch) { wrmsrl(MSR_AMD_CPPC_REQ, READ_ONCE(cpudata->cppc_req_cached)); - else - wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, - READ_ONCE(cpudata->cppc_req_cached)); + return 0; + } + + return wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, + READ_ONCE(cpudata->cppc_req_cached)); } DEFINE_STATIC_CALL(amd_pstate_update_perf, msr_update_perf); -static inline void amd_pstate_update_perf(struct amd_cpudata *cpudata, +static inline int amd_pstate_update_perf(struct amd_cpudata *cpudata, u32 min_perf, u32 des_perf, u32 max_perf, bool fast_switch) { - static_call(amd_pstate_update_perf)(cpudata, min_perf, des_perf, - max_perf, fast_switch); + return static_call(amd_pstate_update_perf)(cpudata, min_perf, des_perf, + max_perf, fast_switch); } static int msr_set_epp(struct amd_cpudata *cpudata, u32 epp) @@ -480,7 +482,7 @@ static inline int amd_pstate_init_perf(struct amd_cpudata *cpudata) return static_call(amd_pstate_init_perf)(cpudata); } -static void shmem_update_perf(struct amd_cpudata *cpudata, +static int shmem_update_perf(struct amd_cpudata *cpudata, u32 min_perf, u32 des_perf, u32 max_perf, bool fast_switch) { @@ -490,7 +492,7 @@ static void shmem_update_perf(struct amd_cpudata *cpudata, perf_ctrls.min_perf = min_perf; perf_ctrls.desired_perf = des_perf; - cppc_set_perf(cpudata->cpu, &perf_ctrls); + return cppc_set_perf(cpudata->cpu, &perf_ctrls); } static inline bool amd_pstate_sample(struct amd_cpudata *cpudata) From patchwork Sun Dec 8 06:30:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848642 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2066.outbound.protection.outlook.com [40.107.223.66]) (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 DA76D149E17; Sun, 8 Dec 2024 06:31:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639467; cv=fail; b=R+9axDqmkawJ8/fcdEeN3WtSMM7/6k8+WK6R19Vfq0qUbXhexoD/pvrRUPrVg6LGmOBcvre+jx3hk9yBLAS/Cn02CPKA2q5zPRnB8Ohqg4w597K0RIKv+IVsmic8JietqIdbLJ+APr3M3mjxrQLo/GUjH44Pj+A4r8h+Vg6FBjo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639467; c=relaxed/simple; bh=AwZXjv+db6RTp0lU5VLcJiWHv2AG9kP+T4CZKHiGgRM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Gwc2sHAYeJYDB9EQP1bfyqnYloM3t7lk4RrveBLnrF0AEeC7vBH6BayM6Dpn4QIrOF+hjcuBhI4Fk/htcRt1M6h9wj53iBBZ2iMkW/BCDW1qiclNXoAMRbcTLt/fZo7GnJgslTc+ZmDsiEy3i2zMUeNuBZA3rXAAQlOw2Fs9eFE= 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=XlZxw2Fl; arc=fail smtp.client-ip=40.107.223.66 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="XlZxw2Fl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ABOjDn6mbgEvoI1+QYT/YqPgUVZxgSekQb95BQSroWVKvoFjxBIAQkDj8jGunaukV6zLzuQiaFlDEDFDXGv0wGY1/rDh8sHMvTWR7gCzPMqbi5lSAwnHRqqjMx8g4v6M01Flrz8esBwsngioNqdPcRKt7jI62rtlO7qx836iMtkaiaV/0d/OekUQvflN0oHDYvlmHP4ZKg1n8xlbADW53CBRSIT141Yj3KLmFG218HWMl1xfP2FWq3HkfrJIm+9J1f2wT0L3aQcmO0pZ7JKLMfotLvgHuCK9XYtX27UxXVkas3bH9zVRZRqtv6toP+Cprph9xlTeHfUPEX2Nwmw+Vw== 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=N1Rs8gVhH+rT2+4S+fdyTLEdm4k86DuUXXfVda7IC34=; b=ctGXlld82pscQaPqwHU3kvUInBPu31migLYRwrvXWqcUIleURZmksoWpgU07Y8nBiXk4cKL5OGbzZZAUgmvQHGlYmmwSF0MtfsaRi/5HJ/1Ue+IrzdypDuC346PnSJo4eKY2FDv8bA2OWnabiJlJoTEptV2BzTzXTndZ8bRe8u0HIjdlbhtpec+c0kXNZptr6r9EQERIS4EoT5RiOmBNSJnpInL9IVxMk6LtoTLT79TTNevCfSwNY2xccpf5B13emHRcLTsETZS9gXamoXIiIS3nn5ft8bgWt9NJ2SAmyA86Xm22PL5l9WaHei/liaYJqiTubP34ATT53vdm1xN20w== 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=N1Rs8gVhH+rT2+4S+fdyTLEdm4k86DuUXXfVda7IC34=; b=XlZxw2FlpYW6+U78NM7MO/oe8vvvdTZCiruQn2nMnARU+fAuZX6oxQE32eWU8SKtc0nqQueXzApNTFQ3DMXKK43yA2HVmGOohc63z8RvjdWsQgTCaHbMAS3WStcI9GxgCVBwTBio769GLm0yxUHHyKXclg7asWvyOj3IzsLkuUM= Received: from DS7P220CA0002.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::12) by CY8PR12MB7340.namprd12.prod.outlook.com (2603:10b6:930:50::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Sun, 8 Dec 2024 06:31:00 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::c9) by DS7P220CA0002.outlook.office365.com (2603:10b6:8:1ca::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.14 via Frontend Transport; Sun, 8 Dec 2024 06:31:00 +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 CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:31:00 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:30:57 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello Subject: [PATCH v2 10/16] cpufreq/amd-pstate: Move limit updating code Date: Sun, 8 Dec 2024 00:30:25 -0600 Message-ID: <20241208063031.3113-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|CY8PR12MB7340:EE_ X-MS-Office365-Filtering-Correlation-Id: 56f42a17-c6d4-41ef-5b22-08dd1751e1da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|1800799024|376014; X-Microsoft-Antispam-Message-Info: Q01gqTUfCmg4kkC4KZVzm0UpEKOhOKxmZDPj6aKB2QT8BxogqBXcRRcjeycK1uHgEIEtvs6BjfOyU6crY3syu+w8vb7OAv0tLKIaY/+DWIjfN1pblq/bJn0SVefM7jTFTiGu4/poH5/oJdFEbwolMCyMY2qrlnHtG0kXeAX6PT5AUDl7XqWazMkdBZne6vZQgs4vCaHilpgBC+O4GqQyTuoB3djWGCsb2kOr4ESJT2qQu0hIu4cgl1vN1Jj2eJXLI5jUD9j/yFt9BrSpcpTXR7Ch/kM62lsiBuZLv5PBeE1Dv//2MPWB7DF/LM3WPcMn3Z/xtJQGcj4l74gxv0QDX6yRRiUoHuPgzlZ0nBElevrZQe0R1xv2owSpLobLnLo0k+TYss0iL5q9ZEyUv3jnuO01RtHKppm5xWiGCsSnXaOehi+WVHoUi2FuUo0W4WykZjCwU8dkOqd2BOYBXzphhfbScG6OX/jXuFa1v2BNitbIomIcZm//ueaoHeQGAlK1S3rM99RtJsQH6yMNxOiQItBKGrUU6EPU4J4clsTWCduTJ5HyYTqECHvo7cG21iApfdqBHDI0nNTek1OyWJPY1yopAvEYdzZJJcU90Sug9yVAk2d/TveCOlkaW0WbPN4x5UvMpFBir3qjiAkMPen0HQCK4jwa5IYiM9pYV/sPm2MPE8YE1XUHlIFFPTHSWg9UrtOIHCqAKoD0sqv4XiQOu4eRlo3E9wZY3eqffsn0bvk9CjMl/l9WQumcqoJuqu3a3i+2kJ2HCM+nsBN+Ppi94YZ8MOY3Bjws6BKojW9QK9GuDMixOhZeIJpbvya+aXCaZN1iyicDjNw8ASbYI8gMWR2fjwAqLbLHAscnuLWRq+ma+/bkz32CRv9qtwCVYJs6Ewp+6ZUZoA/UkDoyh9N2Gkwwuz203QocFmRoikWzrLiiGgDx5R1gZcjVA6dKeYueGSvu1vBUZsAKj3kav5vWXDAe76nReC88Zx0rvIH2l5W19ANxNstfqYXyjIAtvXw20chDlOsDLYN9XNUTt+iGxPzdeya1zwvRZx+naQZ3bbiW8d+QlHQnpsS9WPJgMnoQg+oOEtMk9MHLam+mHTFkhSuEoMVHdEAnQQZIyL0XGZCEILd+PBnttxX2wAWgFCpA4RKGbxuozr+DIAlCEiJD04/o/+HJxIQ57CL12yKp06v34Tfhj57+ysoZJzd8EKF7LAanlkB0lEDRXWHaSYWjWKcE/SSWiJ5F+pvNXEzsw47otMTNbgTyRZ+YJcFJIcG+v14lL/afwr6CueXpvw46UKLL+5DGjaOnIQy6cjaRuHcY9p75kYO3YD9AFTqpsko5qRmX2DH7tU1nSeyM9flJb1EJq0uDz2lyw8pGbuDIlRn8IKcg2zNa0Sa7zIm5PY51SKEMnHm0QU1Uz5nXHGEYFIiQfjCYp2aofOOU7iyjBG1cMjTqdtEYSXzahxPdtQgE 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)(36860700013)(1800799024)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:31:00.3733 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 56f42a17-c6d4-41ef-5b22-08dd1751e1da 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7340 The limit updating code in amd_pstate_epp_update_limit() should not only apply to EPP updates. Move it to amd_pstate_update_min_max_limit() so other callers can benefit as well. With this move it's not necessary to have clamp_t calls anymore because the verify callback is called when setting limits. Reviewed-by: Gautham R. Shenoy Signed-off-by: Mario Limonciello --- v2: * Drop lowest_perf variable --- drivers/cpufreq/amd-pstate.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 3a3df67c096d5..dc3c45b6f5103 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -537,10 +537,6 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, u32 nominal_perf = READ_ONCE(cpudata->nominal_perf); u64 value = prev; - min_perf = clamp_t(unsigned long, min_perf, cpudata->min_limit_perf, - cpudata->max_limit_perf); - max_perf = clamp_t(unsigned long, max_perf, cpudata->min_limit_perf, - cpudata->max_limit_perf); des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf); max_freq = READ_ONCE(cpudata->max_limit_freq); @@ -607,7 +603,7 @@ static int amd_pstate_verify(struct cpufreq_policy_data *policy_data) static int amd_pstate_update_min_max_limit(struct cpufreq_policy *policy) { - u32 max_limit_perf, min_limit_perf, lowest_perf, max_perf, max_freq; + u32 max_limit_perf, min_limit_perf, max_perf, max_freq; struct amd_cpudata *cpudata = policy->driver_data; max_perf = READ_ONCE(cpudata->highest_perf); @@ -615,12 +611,8 @@ static int amd_pstate_update_min_max_limit(struct cpufreq_policy *policy) max_limit_perf = div_u64(policy->max * max_perf, max_freq); min_limit_perf = div_u64(policy->min * max_perf, max_freq); - lowest_perf = READ_ONCE(cpudata->lowest_perf); - if (min_limit_perf < lowest_perf) - min_limit_perf = lowest_perf; - - if (max_limit_perf < min_limit_perf) - max_limit_perf = min_limit_perf; + if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) + min_limit_perf = min(cpudata->nominal_perf, max_limit_perf); WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf); WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf); @@ -1562,28 +1554,18 @@ static void amd_pstate_epp_cpu_exit(struct cpufreq_policy *policy) static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy) { struct amd_cpudata *cpudata = policy->driver_data; - u32 max_perf, min_perf; u64 value; s16 epp; - max_perf = READ_ONCE(cpudata->highest_perf); - min_perf = READ_ONCE(cpudata->lowest_perf); amd_pstate_update_min_max_limit(policy); - max_perf = clamp_t(unsigned long, max_perf, cpudata->min_limit_perf, - cpudata->max_limit_perf); - min_perf = clamp_t(unsigned long, min_perf, cpudata->min_limit_perf, - cpudata->max_limit_perf); value = READ_ONCE(cpudata->cppc_req_cached); - if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) - min_perf = min(cpudata->nominal_perf, max_perf); - value &= ~(AMD_CPPC_MAX_PERF_MASK | AMD_CPPC_MIN_PERF_MASK | AMD_CPPC_DES_PERF_MASK); - value |= FIELD_PREP(AMD_CPPC_MAX_PERF_MASK, max_perf); + value |= FIELD_PREP(AMD_CPPC_MAX_PERF_MASK, cpudata->max_limit_perf); value |= FIELD_PREP(AMD_CPPC_DES_PERF_MASK, 0); - value |= FIELD_PREP(AMD_CPPC_MIN_PERF_MASK, min_perf); + value |= FIELD_PREP(AMD_CPPC_MIN_PERF_MASK, cpudata->min_limit_perf); /* Get BIOS pre-defined epp value */ epp = amd_pstate_get_epp(cpudata, value); From patchwork Sun Dec 8 06:30:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848641 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2070.outbound.protection.outlook.com [40.107.94.70]) (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 885FC14B965; Sun, 8 Dec 2024 06:31:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639469; cv=fail; b=l83wVlYr+QCraJZE2Bhjjo27p6Xpys5oLEvi15/Gi24DzFpulGjhI2enc5Lm/DwHzwRAwKj4zOzIRvKDRnxQCTSNJ/+dj20Jz3Zkf8STO8Gnoa3wW9ST0EMDwSbLnTKUxLdbcbNksghp8vzKolG3XxktOg98Te/OkiBTsm/Qsyo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639469; c=relaxed/simple; bh=/TVV2dHV8Z7jzSu9v2b0756gAyUbIYlrUEKmtiqAsLU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SbG8W2sEu44GRevmwmeXnbmebngLCCI1RGe3SSwUPkzDUrY4VNYZv/rGcGXPydh2TNVkIU/3eSFFWRw5yO82upGPLtmyi+rKc2Z7LnF7B19GQBbjdC87QeSKD2f0KSps3WGZn/ysOhtpEvQxDqPyuNALHEXJ/DHl9sRMI24TuWo= 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=IuNDv/NB; arc=fail smtp.client-ip=40.107.94.70 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="IuNDv/NB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PfmFKppLoI40WmKV5QkyfyqHs2x6PpjSxTxgJqqXGxCEqkhJ2TmOzx1XhDDWljx6EJ20e5KqpPsCL4N6NRTo8G43YvAN8RVXK4YtLS5/KKaz27RM/+kjrFDaZKmvp37iZm92YmDYlwK7npht25fUumzTiA5Wq/s5mMj0L+2Cgwt4COys+x8hvtgzl/DAAcGqPBWgaK6qS//MxQuo/I/WeYn3hQHgXAicDz/MRlvaX2CTfA+8ITVi5ZTm3ejUXdeiGfJH309r8lYJe6IDjFbWWKHWeDmbK7p4R9bV9/omRzIfO3f+IOge0RT4fcyKuwtcg/3YSU/7KOiB2qaX1oL2Dw== 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=1pESds6HcfdNRNMtn6/Xfc/5VuKjuNDCl91K4Vnf4tk=; b=MhywmJVDKrwe2B4YFMrbvt5e0yi3QL2ibwOmddMAc3GZqr4GYV2z/z/ryloh8NwZ/pfQ7TKz0nrV6q1OOpYxYUiNg5eHgZszmv8vcdcmEiL8nV+RcXT4Yw8W8NHsND3pPjtwC6/cggXnFWGuxB8m+DiMg5wHBwkD5UdayTHp2tIgDjZd3yQEIZ9FTXAyfTcPvuvIiEJ/siHbYLiG68Qcd7D1AFOEs6tapwoq4G6p5PsA7oUeZOBEoUwhDnISEc4OLaIQS1G74BK+vtWbcM/654j3Lt1DWyCWqz2SHPAuWA+zZtmi/qXj0dAQhsaDtca7Bb8Tz7ROAcSDFVaX3Bwkgw== 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=1pESds6HcfdNRNMtn6/Xfc/5VuKjuNDCl91K4Vnf4tk=; b=IuNDv/NBUTHVR1XuDEQeX3cFkPLItFqO2RTUC2niHtVuSnEL5WSNOscwcJiaX72nI2hrQIwZBJ/EHeQolb/X1ts1blvJIWSzrkMkTw30sDklc7u2MyZwn56hJn7sr3mgZkwHEGJXpzihmeA9TuRLdL/3bmxD6JE0jsm103EiGU0= Received: from DS7P220CA0011.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::16) by CY8PR12MB7729.namprd12.prod.outlook.com (2603:10b6:930:84::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Sun, 8 Dec 2024 06:31:01 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::12) by DS7P220CA0011.outlook.office365.com (2603:10b6:8:1ca::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.14 via Frontend Transport; Sun, 8 Dec 2024 06:31: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:31:01 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:30:58 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello Subject: [PATCH v2 11/16] cpufreq/amd-pstate: Cache EPP value and use that everywhere Date: Sun, 8 Dec 2024 00:30:26 -0600 Message-ID: <20241208063031.3113-12-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|CY8PR12MB7729:EE_ X-MS-Office365-Filtering-Correlation-Id: 74137e7e-9a1d-4f37-a51b-08dd1751e245 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: DAHjzW/43oft+Ud3h88wWD45FqJsqRA1bYLL1+VMwUSmRb60UyaRWE2scyoqxQHG6c+nsnK1LNp/H1mV+9eg15jRSh2Nm7MQuMql0IginBQ4gMKV5ZplngnxxAAR2LYi4tl0n4eKDRjBKd4AyiodZ9kKx1yR32/7R/tdtRIekU4rWG/QDcroAIllcD6v2/e3aoxClBz5GmsmI6wYnL4MOeu/5ChUWmx3Vwp0phHRr9Tgd4a5PSBLNLOAdfxwhXI40lh6bw3mRQw+X4I0KwLsTs+GMRalhvsWNKhztbIvCjNxqmasxytfceVv7/7AJr1mo8TpDDdglKlmOum4uXGmYynVjKugWsxxRjydzBNRnV/vK806q/VYgPWEfpp8+2diItCu9aiPI/i4Yv4hI8pLIfI5IBzkFe0mp6Z/Q0+lT37Tte2Un45tuFlhPOzVgTlfoSp08KapufqBDFKFdU9nC1fJ07f+sNsLnTLC/aWgnAbgbGLWVs1RAwuQmpLcUmkTT4y9h0COKt9DDLbIjgbXf2gtdJ7mcDIE0dQ1JNCg8/6dFZqD25P+YE+Xg0o8WwbDXnH5NaatKO2FsUaorR1UzPLP4pQo8KRmFEnFgADvE/4KG2FMgmzibndYHscN3KQsPB3Ag5Pj8VULo11sadinpROItnQzi9wAw2HOKMiXGLoHcj67xS8ZgAJal0a1Z3zd0XSkvlqHQsDcfTtDulpH3woG0BXtK61fFCAp4ThOC17hybM6olRBO8Bo0gDJj1YLbWTv52ZoxcTJcRHgRXEk3wc89NfNsU9vFbbxWOAdHHQjdfwQFd8rP5XwRJIC2Ga1Q1bAap6ROobpoq2B/R7Y7tP36VSOts4pGOC6nHTLsQ8Fs9nuRjJy2/u+/twKGK3KC2ndLZqDOR5RGGfrLu3nwXdsr+WLjvgmJibq9Y3hWuQk1KZ2iXmhXaLWRUxAh7y/mSXuDSP/bjsApN4Ct1ASKOisyctMHehcQzizKAEQ5aCrP0r/v7u6Vu2Y8rqIuXmEcdtWIUcG9EAeZMYFDdZKWYXsSG+9ES/+EROHydbcHnYNSx0TQ10HGa5rFINpB/Ceno/xvOTFLqQuMY9oet1D+GlB0w5bcfYH4Qa0m9KDgjUegIi8CbD+cbv8ReJE09osPBQVNf9qNb6rqBaApeJUP9nwoAVZ/+JQO0mi4cEZMQOzzJpig9zjGQr+UsLp2af6sv7zAxu1IHDxdeHtyNOVGurD5RGW2Mkvf92+BaaLOjey3Y5sXGckN2StzVo5J2rLnFZUIRbE5zXbtY59CaTGYuwu8xzjSxtndbfJvJa85CH9BJvyOq1n19n6rvZueLf0wDfKwlzL9jCN1U30fIq2mrYpqp6iHVXoz/vBVR82czQ0cOlZWq87Q4sr6i/gGqcGE/TAqiHxw6Q69JQAJdwprO59oX1TZc8btUMudXnbZRN0orL7xbiGoLXScxLnYr/P 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)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:31:01.0764 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74137e7e-9a1d-4f37-a51b-08dd1751e245 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7729 Cache the value in cpudata->epp_cached, and use that for all callers. As all callers use cached value merge amd_pstate_get_energy_pref_index() into show_energy_performance_preference(). Check if the EPP value is changed before writing it to MSR or shared memory region. Reviewed-by: Gautham R. Shenoy Signed-off-by: Mario Limonciello --- v2: * Drop extra mutex --- drivers/cpufreq/amd-pstate.c | 105 ++++++++++++++--------------------- 1 file changed, 43 insertions(+), 62 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index dc3c45b6f5103..d21acd961edcd 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -186,29 +186,28 @@ static inline int get_mode_idx_from_str(const char *str, size_t size) static DEFINE_MUTEX(amd_pstate_limits_lock); static DEFINE_MUTEX(amd_pstate_driver_lock); -static s16 msr_get_epp(struct amd_cpudata *cpudata, u64 cppc_req_cached) +static s16 msr_get_epp(struct amd_cpudata *cpudata) { + u64 value; int ret; - if (!cppc_req_cached) { - ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &cppc_req_cached); - if (ret < 0) { - pr_debug("Could not retrieve energy perf value (%d)\n", ret); - return ret; - } + ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value); + if (ret < 0) { + pr_debug("Could not retrieve energy perf value (%d)\n", ret); + return ret; } - return FIELD_GET(AMD_CPPC_EPP_PERF_MASK, cppc_req_cached); + return FIELD_GET(AMD_CPPC_EPP_PERF_MASK, value); } DEFINE_STATIC_CALL(amd_pstate_get_epp, msr_get_epp); -static inline s16 amd_pstate_get_epp(struct amd_cpudata *cpudata, u64 cppc_req_cached) +static inline s16 amd_pstate_get_epp(struct amd_cpudata *cpudata) { - return static_call(amd_pstate_get_epp)(cpudata, cppc_req_cached); + return static_call(amd_pstate_get_epp)(cpudata); } -static s16 shmem_get_epp(struct amd_cpudata *cpudata, u64 dummy) +static s16 shmem_get_epp(struct amd_cpudata *cpudata) { u64 epp; int ret; @@ -222,35 +221,6 @@ static s16 shmem_get_epp(struct amd_cpudata *cpudata, u64 dummy) return (s16)(epp & 0xff); } -static int amd_pstate_get_energy_pref_index(struct amd_cpudata *cpudata) -{ - s16 epp; - int index = -EINVAL; - - epp = amd_pstate_get_epp(cpudata, 0); - if (epp < 0) - return epp; - - switch (epp) { - case AMD_CPPC_EPP_PERFORMANCE: - index = EPP_INDEX_PERFORMANCE; - break; - case AMD_CPPC_EPP_BALANCE_PERFORMANCE: - index = EPP_INDEX_BALANCE_PERFORMANCE; - break; - case AMD_CPPC_EPP_BALANCE_POWERSAVE: - index = EPP_INDEX_BALANCE_POWERSAVE; - break; - case AMD_CPPC_EPP_POWERSAVE: - index = EPP_INDEX_POWERSAVE; - break; - default: - break; - } - - return index; -} - static int msr_update_perf(struct amd_cpudata *cpudata, u32 min_perf, u32 des_perf, u32 max_perf, bool fast_switch) { @@ -275,19 +245,23 @@ static inline int amd_pstate_update_perf(struct amd_cpudata *cpudata, static int msr_set_epp(struct amd_cpudata *cpudata, u32 epp) { - u64 value = READ_ONCE(cpudata->cppc_req_cached); + u64 value, prev; int ret; + value = prev = READ_ONCE(cpudata->cppc_req_cached); value &= ~AMD_CPPC_EPP_PERF_MASK; value |= FIELD_PREP(AMD_CPPC_EPP_PERF_MASK, epp); + if (value == prev) + return 0; + ret = wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, value); if (ret) { pr_err("failed to set energy perf value (%d)\n", ret); return ret; } - cpudata->epp_cached = epp; + WRITE_ONCE(cpudata->epp_cached, epp); WRITE_ONCE(cpudata->cppc_req_cached, value); return ret; @@ -305,13 +279,16 @@ static int shmem_set_epp(struct amd_cpudata *cpudata, u32 epp) int ret; struct cppc_perf_ctrls perf_ctrls; + if (epp == cpudata->epp_cached) + return 0; + perf_ctrls.energy_perf = epp; ret = cppc_set_epp_perf(cpudata->cpu, &perf_ctrls, 1); if (ret) { pr_debug("failed to set energy perf value (%d)\n", ret); return ret; } - cpudata->epp_cached = epp; + WRITE_ONCE(cpudata->epp_cached, epp); return ret; } @@ -1214,9 +1191,22 @@ static ssize_t show_energy_performance_preference( struct amd_cpudata *cpudata = policy->driver_data; int preference; - preference = amd_pstate_get_energy_pref_index(cpudata); - if (preference < 0) - return preference; + switch (cpudata->epp_cached) { + case AMD_CPPC_EPP_PERFORMANCE: + preference = EPP_INDEX_PERFORMANCE; + break; + case AMD_CPPC_EPP_BALANCE_PERFORMANCE: + preference = EPP_INDEX_BALANCE_PERFORMANCE; + break; + case AMD_CPPC_EPP_BALANCE_POWERSAVE: + preference = EPP_INDEX_BALANCE_POWERSAVE; + break; + case AMD_CPPC_EPP_POWERSAVE: + preference = EPP_INDEX_POWERSAVE; + break; + default: + return -EINVAL; + } return sysfs_emit(buf, "%s\n", energy_perf_strings[preference]); } @@ -1501,7 +1491,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) policy->driver_data = cpudata; - cpudata->epp_cached = cpudata->epp_default = amd_pstate_get_epp(cpudata, 0); + cpudata->epp_cached = cpudata->epp_default = amd_pstate_get_epp(cpudata); policy->min = policy->cpuinfo.min_freq; policy->max = policy->cpuinfo.max_freq; @@ -1555,35 +1545,26 @@ static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy) { struct amd_cpudata *cpudata = policy->driver_data; u64 value; - s16 epp; amd_pstate_update_min_max_limit(policy); value = READ_ONCE(cpudata->cppc_req_cached); value &= ~(AMD_CPPC_MAX_PERF_MASK | AMD_CPPC_MIN_PERF_MASK | - AMD_CPPC_DES_PERF_MASK); + AMD_CPPC_DES_PERF_MASK | AMD_CPPC_EPP_PERF_MASK); value |= FIELD_PREP(AMD_CPPC_MAX_PERF_MASK, cpudata->max_limit_perf); value |= FIELD_PREP(AMD_CPPC_DES_PERF_MASK, 0); value |= FIELD_PREP(AMD_CPPC_MIN_PERF_MASK, cpudata->min_limit_perf); - /* Get BIOS pre-defined epp value */ - epp = amd_pstate_get_epp(cpudata, value); - if (epp < 0) { - /** - * This return value can only be negative for shared_memory - * systems where EPP register read/write not supported. - */ - return epp; - } - if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) - epp = 0; + WRITE_ONCE(cpudata->epp_cached, 0); + value |= FIELD_PREP(AMD_CPPC_EPP_PERF_MASK, cpudata->epp_cached); WRITE_ONCE(cpudata->cppc_req_cached, value); if (trace_amd_pstate_epp_perf_enabled()) { - trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf, epp, + trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf, + cpudata->epp_cached, cpudata->min_limit_perf, cpudata->max_limit_perf, policy->boost_enabled); @@ -1592,7 +1573,7 @@ static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy) amd_pstate_update_perf(cpudata, cpudata->min_limit_perf, 0U, cpudata->max_limit_perf, false); - return amd_pstate_set_epp(cpudata, epp); + return amd_pstate_set_epp(cpudata, READ_ONCE(cpudata->epp_cached)); } static int amd_pstate_epp_set_policy(struct cpufreq_policy *policy) From patchwork Sun Dec 8 06:30:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2054.outbound.protection.outlook.com [40.107.220.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 3133414F9ED; Sun, 8 Dec 2024 06:31:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639470; cv=fail; b=Ig81mdWTWILi7VAZSktv0ng6VtdReMlj7M507J9NftEhwaLcDtDzUGdlWwfB2S04+ZY7I0YsyhbmKtY5rrDBuBsRmXaEETHJCZmYIs3PdH4y0YuAvd95bYokMVaqbB+QX2gxG3Qznldi3Mem39O14FoW3ndqbvrYxuIq0FnNPh8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639470; c=relaxed/simple; bh=w1yI5QkgpQrkmWxndiGo71mmwJD5DXNgj8Ik+AytcIk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WdyxUGwaF31v9HmLtypuDxbW+MXouH2tGfaZtXSZzvF0WyAdy7R2n+XdpYXoj2JIdC8+Ayt1KUI8DxIhNG6pDj4s5KWY4aHbqq6MpD7+eq3Icqo6c9yfG3Ue24kCGsjYOdQJeVyeJX1DfS1jrXJxvZNCictCIRk3sHTWZLFAnSU= 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=U7cAFKaQ; arc=fail smtp.client-ip=40.107.220.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="U7cAFKaQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=InybHUWTAmm9K3spMJbBzFTkTkf8Cza8N9DnjONxZORNDax/ez6DCX+qXSzaUKdYoFShFz6WUzaLNH05LEoGGA3WZkZ6D20ay21VCatIPTSF3tu97oAsR4hESmSCk3wgYZ9fxKDdNHtUCmL+p0gd0yHP21L6HRZLj57+OJgfZ+cyC6aTh8hknnjwez8KoXkVAZrK2rpmArrrJTe2D8sChNOIx4/F48bcY9qHQZAWXcBL9+KGnqmKuUU+FDTOtRq1NPyBEofMYeSQnusgP21SycWwHO2YEGWRfxc0HG5vhAHz4Ulo+IGYt6y0Fz2yoQve9axnbFhkvCiljwXkufTSPw== 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=sscEtimuOUJemviRepZcMyYZsAU2LYLD1Lv9VJgc07c=; b=HdWJ2+JE74CRF2IeAdWEgNj36ybRmsHB3QbOILQ/LurjDZDrR7EMuZwMdHk/kWkiVLqXtcLN2luX+ZKlRQZSbnOy9xb+OcGKCPNdCWdMWdKt9G435ro+6+aIprQhUwEmGBK8HaERD0zd0GaET8QnzZlEc5wkUp0cgd+sY+CmWyD63v3PWWENGOqgqS0ohs3CsazphitbgDKnU9ZT0wdWtzaTtVtY4kRe2+/trrzz2faCWDc5Pmv2XFMBvgtc8mOJNBvx694YUMk8exBXkM3Tn4EcoxAu+w475Ci9U8S8cCfftU+VEIWS62S9IqrY0JOfKHIkGrEq1rasRX8qM0acnA== 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=sscEtimuOUJemviRepZcMyYZsAU2LYLD1Lv9VJgc07c=; b=U7cAFKaQbKIeADoFp3MmMXWbc7X2FJUjTUz6WnnsMl4cSc+GLYRcr9Zz4n3JHVPR83EIR3XKGjS7w8Dy96/7jWuiP7ob91PFlq6Lmwd8as0cRrgl3jkjsw8/tzq9Fuz2vxqcZCZuEXZOVjf2TIySnBmubNir/q16IjpIfDBX5A8= Received: from DS7P220CA0007.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::14) by CH3PR12MB8403.namprd12.prod.outlook.com (2603:10b6:610:133::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Sun, 8 Dec 2024 06:31:02 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::a2) by DS7P220CA0007.outlook.office365.com (2603:10b6:8:1ca::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.14 via Frontend Transport; Sun, 8 Dec 2024 06:31: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:31:01 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:30:58 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello , Dhananjay Ugwekar Subject: [PATCH v2 12/16] cpufreq/amd-pstate: Always write EPP value when updating perf Date: Sun, 8 Dec 2024 00:30:27 -0600 Message-ID: <20241208063031.3113-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|CH3PR12MB8403:EE_ X-MS-Office365-Filtering-Correlation-Id: d894fe7c-517c-4b5b-030e-08dd1751e2a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: dXSHmkYCAKZazVIuhPAy15cPvF1OQ8k9lpFk+/yc3hZz968v+U0qjC5EeoYQVm53rIFKRJuCglCC+dPP8J1mcwDX/NIJmCl75yBT8amEgLS7+zZ1V6t0i9RTABzGohOGwDI0ZmF5B62PfCuTBSSJ0LD8zXNcjEKs7U6WeNXmWj9RDXY1lTpX6VnU37iTLpS5/1NPiAaTz2xaiIsCKhbN2odnhkAnxTpWAo/SmpgQhDmsZ3g3jxtl+jFII5+CF2YUti6Tc0/n8j3hvY3i9uebqEyabeUMzHY5cVmJ0vTOlOQPLCSiA3+4zguXCSB23ZRoorYgqdo6BurE1xbdiMmY/j8xs7R3ke2Lgleg/xTLLR7b7VPLLyQ33+yiSvPmyTBqUCWL9tfyiLZQcS5R94Y2KZupz6TFc1nb/2Rm87ea+6ekrbdVPAQWMyMBgmNiiEEbH3sJUm8bDwSumLukuOIxCi8sgLfuIQ3XZQNOhM1OU8Cr+DjmLHS1EYZDJ26v4HBOzFni4MUOFhFDrSTwG+lKyg1y/3XKU/09dDvcjE/iju0IAFH627R6T0tkMJJ6qvIMUY0CsHLsQ37wAbOtjuPlbCKvRSZ28LEyWT8WL8llEBu8tnwP5lGagX0skhzQsE2hj23BtA28VWZKbjAqOBhvDrIdT8WnQO7ix5aBAOy8vgz5/RuY1YyZ1DTYjWx2+Qmw2dwvD41hRaGLBklWPtAUnOFM3a0/tV8xw+T2p4JSJ10ZGHbYla/qmRpf7AM35ByL7aOi9BGLIDETmiMwOzdrC7LvR7Wl88XfprmZoKuidSvIa1ruCc0WdTADFE5P4Pd3J8UY2wHkBmMsXRFLOtZoVJQArqimKZK4d6xIEQsoafgzGCT86KFAOZBJEW+8YQ38c/25W61ald17Np+KqCLqn9cQQjnQo3+eKxkMbassiqR5Ov8axQvxFwS3YL5bbbqMRMGef7ECBTPXBjxCcZqe0sZIL/a1PX7mS2yilkPc3gG3d58L6JNVuSBflNZXKNYPmJT3dBI+lOrfPRxK+brtERALGOsXqgoGBU/0sFbhNpGfRAzrclLUXmrhovan2ZOk578ssk0b6+iK/uydvZMdq4PlIBR8uGpBrOsCaO396bJRZeRuYAkMVleZQFuQK4yg2yldfVB2SOaMrO+dBUQzI5QeA9TB9n8iv5C5AJb8nDkfL8aikgJaiS2M44Cp8VNL/KPPumTD6JW0eV+y+Mozmzxv7/txOb5IEHXFMn4JYWgi+HV1/ed4Yv448h5hl/AFvs/0T2IdhQ07MTmf917HV4MQ/BUG61NTGRcPfXfT2UE5dhawaowTdHLmVHa91pxu5t4NMR0wI9Bpncc2rq2f1eyB3FAzMKt1DvU75V1i4Wu8doP4haJYT84jVafpgNaMJ+PvNhM/FIuN+sUmO6dJl6/OrXwxQO/1MP2cP6mmpJ1nslhs4slbPUtJSFtU3+c/ 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)(36860700013)(376014)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:31:01.7170 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d894fe7c-517c-4b5b-030e-08dd1751e2a5 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8403 For MSR systems the EPP value is in the same register as perf targets and so divding them into two separate MSR writes is wasteful. In msr_update_perf(), update both EPP and perf values in one write to MSR_AMD_CPPC_REQ, and cache them if successful. To accomplish this plumb the EPP value into the update_perf call and modify all its callers to check the return value. Reviewed-and-tested-by: Dhananjay Ugwekar Signed-off-by: Mario Limonciello --- drivers/cpufreq/amd-pstate.c | 71 ++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index d21acd961edcd..dd11ba6c00cc3 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -222,25 +222,36 @@ static s16 shmem_get_epp(struct amd_cpudata *cpudata) } static int msr_update_perf(struct amd_cpudata *cpudata, u32 min_perf, - u32 des_perf, u32 max_perf, bool fast_switch) + u32 des_perf, u32 max_perf, u32 epp, bool fast_switch) { + u64 value; + + value = READ_ONCE(cpudata->cppc_req_cached); if (fast_switch) { wrmsrl(MSR_AMD_CPPC_REQ, READ_ONCE(cpudata->cppc_req_cached)); return 0; + } else { + int ret = wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, + READ_ONCE(cpudata->cppc_req_cached)); + if (ret) + return ret; } - return wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, - READ_ONCE(cpudata->cppc_req_cached)); + WRITE_ONCE(cpudata->cppc_req_cached, value); + WRITE_ONCE(cpudata->epp_cached, epp); + + return 0; } DEFINE_STATIC_CALL(amd_pstate_update_perf, msr_update_perf); static inline int amd_pstate_update_perf(struct amd_cpudata *cpudata, u32 min_perf, u32 des_perf, - u32 max_perf, bool fast_switch) + u32 max_perf, u32 epp, + bool fast_switch) { return static_call(amd_pstate_update_perf)(cpudata, min_perf, des_perf, - max_perf, fast_switch); + max_perf, epp, fast_switch); } static int msr_set_epp(struct amd_cpudata *cpudata, u32 epp) @@ -459,12 +470,19 @@ static inline int amd_pstate_init_perf(struct amd_cpudata *cpudata) return static_call(amd_pstate_init_perf)(cpudata); } -static int shmem_update_perf(struct amd_cpudata *cpudata, - u32 min_perf, u32 des_perf, - u32 max_perf, bool fast_switch) +static int shmem_update_perf(struct amd_cpudata *cpudata, u32 min_perf, + u32 des_perf, u32 max_perf, u32 epp, bool fast_switch) { struct cppc_perf_ctrls perf_ctrls; + if (cppc_state == AMD_PSTATE_ACTIVE) { + int ret = shmem_set_epp(cpudata, epp); + + if (ret) + return ret; + WRITE_ONCE(cpudata->epp_cached, epp); + } + perf_ctrls.max_perf = max_perf; perf_ctrls.min_perf = min_perf; perf_ctrls.desired_perf = des_perf; @@ -545,10 +563,10 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, WRITE_ONCE(cpudata->cppc_req_cached, value); - amd_pstate_update_perf(cpudata, min_perf, des_perf, - max_perf, fast_switch); + amd_pstate_update_perf(cpudata, min_perf, des_perf, max_perf, 0, fast_switch); cpufreq_policy_put: + cpufreq_cpu_put(policy); } @@ -1545,6 +1563,7 @@ static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy) { struct amd_cpudata *cpudata = policy->driver_data; u64 value; + u32 epp; amd_pstate_update_min_max_limit(policy); @@ -1557,23 +1576,19 @@ static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy) value |= FIELD_PREP(AMD_CPPC_MIN_PERF_MASK, cpudata->min_limit_perf); if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) - WRITE_ONCE(cpudata->epp_cached, 0); - value |= FIELD_PREP(AMD_CPPC_EPP_PERF_MASK, cpudata->epp_cached); - - WRITE_ONCE(cpudata->cppc_req_cached, value); + epp = 0; + else + epp = READ_ONCE(cpudata->epp_cached); if (trace_amd_pstate_epp_perf_enabled()) { - trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf, - cpudata->epp_cached, + trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf, epp, cpudata->min_limit_perf, cpudata->max_limit_perf, policy->boost_enabled); } - amd_pstate_update_perf(cpudata, cpudata->min_limit_perf, 0U, - cpudata->max_limit_perf, false); - - return amd_pstate_set_epp(cpudata, READ_ONCE(cpudata->epp_cached)); + return amd_pstate_update_perf(cpudata, cpudata->min_limit_perf, 0U, + cpudata->max_limit_perf, epp, false); } static int amd_pstate_epp_set_policy(struct cpufreq_policy *policy) @@ -1602,7 +1617,7 @@ static int amd_pstate_epp_set_policy(struct cpufreq_policy *policy) return 0; } -static void amd_pstate_epp_reenable(struct amd_cpudata *cpudata) +static int amd_pstate_epp_reenable(struct amd_cpudata *cpudata) { u64 max_perf; int ret; @@ -1620,17 +1635,19 @@ static void amd_pstate_epp_reenable(struct amd_cpudata *cpudata) max_perf, cpudata->boost_state); } - amd_pstate_update_perf(cpudata, 0, 0, max_perf, false); - amd_pstate_set_epp(cpudata, cpudata->epp_cached); + return amd_pstate_update_perf(cpudata, 0, 0, max_perf, cpudata->epp_cached, false); } static int amd_pstate_epp_cpu_online(struct cpufreq_policy *policy) { struct amd_cpudata *cpudata = policy->driver_data; + int ret; pr_debug("AMD CPU Core %d going online\n", cpudata->cpu); - amd_pstate_epp_reenable(cpudata); + ret = amd_pstate_epp_reenable(cpudata); + if (ret) + return ret; cpudata->suspended = false; return 0; @@ -1654,10 +1671,8 @@ static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy) min_perf, min_perf, policy->boost_enabled); } - amd_pstate_update_perf(cpudata, min_perf, 0, min_perf, false); - amd_pstate_set_epp(cpudata, AMD_CPPC_EPP_BALANCE_POWERSAVE); - - return 0; + return amd_pstate_update_perf(cpudata, min_perf, 0, min_perf, + AMD_CPPC_EPP_BALANCE_POWERSAVE, false); } static int amd_pstate_epp_suspend(struct cpufreq_policy *policy) From patchwork Sun Dec 8 06:30:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848399 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061.outbound.protection.outlook.com [40.107.237.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 BACD115252D; Sun, 8 Dec 2024 06:31:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639470; cv=fail; b=iuGBgfsEFnb+CZIwt2zUg1fAdByOefvoUgJJCd8Z2iALqE7HHfORPjTk/nAzQb6ptMlkU50Weed6EowN9Ld43dEY9eA2mESRkbOcFLjBG5b33JziFSJ56HsLMhu7h0jHi1abYG35noHVzifcpYzilxXNsXknp4camIJPNBwyymA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639470; c=relaxed/simple; bh=43TL3DHGRjw+j9diIktI+q56Yl9i+laB/64pkuVkpOI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LdsIu6svPDnClyenk5ycnPc5VBjMr2uPhtfWO0Nzdhvru+7KYuXWMglyYB/Vy/w0a5Xy7c/jfVbTVR/NX6IwRouoMC+PNCUNgcj7taBBsqQzCxx5fAZZLZsTEjblrI1I5LDcDwzhSkb4jvAYJLVw38dCAE+eF6/nkdCuX0/3jXc= 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=oo2bqOk/; arc=fail smtp.client-ip=40.107.237.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="oo2bqOk/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QSJ2QjroaGOmP2btEApmAnB5BnwKbso9ZbhfqPfVcB0WSPVsU0Ldh4P+vxs6rsbYCnKyh4dEEL7uocJHliYEYzUHoo+doH/8AAApg8XKtOad688Ui91J2flK457K9vDxVjx9EwLI10t9uQjwstt7HJ+31bHIF8al4RP46TU/StT2+o5t32GJF1pEHEi0O+r/OcQ/w8rmY/NaNXgCOr/FrJCj5S3XJ0OoxvWqGsVyRlsTpRofjyNK1h1VFEP95ho5w700xAzs6Kc45S482w/5H7KW8Y3jlwgC+8an1lRnijHKJ0m8csn6keF3sj6VoEKL0oYY6HOCxQkY+nYBNib5zg== 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=yUC+b8LOZP/8cay9I9MUBpDDVjIaTiTwK0NIxMtU08M=; b=I+XdglXE4CFWQwUSrMVdwJQr/+yVeopas4+Fh1g0nshL3VGEKvWvePFW46dV8rLXT/8GjRUY4ZfsaW3sLOR8ikNzwlYvpguUGfNjinv5W95uPaQo/o4z+jSFo9rh1mt4UeuWIFMnSb8a8FCjlX+ieV0kvIfkyhQbcFValQy4jqbE1jTrV8jQnvRUASwGfvnn7laH5m3eH+s0VcdoKm82MWD213Cf69lmnofGsNhCB67ok3i7huQO3HNQELcIRcWY8TSAabZPIrEXJ3+DFzLAQcf49eFOsWfwTvW17ahVpDR3avnfUYdYHzrp49f/oO/CRcPHXCARzlwqKNvnUP6v7A== 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=yUC+b8LOZP/8cay9I9MUBpDDVjIaTiTwK0NIxMtU08M=; b=oo2bqOk/Mxb6dkVTlbVXhKTG0Xtkcv8UnooQfduOu6zQIYA0OgtlP62B9XKxwbDgVobqs58txVXvpyfjOOza8GGeDXzfqQkNZUuCi2wAnwzSi788OznP7hlpqJW7Q/BN38DHSt7txroKYSkxUNcf8D/3wnEfJv4UnODyxNy9IeQ= Received: from DS7P220CA0006.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::10) by PH0PR12MB8032.namprd12.prod.outlook.com (2603:10b6:510:26f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Sun, 8 Dec 2024 06:31:02 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::3d) by DS7P220CA0006.outlook.office365.com (2603:10b6:8:1ca::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.15 via Frontend Transport; Sun, 8 Dec 2024 06:31:02 +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 CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:31:02 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:30:59 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello , Dhananjay Ugwekar Subject: [PATCH v2 13/16] cpufreq/amd-pstate: Check if CPPC request has changed before writing to the MSR or shared memory Date: Sun, 8 Dec 2024 00:30:28 -0600 Message-ID: <20241208063031.3113-14-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|PH0PR12MB8032:EE_ X-MS-Office365-Filtering-Correlation-Id: 850b5825-0894-485a-1198-08dd1751e315 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: 4dOW86SQi3LS5biDz4Sz1OP1/tF/KgURq/k61CW5jyCjm/2X6NIPue1ZkGXUw6kUCO65xGQwW90+tIElWc8E4pxxYsCi213TeIlxqk8Z8yZOTSaAwpU6Of7jxAkPXx8U4iE5qmfqnat6zGHmDWI83ugsPdW+vKkSGiMsb7EaQdu5OOdlGS8dJJgDQyq4XL0k2UMCIhmQxZXXu4tUSi2J+GmbV+mfrHD+MteC0d0GUkHKLzcRFzluJ4KprORyjygD88/AzLmiru0+fQVTAfHSzZ5/T06KkUqO5q/zdW3PSDaoqDDKBHvBv/YIc0CTAs5wxxoKpnps9RibXu7SVwyx9DNTGfVLyEpEUPLfWhlp/2jN6ADxaj4ideDeRbHiaTuaBfHNHb8TIlXuW5evnfsf1ZgGAMdDJIOi1Yu6HYO3ND6uu99oR3195Zf2fo4vKR7jhRkSQvKSUYzzZ6weIY4/XivtNrTZGrFiCdJsg5V+1uM7XqTqT/reCEOjYcJbbMNk3Cu77JKpYnIM44RR3sk9E7R78X1ZiOqIKA3gLnN74TvtrjuGhkFJcQU7H8PTfGljzVO/WBfGbHZWptRNYKsWth965DKjsjisXWiNM1X4hDgL/R3NR9PveirdKcDkfWCQa1c4OdowwvC08HUf7l5yqoz9veZ1FMoHMKh3uW7uOL3+liN/2AsqMsdoymmdA2PHDOSm/Nn6FB1H+M55tIsiWfKblKRB50comHMP+pSQCneF2tsFszS9GCal2M/oaQG5blYUP2Ra/I9kFqnYFBu/mV/qsnX/ymqdU4KvpPVzuQkCLKNrQoFtg71WJlgawjMV3jBua7FKPsQbGKLc7S9/Z2/zluKrsi5LqeQp8hLSO/L83H5iNYWgzG3GVmCmQa8zP2wtHW/OTjLsndCJIymzHLK2q4W/8XGIgS4T3osCb6NTlJIDanv1a+czckPUWw7zELGZrMQevIgeNz7jtdr+meH7GX8P4G/v5EI+4cW5QO+9mHhpSLw08zJYC0YieL33wPeBRh61Zr7AHcMdrwD5a2ljxcPMMEZRETAQxdyk7LJR8fg7Kv2+VJG16tNrFScY4N0DDwza9IfrbxvWZXuj+zYhicuKKth/0days1U2GqAqBni1FYLYANmOJJVnPv3J/sVqmr+mYxZLHQjN5rqckmsHlicybuxodm5lzlcXWPoiS00Li1gUDdxBLKWKODEMBXjQYxH2iKNQ7eTJAtti9xyBh3m4Ne2v8Q7XOOJ6NC9DiDww3qYnDP+1XDZK7tvQ7Zrg1K5fc/0ncyWdN4hBVEaYY/oOlpIE+cEIw/q9pj0zsFmpKJiijA3jlDPcUfte1aWW8ICE3QcGCE27Yo0VmabHlQBaWT3n/bcVSrZBYNw9UWAVzpzHhDFM0Vwbjo9ZYtGn1mZfDOE2e0Zs18DCiQTZCJGlVjjwsFszPKkm80lxE8shmPTIhreP13GFjibV 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)(82310400026)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:31:02.4358 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 850b5825-0894-485a-1198-08dd1751e315 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8032 Move the common MSR field formatting code to msr_update_perf() from its callers. Ensure that the MSR write is necessary before flushing a write out. Also drop the comparison from the passive flow tracing. Reviewed-and-tested-by: Dhananjay Ugwekar Signed-off-by: Mario Limonciello --- drivers/cpufreq/amd-pstate-trace.h | 7 +---- drivers/cpufreq/amd-pstate.c | 47 +++++++++++------------------- 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/drivers/cpufreq/amd-pstate-trace.h b/drivers/cpufreq/amd-pstate-trace.h index e2221a4b6901c..8d692415d9050 100644 --- a/drivers/cpufreq/amd-pstate-trace.h +++ b/drivers/cpufreq/amd-pstate-trace.h @@ -32,7 +32,6 @@ TRACE_EVENT(amd_pstate_perf, u64 aperf, u64 tsc, unsigned int cpu_id, - bool changed, bool fast_switch ), @@ -44,7 +43,6 @@ TRACE_EVENT(amd_pstate_perf, aperf, tsc, cpu_id, - changed, fast_switch ), @@ -57,7 +55,6 @@ TRACE_EVENT(amd_pstate_perf, __field(unsigned long long, aperf) __field(unsigned long long, tsc) __field(unsigned int, cpu_id) - __field(bool, changed) __field(bool, fast_switch) ), @@ -70,11 +67,10 @@ TRACE_EVENT(amd_pstate_perf, __entry->aperf = aperf; __entry->tsc = tsc; __entry->cpu_id = cpu_id; - __entry->changed = changed; __entry->fast_switch = fast_switch; ), - TP_printk("amd_min_perf=%lu amd_des_perf=%lu amd_max_perf=%lu freq=%llu mperf=%llu aperf=%llu tsc=%llu cpu_id=%u changed=%s fast_switch=%s", + TP_printk("amd_min_perf=%lu amd_des_perf=%lu amd_max_perf=%lu freq=%llu mperf=%llu aperf=%llu tsc=%llu cpu_id=%u fast_switch=%s", (unsigned long)__entry->min_perf, (unsigned long)__entry->target_perf, (unsigned long)__entry->capacity, @@ -83,7 +79,6 @@ TRACE_EVENT(amd_pstate_perf, (unsigned long long)__entry->aperf, (unsigned long long)__entry->tsc, (unsigned int)__entry->cpu_id, - (__entry->changed) ? "true" : "false", (__entry->fast_switch) ? "true" : "false" ) ); diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index dd11ba6c00cc3..2178931fbf87b 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -224,15 +224,26 @@ static s16 shmem_get_epp(struct amd_cpudata *cpudata) static int msr_update_perf(struct amd_cpudata *cpudata, u32 min_perf, u32 des_perf, u32 max_perf, u32 epp, bool fast_switch) { - u64 value; + u64 value, prev; + + value = prev = READ_ONCE(cpudata->cppc_req_cached); + + value &= ~(AMD_CPPC_MAX_PERF_MASK | AMD_CPPC_MIN_PERF_MASK | + AMD_CPPC_DES_PERF_MASK | AMD_CPPC_EPP_PERF_MASK); + value |= FIELD_PREP(AMD_CPPC_MAX_PERF_MASK, max_perf); + value |= FIELD_PREP(AMD_CPPC_DES_PERF_MASK, des_perf); + value |= FIELD_PREP(AMD_CPPC_MIN_PERF_MASK, min_perf); + value |= FIELD_PREP(AMD_CPPC_EPP_PERF_MASK, epp); + + if (value == prev) + return 0; - value = READ_ONCE(cpudata->cppc_req_cached); if (fast_switch) { - wrmsrl(MSR_AMD_CPPC_REQ, READ_ONCE(cpudata->cppc_req_cached)); + wrmsrl(MSR_AMD_CPPC_REQ, value); return 0; } else { - int ret = wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, - READ_ONCE(cpudata->cppc_req_cached)); + int ret = wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, value); + if (ret) return ret; } @@ -528,9 +539,7 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, { unsigned long max_freq; struct cpufreq_policy *policy = cpufreq_cpu_get(cpudata->cpu); - u64 prev = READ_ONCE(cpudata->cppc_req_cached); u32 nominal_perf = READ_ONCE(cpudata->nominal_perf); - u64 value = prev; des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf); @@ -546,27 +555,14 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, if (!cpudata->boost_supported) max_perf = min_t(unsigned long, nominal_perf, max_perf); - value &= ~(AMD_CPPC_MAX_PERF_MASK | AMD_CPPC_MIN_PERF_MASK | - AMD_CPPC_DES_PERF_MASK); - value |= FIELD_PREP(AMD_CPPC_MAX_PERF_MASK, max_perf); - value |= FIELD_PREP(AMD_CPPC_DES_PERF_MASK, des_perf); - value |= FIELD_PREP(AMD_CPPC_MIN_PERF_MASK, min_perf); - if (trace_amd_pstate_perf_enabled() && amd_pstate_sample(cpudata)) { trace_amd_pstate_perf(min_perf, des_perf, max_perf, cpudata->freq, cpudata->cur.mperf, cpudata->cur.aperf, cpudata->cur.tsc, - cpudata->cpu, (value != prev), fast_switch); + cpudata->cpu, fast_switch); } - if (value == prev) - goto cpufreq_policy_put; - - WRITE_ONCE(cpudata->cppc_req_cached, value); - amd_pstate_update_perf(cpudata, min_perf, des_perf, max_perf, 0, fast_switch); -cpufreq_policy_put: - cpufreq_cpu_put(policy); } @@ -1562,19 +1558,10 @@ static void amd_pstate_epp_cpu_exit(struct cpufreq_policy *policy) static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy) { struct amd_cpudata *cpudata = policy->driver_data; - u64 value; u32 epp; amd_pstate_update_min_max_limit(policy); - value = READ_ONCE(cpudata->cppc_req_cached); - - value &= ~(AMD_CPPC_MAX_PERF_MASK | AMD_CPPC_MIN_PERF_MASK | - AMD_CPPC_DES_PERF_MASK | AMD_CPPC_EPP_PERF_MASK); - value |= FIELD_PREP(AMD_CPPC_MAX_PERF_MASK, cpudata->max_limit_perf); - value |= FIELD_PREP(AMD_CPPC_DES_PERF_MASK, 0); - value |= FIELD_PREP(AMD_CPPC_MIN_PERF_MASK, cpudata->min_limit_perf); - if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) epp = 0; else From patchwork Sun Dec 8 06:30:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848401 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2088.outbound.protection.outlook.com [40.107.243.88]) (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 7FC1914D2B9; Sun, 8 Dec 2024 06:31:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639469; cv=fail; b=nI+mOVl2IFpvuOURTOAn7Kt8VBy2ivGdAB87j7GHy+eDgElmOG8QrnGnJGF1g9BtCSQsvi3XSgGzmay3s8dp3Kl8MYe/x0WuN/Y9JQe+0O3DyCRVfzFx7s17kXiRU/r65BeUeIYByN3BTF3dTbhvB2cNBU0/OtHxxrdbVB0ikZw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639469; c=relaxed/simple; bh=vkKo/4s8AJHrxcMAdTwOpCYVCwosLIyVKxM6l/lgozY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PR25jquQUmvF5lccy0yN6+Ho1Y0h/pI9UXs0lrZHbeVsKoyqgOfxV8D1ypUOzYRGHD1LN4zHCv0Xngz8Hqafr8kXLAfLzt2GhXAcmJCrNFCmZDXvEYT/gRdsMXWrnNoiBqtYrhN+FIJCe9XgKAfFjE499YJdVSUTb2HpC2nkGaI= 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=xWTspgu2; arc=fail smtp.client-ip=40.107.243.88 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="xWTspgu2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DPhSwuQivcYt3qfzEuHhKFVtxuJFW5R0w/av2hbmzqMaFOb3rQj0wgLRsUYh0FHopISVmIRjr4BMBYBtXV1WddI8SFs7BMDTtKyp2PyqYpfJcQVE6Sg7jmV+l2qtRLRBfkvCd35zXWdLBEmOpFShA0ootTvtE9X7w5cYAzHudm3+QWDjEnU4hqT0S6sxUSNnJwFUqDuFgFgnyzNvo8Frr9RVImS7puS57GUJtaJAvKZZgb9nPxcIqF9SbbV44WoXWXrMYymnGP+grbWFcaZfzpVVa7ChN8iO4ViAKLDYjWBpQUNIYk+GQExknmMZI4D9haUlAopbiuW6HxK06KAINQ== 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=e5ztNw0rCPyoFK32wG2ZAfAIj5nmgIIkK7w1Wa8CnbU=; b=GXcXr6T7JOoSzZVTPIouOcP+RNCJp6cFw1k2p0B9CjvRPJ48Zl+WZYfUMTStzclGoEyli7i8fXiEZMyJiC68XjeVTD1YrqUwO5PanmxaolQpbU3I9Fj/IHrRisrqCzzNq5T31xr4t3fcVeCijqYEzDBDz6miHMc1Q3sJPk4/WyjmyQi3c0lA4QxdrNsdUtgAa6g1u2KBvBHDa9YE3Qx4nR6emgTyF7G53zvAihrPIOcDgDpUiDlI9TWjrIku6FX+T4uVAhq1Z6jVsnBQtDBK+ZqrN4VADPtN6WOeu9S/i0jskcsJixsMexAeHg9s9vFswHJAI3dUgvLnEx53K4kx9A== 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=e5ztNw0rCPyoFK32wG2ZAfAIj5nmgIIkK7w1Wa8CnbU=; b=xWTspgu2zbmvbwYBS4wr/tEoVS5521B18amZ8LV3oeK7ON+yOo3ZMYHook8kyBHIuGtiKdsegHvpXhZ76brtNubGsGukv1dAzxKiHmYn4qNUR5y1VAO3bCYnNhP0/yAcWyoANeczp/I3uVJBHbkeWdnXpoUlKsp54HhMJ69qog4= Received: from DS7P220CA0011.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::16) by MW4PR12MB6850.namprd12.prod.outlook.com (2603:10b6:303:1ed::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Sun, 8 Dec 2024 06:31:03 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::fd) by DS7P220CA0011.outlook.office365.com (2603:10b6:8:1ca::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.14 via Frontend Transport; Sun, 8 Dec 2024 06:31:03 +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 CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:31:03 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:31:00 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello , Dhananjay Ugwekar Subject: [PATCH v2 14/16] cpufreq/amd-pstate: Drop ret variable from amd_pstate_set_energy_pref_index() Date: Sun, 8 Dec 2024 00:30:29 -0600 Message-ID: <20241208063031.3113-15-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|MW4PR12MB6850:EE_ X-MS-Office365-Filtering-Correlation-Id: d18da0c1-d7fe-41e3-e4bc-08dd1751e389 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: SbReTEwngUE2gfH7v65sAU5Q+HxAxXpokHnALj+LWV+dAHZbvPiyrujTWu91kwEI7kW48CT916WWJ+QGS3KnoAW2Q/enrqczMXl5jqhogaOhILLnJA9OjuhLQW3oppp8s6NzfZ3buH5aRlxHBQh4reqUN834nN2k9Wzd5j6HZHJX5AtsV//7Od9x0byXPn8CIm00XsxixrBS5EskHDcTQBDebiDcb/FqzhdYXvtkjtm/G9u4bK2KQbS0Zx2AuLK8oBNvVqB+ht6WpYoPKxbEXCPSPSJ1M4sy/p12oocHzaWi9BFe0B20H9DaMVFZ0vLzLU1aMFoE8O+ycVpfmtaNQGEuoeGVZdT/rgb+zdFR6WjHLX8JUR4BkPmlemWlLB8Dp2lUDP6rqM5eXMxXoNt1+lIXTOh38FrQnI0bc2aI/veyU5VwGLhFcrDVkxGDLn16d78BDRTgj8PpiZZRYiO/0643YaaE1cwui3FGwaX35MZTpKxpWYAiMxCDyn6I7NHM3v4xLhyAybOVJ9ZvOOdEbF4OVs6HrAguEUBGyuW21+qerymMAmdsryV8JGbt79DR+RtU9ctPTxBwaLM7fUOWq/8p8RDYhqQpY7eokNfZyV9k+9Onx9NaCyJwhq2QW1CRo6wQuzbFpEWoG/TAxJgpUI9uM3xxRLk5+q73w84dcxuMjpCVUcMF7xR5LQ57LkWphrdLlnQSRjpJnapbEU6F5sHPugzVvPLV/WcY5DdLMeZgkNYX/OM2x8w6+SngavBFpHTTEr2SBW0BOkqOBf7w5DV0lGnHfpwv6zGNvYAJ6W3Tmp4e1HInVdgoU7IB8qlKYw8sbHk7pgyhnHFPuLuUyXYVbjPgHqYw3eVnI29pvHaMh9Bwp6USEgKJqyEDUyJRaJLK/IPObJQ3K4WA2ULU44Ut3eAFKMmcddtlBpIQJ/CiQGKoVk20qJ6tPqV+O0DuA1VcrImxp89VdXrVSJ/h+eGAUdT1oDM8HDpAalFpRuU31Z+0obPGVkuT+uIZtZNDvhvd7qVHDMNnRqKFJ6r2c0ZChpniLaLCmAYfnVr2LbdxibNuGbYattttgr627GDSi7x0qKo5LAuZBUWWO1lNfrHpTpUZWm/8nHfKy8l1Ja2G4od4luUmYQ6amV0t6mcq2BzFKtp+mE6oKFDlAFyE1ZIWjxBlkNzqBvrUjkWT7vcYKjllqcd3K2ZYqgn4DBC5iuKSYhKVZ9BdKvMxUnfXTezURPLWaSOGAqu/VaqKI3FYAlK4ubSf08IC/v5IgBpiOLrui7ZtwRtxKt5pXwwgVphh4td0pPNXNyEIhIKwY6eNWswhvkaJbz1yWxXMPvNvszKGHN73p4PyLzJAWiuXEL967CExC74Qydp4fXSdlRl1Tp6wvkE/lnx9y1jGBdqbmGWJAPF+EIHAhWrmAc9BpuUCb70Su4S35VGXG3jlDolPfsod88TpQ3ZUbejs4Rd5 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)(36860700013)(82310400026)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:31:03.2014 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d18da0c1-d7fe-41e3-e4bc-08dd1751e389 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6850 The ret variable is not necessary. Reviewed-and-tested-by: Dhananjay Ugwekar Signed-off-by: Mario Limonciello Reviewed-by: Gautham R. Shenoy --- drivers/cpufreq/amd-pstate.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 2178931fbf87b..5869bcd287e87 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -318,13 +318,11 @@ static int shmem_set_epp(struct amd_cpudata *cpudata, u32 epp) static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata, int pref_index) { - int epp = -EINVAL; - int ret; + int epp; if (!pref_index) epp = cpudata->epp_default; - - if (epp == -EINVAL) + else epp = epp_values[pref_index]; if (epp > 0 && cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) { @@ -340,9 +338,7 @@ static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata, cpudata->boost_state); } - ret = amd_pstate_set_epp(cpudata, epp); - - return ret; + return amd_pstate_set_epp(cpudata, epp); } static inline int msr_cppc_enable(bool enable) From patchwork Sun Dec 8 06:30:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848640 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2073.outbound.protection.outlook.com [40.107.102.73]) (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 D485E1527B1; Sun, 8 Dec 2024 06:31:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639470; cv=fail; b=sWIbdDZUAmqB0eoUAQqQqchZmPNEWlDM1a6OqQNqMnnKKyp9oVR0894XZdKg7ggICBC5kKT7eAASLu3avehAQK4ZuIJ/hsxwdkxWrXcEl6Gb+ks16y4epigPI8zVTjxbcPLdqnuwli8z/OwZlWtzaiTbO3YwiwTSAcHc7H+2PoA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639470; c=relaxed/simple; bh=G7WZmQjJGwWyTzoGvIVBBc1zJ8j5hbkCD5y1ZkKPQN0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LsJuaSDmyoCCux8D0aG/iwyXnLEPCtJB+laUnlNW+7xmIG9v5am6rln2yDjlfi0X0xe5xruCOqyd1FEOKJ3e8hYjrvDkGV0G0epHLUgSarN/ZCDi2bBejpCp6GwICL/dAA7ILkJBq2xNGp/0e4mWKdPjXNi+y0o3nkZmdn12r0Y= 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=CPxotDaa; arc=fail smtp.client-ip=40.107.102.73 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="CPxotDaa" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=m8+GZuHSz2apgmVRfMIKYSyxLV+Hy+x1Twu0bJgviJLbVUkv7groE/JOrKB2q40u1Oi1WG5U4H0VI3KoZtIg2RnsBaiHJXL4+qAd7QTuAf1GwqTzKNRuGJNwPvMQYcnaqrzUFxJTUYkHtKivAj4C3npd6af0dZPNUNZISY1BcxRp0bzJ/xCLyfP6PJlEPBUWSTsUnmRVoWEb7aNWHPZRigjjLiy3pfHRQTmKE+Lm/zlgZDMNOlZoWANPPZwLomHknO9m+rWt8U4A74fKvusO07EeFYDISl1BZKqDXVoXdScU9XmR+b/gJt7liCyEEYZuOwPu/dI2e8DgMS+wRtkZUQ== 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=VPpGPbIaUvcdCsXFPkO0a59YD4NddTekCjTv+uiRGqc=; b=aS4szqmOb/fH0BZp259GMhACq8HXIuhkbzEHexN/SKdcYbWNO57AzGCwyaFVg45uqgdA+Gs2+H+amWK7a4WL3rC25Qkja75IqQ7RM0ByZQi76Bk8bNrZ8u0KzF+WvfeMyUmzJFZGOBRJiL3dhJhzsL9/4NKhcN37AVvkQ4AVawTmrHNT0Is1g37O1hd2q0ivnh3fvsgxzkaR1Wl9/0B6OKSwP164l6XQNf2i2sfH84DuCTu5ZcKMrJNI/WwjwF9hLZn8VMVf7h2DAc2/2K+cJFjfp/MQsinlaPCMriRhWx5P+UhyPD/uQh6Q33oP06ruw2yyUMFjQ1BTks2IMsRMZg== 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=VPpGPbIaUvcdCsXFPkO0a59YD4NddTekCjTv+uiRGqc=; b=CPxotDaaGqWae/VTnxfElTq1AGU/3yf5s9SOwx92IuIaucpDFMD3IihD6F8pNE8iNLsg8FWjeumW0SyyiowutqhmKrM3aAWKkX72luhCHMPZtTMmnJKNyHPZQ04ef1uc9XvBkYLyhiZ/7ZuuGfLCZC4aMNoc5EsBhnRghPZnJWY= Received: from DS7P220CA0006.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::10) 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.8207.19; Sun, 8 Dec 2024 06:31:04 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::ec) by DS7P220CA0006.outlook.office365.com (2603:10b6:8:1ca::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.15 via Frontend Transport; Sun, 8 Dec 2024 06:31: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:31:03 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:31:01 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello , "Artem S . Tashkinov" , Dhananjay Ugwekar Subject: [PATCH v2 15/16] cpufreq/amd-pstate: Set different default EPP policy for Epyc and Ryzen Date: Sun, 8 Dec 2024 00:30:30 -0600 Message-ID: <20241208063031.3113-16-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|PH7PR12MB8594:EE_ X-MS-Office365-Filtering-Correlation-Id: f3736dfb-6d42-4a7a-55a3-08dd1751e3fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: DbXlOPtULInm7eR0/jd8zQ6DEqiWsu7xtZ9S/GxZ97IXoG/urGhvj+oghfjwElQR/kV8VaPA2NMwNafu4tYTj2nk68kdpolR8xgW5cpgRBqCarA4z2XUAl4f7iw6s4wHM8Li5QOHvz7fv/lOb1/fRok3THrpi/zu3ywyuzLZeCPPUpHi640mYcY34no9HFa/VWOGZIVHYyj51ca43Hl4dAMhk/XCVhE7HRjenjB4CDmS59f9zGk3G7AqOPP+H4zl+X6Pzk7AJJQEHlyqflVxVYZ2DeS+qaki3klVOJ+xV4G1NJPPv+EkUn7OsVRtkPZBRkqSjSYxTI1aqZieQE0mCs1PkDy22EX6bI49yvlR0d6ZZ9ewInAZMRpuNnbUIgCUtBHVKIBFrKo/DqR7cyyr1K4qvf1T0Dsck6B/ME2sD8Tne2OuGKwnm2TWKluNwYe89peb65jfoe8oXkYPq8rqeAcMEGWPp7X4isP7yAJ54rfFjSXmr0TbfG+new81sh/Wq362l7+egGDZFtrRHIjx9vRITUL9u1MYoLgE6DF+zaLlFsmyRXldi4wkg6ljilzPW2o6hiU5WqqCqAz9U6wyd6/agQ+MKTPYPuG5GoUxiN2CBhdtuji2lGTwV7zX8H5lVnvZAy0poH323aIfKSwjl1sbm8S1yNIeDv+OBX8lT1nA5h8bQ6KTLLpRw0Z2FOOKNq2xQhch38qvu5d617vzFhfqnD6ZfxrwjndNf+G1pH/UfNdVb5VzNQOwgTr2RSCBSytekPmN5WYXh+vkg3YCwDc1BOt53Ep8bHSzVVc0knYe5YoQjiX3QynO5/QPa60Uy4o0mj7T63Uil+d49jUhemLBrc5uUHF4njTENvPDxLcbb+R7Kax0avvxcLf5D1QNpDPG8+UdkUjCg7L6d3iXAROM42fGUK27E/GJpGxyyXAIGd9t1qhPb5brsF8NaB3oNm8DTv5atXtfzyQCljoY2+pA3FUMrG0PcJFv9DymKeBZ5QZpgaarvWQqHeCcSHXYxzRiSNXIDd9zkEWMDgiVYxJ7Zv3BfHQg+lyTz7K/1na5IJDQBGx1DdFqPlpqbxo9lNKcmYJkVQk2kXDIwrra66TAnGlgKORC+YpSxic+HAAdm99OXXwR1HoCJ1vk09Lp5nEj0BRaJ8Qywi28KVSJ6Jtl3btlhwWt0oRPhSWY5vXzNRslIo4Ylmj94NAqYOs2vh0bqbIBN1gUbiaYAIOaa3ykqaK2Yd3+eH5ADkk4VRKM4qQge8ev6ibywlcgYjSHdJRvFn7sTG/ON/gF7kczaBg/mP0cWQjfKXMZh0NzKzkCHDtXQMbGcBsafStNzw7ZlmURt0wQ927R1PYQ9fOC/o85SgLhj4kx25OzNdSJEbG+lv2zCNtgkL5jDo1Fc7zaclCBQpCYNkcPhUnDWSN8wDCQ9vAyWn2gcRaX05mHuXtHOv5HmnRO57NfHQ2q7des 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)(1800799024)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:31:03.9670 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f3736dfb-6d42-4a7a-55a3-08dd1751e3fc 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8594 For Ryzen systems the EPP policy set by the BIOS is generally configured to performance as this is the default register value for the CPPC request MSR. If a user doesn't use additional software to configure EPP then the system will default biased towards performance and consume extra battery. Instead configure the default to "balanced_performance" for this case. Suggested-by: Artem S. Tashkinov Reviewed-by: Dhananjay Ugwekar Tested-by: Dhananjay Ugwekar Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219526 Reviewed-by: Gautham R. Shenoy Signed-off-by: Mario Limonciello --- drivers/cpufreq/amd-pstate.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 5869bcd287e87..a4ededb8d89df 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -1501,8 +1501,6 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) policy->driver_data = cpudata; - cpudata->epp_cached = cpudata->epp_default = amd_pstate_get_epp(cpudata); - policy->min = policy->cpuinfo.min_freq; policy->max = policy->cpuinfo.max_freq; @@ -1513,10 +1511,13 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) * the default cpufreq governor is neither powersave nor performance. */ if (amd_pstate_acpi_pm_profile_server() || - amd_pstate_acpi_pm_profile_undefined()) + amd_pstate_acpi_pm_profile_undefined()) { policy->policy = CPUFREQ_POLICY_PERFORMANCE; - else + cpudata->epp_default = amd_pstate_get_epp(cpudata); + } else { policy->policy = CPUFREQ_POLICY_POWERSAVE; + cpudata->epp_default = AMD_CPPC_EPP_BALANCE_PERFORMANCE; + } if (cpu_feature_enabled(X86_FEATURE_CPPC)) { ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value); @@ -1529,6 +1530,9 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) return ret; WRITE_ONCE(cpudata->cppc_cap1_cached, value); } + ret = amd_pstate_set_epp(cpudata, cpudata->epp_default); + if (ret) + return ret; current_pstate_driver->adjust_perf = NULL; From patchwork Sun Dec 8 06:30:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 848639 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2052.outbound.protection.outlook.com [40.107.93.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38FF615574E; Sun, 8 Dec 2024 06:31:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639472; cv=fail; b=mMk1DPWtMyp66taumERdld60Z2Um6s/uVXWNqbbH/tuzTD56nKRYdv1ow8qDWfAZAWTMEA57uUTwcNKlbI+xYIPYSZBKiU0rFFA/DrvRB+iK4Sirw4OEuL9NMCITw+mTzQV1JigtrGvCONoa0V9SuWXrqV0kOE7A1VF9tpERf2o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733639472; c=relaxed/simple; bh=aw9M/hP99koK1j9c0Kt7OIkvWJioIu+97d+9XOaEddI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l444fCLwQMTSJ0ITs/SyAojZjOXcaWTh2rRIZWI9B3Bc7z5l6aOkN5jwI0h/WN+hmUwtxwElr7kwlLuAEBrLm3hhjXEy/DKiNHXfoFTUb6QIPS3ibIq9vR3BG5GwDk1Xr5AiHdZoOI+8+hiOy5lKoUGxTiJPVYD9/liQH0C3nBU= 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=WSsbY91l; arc=fail smtp.client-ip=40.107.93.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="WSsbY91l" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PnbvApNx+Q7cGRt9NL6kxfTdKpSHF/CgptvOjKBEI8guJTN4eiSN0T6kKDuzZua+HBcD0M3SfOM85gH9dv1Oy05c59/rSpEGUOuPjSQkjRgD2rzQrtQYzgdKl2zv2MRryqcVvjIVEtI6dl/0x2F8dktUrO8esegDjb2yKQgeMfWHnkT5D7kpwde2AW6ZNebb6VNUbSo471KocI4WQnlyXs3sVtcKcESODoxiPZt+/YvUgGyZ+FRKtldniQZJEvHJgGh3Z7CcltuLa1K4Q9WoPzK7fEpiEdvJjgFgaTdc/Us2qFwqtdWiwZGB1DRmGZ9euphi6EYDm/tDNqnixOd2fQ== 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=Py5/UWIEkshoUfSScG+iJG7Dl+3UQLTpjqI+k2pSVmw=; b=sO1Q6PGVtuJUTyDVD30ajfU19fxhCJ1Rol5STW9bM6/c7a+YtuUBtSst+9w7tnrQPEIOBBsd7yL2dJF5yAWrBabeetMgfi5ykN8jUK9Xrur45GDi+KwNq1oRoh1B8Rw37Ej5KJ7X/h90GRwfgj/Drv3HqVC5X7Jks9gHfCzAurWE6Nb72yJyq2I0oeSUndQ3DAWxJYLw4zqOsJzIUkn2/N8G97zUBQUHwldTKzZefKWyVL466vahIJkql6G7N3Ps1POUxwgHiC4/Xrqdp8BRpIP9KrsH5NuBQxIgv80ECW0hLLc/kyVslJaodjb+2L4HU/5um99+O5oIt9GhN9k/AQ== 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=Py5/UWIEkshoUfSScG+iJG7Dl+3UQLTpjqI+k2pSVmw=; b=WSsbY91liYCqPp4U8iPGXIk2WzZrTszwlq4Kl9YyAGx6P793/Hm/wmkRB1niGibdRkafK1ARs7TH1joRvqf0MlIDIT+P83GtPNoJpTU6PfMvtjolfPIjtArWlCoczlvwyShRKKiI62rPNQYrAN0rO5Gb8dOHEL0iXcwFzRn09Tc= Received: from DS7P220CA0003.NAMP220.PROD.OUTLOOK.COM (2603:10b6:8:1ca::17) by DM4PR12MB6493.namprd12.prod.outlook.com (2603:10b6:8:b6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Sun, 8 Dec 2024 06:31:06 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:8:1ca:cafe::7c) by DS7P220CA0003.outlook.office365.com (2603:10b6:8:1ca::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.14 via Frontend Transport; Sun, 8 Dec 2024 06:31:05 +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 CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sun, 8 Dec 2024 06:31:05 +0000 Received: from AUS-P9-MLIMONCI.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; Sun, 8 Dec 2024 00:31:02 -0600 From: Mario Limonciello To: "Gautham R . Shenoy" CC: Perry Yuan , , , Dhananjay Ugwekar , Mario Limonciello Subject: [PATCH v2 16/16] cpufreq/amd-pstate: Drop boost_state variable Date: Sun, 8 Dec 2024 00:30:31 -0600 Message-ID: <20241208063031.3113-17-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241208063031.3113-1-mario.limonciello@amd.com> References: <20241208063031.3113-1-mario.limonciello@amd.com> 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: CY4PEPF0000E9D8:EE_|DM4PR12MB6493:EE_ X-MS-Office365-Filtering-Correlation-Id: 6deb94b0-ce99-4a48-5d1c-08dd1751e507 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: uHzsE2g5oHB4ACY3AuM8HJ13FwxOhEAz4LGSYKYKHrQ1AuL/25odkCIBy9foNUONNy76KB8FfnOSiU8XT4atuHFzxUJ7ozVzUZmYbfsemYuypxHIC5agUSowqK+pm06f72FYpQgxlRebXeri/rdNVI9Vhm+603DyJGUEep+WdcQaL2IKk4eZ52l9tHVjtbYQwS8EtneNgbkIxmE1MAM21rdSsF9hiMkv/XCi+N6hUs4tdYqyHIvwtY5s+m9NiLhymSFxxCVr/W2IQWLUM/tsW49KvL621dMeLMnX+q78c5Pg3moSe9NEz0qxpFnJRoix97KJRxWtPDRxdf4PNssoSc4+yrlel/Bu6OiCTce2bQpmZ1V3ynqcT5EMCvIZdU69Z14SjL7aBTLNZA3IOVnSJpSedk2lf844XSjd6J5QI2I2Gn9jF8DQQz+Ezma235AkDc5oBUy65b/5ImGYbdPRPxmzB6IIN8xyVsSy2zpBUzztZqI5DYdsBaaPSfEtVbcC7IaK6kCnu92doKAo9jvCh20+CYDGJK+644QbQI/SnpNDkoHAVkwz04nQ1cbx1lRxUHGpoTiJkyrnurJLf49/MTBArf9eG+6q79EnJfrhf4Ew6y0d2hKrPpe6OHiqZL4OgQfOg/aMdjF6KBngFNnlMALoqN30FzJLvaIX23XjJoLBiFOGqyOjsxBo/H0eAAtpqf0ppKo/XkTwCLRsAKtnDBa58Kr42ILONyHt3Cbz9YjT/aN8KriAxo+bMxIPRQGvaLXt8yRPmOmDDENThkvA9mZsoRFZwjlBwKwZmd/07ftRBERi5Nvkdv8aQEAKHA9V592Yh9Z1NhrHtM2i3mHN7KDOdYXCVcwMzB4E7zvE3H/iigkx4yjCr79rkSI3tbMqkUU7RsVCLFhFdJX2NF74Pq2wEROtvFQVa382SoVSiaYk4cHLGH48RY7iDYNxnMWPxCb4D0vWDBvhuYuvdqIYwM/OdRpnEmrBJuvHz5DHNijUDkcj8lIg3ATKMh62Cm+zJ4AS5/ZoY9v4glsRuTsoo62LesX5z5hvEEUi+m90OEEPO6h9JwgLrSe+xXAExbsYF3L39QQC0HDqxqBxVq9Iszw4pfm1C+ZaraEqC3KcxmunRanrxFEHqZxwWJTqpAXO69Rx2FG1UuCK715DeGAVND8xHomrjj/jE1l0WpVAFMo53piGXSXc+EGJeGaIaRlPKzC7xusdhuOUGOeY5TUt7CMFRfrfW0Kmkbhbw1vjg/Y+bUtN8SkLbGOLx0vt8nN77G1EGrSgxmz4CWH0xOwxnVaMgZLu1On9G4HL53b1Vuo3gwk6QQ4cBJmrE8Kvdgt5BRiBCfCSmC979DU49JNCOLuJHnI752OyevnPRYzd0WyOYaTHrpKnSozZBfPQvpd0PnNc2gGpjPg9R+ePAYUBabgtdxQPnW5qPb/IiT+kgMf1Kxl8oCXh1shKpu5QKJ5h 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)(376014)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2024 06:31:05.7014 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6deb94b0-ce99-4a48-5d1c-08dd1751e507 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: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6493 Currently boost_state is cached for every processor in cpudata structure and driver boost state is set for every processor. Both of these aren't necessary as the driver only needs to set once and the policy stores whether boost is enabled. Move the driver boost setting to registration and adjust all references to cached value to pull from the policy instead. Signed-off-by: Mario Limonciello Reviewed-by: Gautham R. Shenoy --- drivers/cpufreq/amd-pstate.c | 26 +++++++++++++------------- drivers/cpufreq/amd-pstate.h | 1 - 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index a4ededb8d89df..3f6208828c063 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -315,9 +315,10 @@ static int shmem_set_epp(struct amd_cpudata *cpudata, u32 epp) return ret; } -static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata, - int pref_index) +static int amd_pstate_set_energy_pref_index(struct cpufreq_policy *policy, + int pref_index) { + struct amd_cpudata *cpudata = policy->driver_data; int epp; if (!pref_index) @@ -335,7 +336,7 @@ static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata, epp, FIELD_GET(AMD_CPPC_MIN_PERF_MASK, cpudata->cppc_req_cached), FIELD_GET(AMD_CPPC_MAX_PERF_MASK, cpudata->cppc_req_cached), - cpudata->boost_state); + policy->boost_enabled); } return amd_pstate_set_epp(cpudata, epp); @@ -746,7 +747,6 @@ static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state) guard(mutex)(&amd_pstate_driver_lock); ret = amd_pstate_cpu_boost_update(policy, state); - WRITE_ONCE(cpudata->boost_state, !ret ? state : false); policy->boost_enabled = !ret ? state : false; refresh_frequency_limits(policy); @@ -768,9 +768,6 @@ static int amd_pstate_init_boost_support(struct amd_cpudata *cpudata) goto exit_err; } - /* at least one CPU supports CPB, even if others fail later on to set up */ - current_pstate_driver->boost_enabled = true; - ret = rdmsrl_on_cpu(cpudata->cpu, MSR_K7_HWCR, &boost_val); if (ret) { pr_err_once("failed to read initial CPU boost state!\n"); @@ -1176,7 +1173,6 @@ static ssize_t show_energy_performance_available_preferences( static ssize_t store_energy_performance_preference( struct cpufreq_policy *policy, const char *buf, size_t count) { - struct amd_cpudata *cpudata = policy->driver_data; char str_preference[21]; ssize_t ret; @@ -1190,7 +1186,7 @@ static ssize_t store_energy_performance_preference( guard(mutex)(&amd_pstate_limits_lock); - ret = amd_pstate_set_energy_pref_index(cpudata, ret); + ret = amd_pstate_set_energy_pref_index(policy, ret); return ret ? ret : count; } @@ -1265,6 +1261,9 @@ static int amd_pstate_register_driver(int mode) return ret; } + /* at least one CPU supports CPB */ + current_pstate_driver->boost_enabled = cpu_feature_enabled(X86_FEATURE_CPB); + ret = cpufreq_register_driver(current_pstate_driver); if (ret) { amd_pstate_driver_cleanup(); @@ -1604,8 +1603,9 @@ static int amd_pstate_epp_set_policy(struct cpufreq_policy *policy) return 0; } -static int amd_pstate_epp_reenable(struct amd_cpudata *cpudata) +static int amd_pstate_epp_reenable(struct cpufreq_policy *policy) { + struct amd_cpudata *cpudata = policy->driver_data; u64 max_perf; int ret; @@ -1619,7 +1619,7 @@ static int amd_pstate_epp_reenable(struct amd_cpudata *cpudata) trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf, cpudata->epp_cached, FIELD_GET(AMD_CPPC_MIN_PERF_MASK, cpudata->cppc_req_cached), - max_perf, cpudata->boost_state); + max_perf, policy->boost_enabled); } return amd_pstate_update_perf(cpudata, 0, 0, max_perf, cpudata->epp_cached, false); @@ -1632,7 +1632,7 @@ static int amd_pstate_epp_cpu_online(struct cpufreq_policy *policy) pr_debug("AMD CPU Core %d going online\n", cpudata->cpu); - ret = amd_pstate_epp_reenable(cpudata); + ret = amd_pstate_epp_reenable(policy); if (ret) return ret; cpudata->suspended = false; @@ -1690,7 +1690,7 @@ static int amd_pstate_epp_resume(struct cpufreq_policy *policy) guard(mutex)(&amd_pstate_limits_lock); /* enable amd pstate from suspend state*/ - amd_pstate_epp_reenable(cpudata); + amd_pstate_epp_reenable(policy); cpudata->suspended = false; } diff --git a/drivers/cpufreq/amd-pstate.h b/drivers/cpufreq/amd-pstate.h index 7765c82f975c6..9747e3be6ceee 100644 --- a/drivers/cpufreq/amd-pstate.h +++ b/drivers/cpufreq/amd-pstate.h @@ -98,7 +98,6 @@ struct amd_cpudata { u64 cppc_cap1_cached; bool suspended; s16 epp_default; - bool boost_state; }; /*