From patchwork Mon May 6 10:19:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 795663 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2076.outbound.protection.outlook.com [40.107.102.76]) (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 826F8142E64; Mon, 6 May 2024 10:20:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714990835; cv=fail; b=SNfDuv5m1ujQBnQtQdsPxbg3bZAU4NpBYmiQw7bHwXUBfClupA22RKNIN0xlA1dwNIMDWm9QC/zJthDehtYuHm6M4QtQmc6LUfse0S2Vt2+x2LOpRFXnyz63BwMbJd7r9Rl55XcqXkBJRg8TavMZhybzer2ogJXo4pKVU8kzrAw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714990835; c=relaxed/simple; bh=aj+jVm5Y66yLkhCotmOflseLcnj7xeRrxtuzD4R8NmY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mG7zCT9qylW+NDFkXos2lypzi4Ieg31ybBW9FXpsYdGaHBTkRQIZR1Bf6R0OvbBPfR+nqKuiGkNNx4/Jc9MDRJjquFgRtlSbrpgcPwqmFMZauyqQnX4lBWvVGLp1H4qppo5KuqXAfi/jEXaMuNf+W5EudKIt+fmaYHmzBs1QRXQ= 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=TQJ+YOb5; arc=fail smtp.client-ip=40.107.102.76 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="TQJ+YOb5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VXc0pVxdQaH9lxNPeR8DBJdbsPSoPQCglfUn8Nj7KVMXgImv/ttYi/DILrxc+P8VSNaR3BGQuadHZLA1WuTWBB0ARy6sK4pzUSIX32c4gj5FgE82cFYp+w9T37ndFtGp7Nt75duQV8tAvd/p1osNvfL03RbYpn5tjDLRl3aOjHKHU7aMdWmc+qo67923TzKs7YaTdKKxxSi3aIlW3cBafAP6m+9TtYWtgP8Jumss37cB45foxsK5jia9l79PBrbPQqvXYuRgGOs8JMBAXxDnce2OTCgeBjWPoFuzkdTrUsbXpmrwu/gPthcszzlzq2831wsM2YzWGArFvmju3aDKsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z2+kQZEikSpTsYjgg4K9mRMLS7fHH+01BY367aQ2EI0=; b=NXB2ZLZwPmewGjYaN/il63gYYl+Qfx2ns5ntxuuF0dKJusq5A+mMtHStfsYBBSyof/HGbP3Wq1kKZSrjGIVLgYutF5V7wb3ALTlZvJ8pDJra2ZuFGVuVXhKvI+6bZCYilUlgeoAA++Rvkj8wPYW+q5Xv8sHw+0RHGpOD0BSKYOkZFc66TXT3xXg6rfVFL3asn3WYYRTHvthCloNqERld8fcKrfoq4RNGcaYQ+8OLD4JMK6se/0iCwpsFY76Fr7Q64fYf2YnyE8Bvf9vTTPtq0yeJTOA0RghVNhqAMG64yCw4+sKVP4s3aYgIiHkVP8VM/lmzM4APN7s088D+U+3Alw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z2+kQZEikSpTsYjgg4K9mRMLS7fHH+01BY367aQ2EI0=; b=TQJ+YOb5mFxQi2NRkU1LgxYmTEROKYjxFXrOVNgjsXpZEjOt9KGhoqX+6yJGBQyArMYgYDRyFLvuGpEIwM055L9DNFXdbVNsOtW+OT3QuEa271edecvRkuUF7k265/5KMIpSyYjwg00xJj/b6T7SSs42Pk/fXEHfsajYWynIBDc= Received: from BN8PR12CA0014.namprd12.prod.outlook.com (2603:10b6:408:60::27) by SA1PR12MB8966.namprd12.prod.outlook.com (2603:10b6:806:385::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 10:20:29 +0000 Received: from BN3PEPF0000B073.namprd04.prod.outlook.com (2603:10b6:408:60:cafe::32) by BN8PR12CA0014.outlook.office365.com (2603:10b6:408:60::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.42 via Frontend Transport; Mon, 6 May 2024 10:20:29 +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 BN3PEPF0000B073.mail.protection.outlook.com (10.167.243.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7544.18 via Frontend Transport; Mon, 6 May 2024 10:20:29 +0000 Received: from pyuan-Chachani-VN.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 6 May 2024 05:20:25 -0500 From: Perry Yuan To: , , , , , CC: , , , , , , Subject: [PATCH v9 4/7] cpufreq: amd-pstate: fix the MSR highest perf will be reset issue while cpb boost off Date: Mon, 6 May 2024 18:19:56 +0800 Message-ID: <08f1feb0ca38d603b8eef54b2e4db3a1cf35f272.1714989803.git.perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B073:EE_|SA1PR12MB8966:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e98250e-e68e-4168-a00a-08dc6db62760 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|376005|36860700004|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: j0Zhl3OG4MslFXZq0bCxdRN+FpQqFwkHXPv75klpcbfiiIArvoNCr4a9dkRDNCUfXYxMCmsXNNx82alqSDj8nI2YA0nG+yPrjx2plhQQeIkB1Hv7SASr9hcAGT2kOj9MpmfjKSUXB4Q1p41g4cdYFqNMXp+vvp6zL7+b3XsqJngssqSIzMR4+wccqjmwLwCF3a53C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ET6/Q+zqwpGTkx2EfifkF/XBrVwHVNCd/p0vxh69l70aTyo2e+9F9JIxpnQ1pFrzbPebc6Rmxx6WyhRs0fF6tURUCiWw1K0Xj4Zs7aD0pDtJXvf1sDu5SgSctbmKk/LzVV X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(376005)(36860700004)(1800799015)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 10:20:29.1418 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0e98250e-e68e-4168-a00a-08dc6db62760 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: BN3PEPF0000B073.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8966 From: Perry Yuan Select the min perf to fix the highest perf value while update pstate CPPC request MSR register, here it needs to limit the max perf value when CPU boost is disabled in case of that highest perf value in the MSR will be reset to original highest perf value which cause the BOOST control failed. Signed-off-by: Perry Yuan Acked-by: Huang Rui Reviewed-by: Mario Limonciello --- drivers/cpufreq/amd-pstate.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index f81fd61dd2a9..11bce2c1db32 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -476,6 +476,7 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, u32 des_perf, u32 max_perf, bool fast_switch, int gov_flags) { u64 prev = READ_ONCE(cpudata->cppc_req_cached); + u32 nominal_perf = READ_ONCE(cpudata->nominal_perf); u64 value = prev; min_perf = clamp_t(unsigned long, min_perf, cpudata->min_limit_perf, @@ -495,6 +496,10 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, value &= ~AMD_CPPC_DES_PERF(~0L); value |= AMD_CPPC_DES_PERF(des_perf); + /* limit the max perf when core performance boost feature is disabled */ + if (!amd_pstate_global_params.cpb_boost) + max_perf = min_t(unsigned long, nominal_perf, max_perf); + value &= ~AMD_CPPC_MAX_PERF(~0L); value |= AMD_CPPC_MAX_PERF(max_perf);