From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D154C1BD4E0; Mon, 17 Jun 2024 13:23:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718630608; cv=none; b=guUT1o9af/imCOdBFcp4V4cZDqSp6nTaLXAJndw2KUqO1K7FV5TJXdDPZ5J8VfeXdQuqVU+AUEfRWukUP9Lcvg0V2/XK1aOIeuzh3RucUEkxO5Bromr8uZ04XJG+sLQ0olNriIzVA+SmDDI8Q4654RKmhSuPRrOkGia1f6rDimQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718630608; c=relaxed/simple; bh=Thyw0jk39ehSKVrWbpzk6z0cIctwuMcByciNbZ10WDs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p2wTR8kvkACvnToeaMqBKtwrh0eyAuE69MPby3aVYgYa/zePtExNWNP/PxRd8+4xJ08lL7K+mfNUdAiJRDGkU5f045x5cxC1222ofEGMqZqt/2k1hZlunehNAx8yOohqEws5IrbeFd38tWmPc8MZwx425DrS+GiX9RjEHbE7AZA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NHOH69tS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NHOH69tS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E897C2BD10; Mon, 17 Jun 2024 13:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718630608; bh=Thyw0jk39ehSKVrWbpzk6z0cIctwuMcByciNbZ10WDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NHOH69tS1eN//rqNx36ZQtX1cQw7A48CsFqLG2dtPTCbKa+dMVY/bK/P31veRF0Iy dSpJ2nQHEzAEOBWB/iBkYXTYNsEFoqA2M2/yGSqcvXKoYeIkOAiV7IQ20B2fm19ae1 sj0ZKRyWP6/Wp+jI9YMPYJLmamh3GJydDsn1yaMoP3NLFxkwvC4q7iyf4uaX+2u9Tp QJT/nBnsSRwFrBm6q7/exIlKu/+WvJyEmG0C4UqAflUNOLsAEZbq06lHKtM9kQcXxO fDP4nxoamtFRHmFZj+jX/aqepE1VOgHvo7zZ7Iz9M22aWVWymdp+8Sj0xP2wn2SOzq cXo45IK6QLA0A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dhananjay Ugwekar , Ananth Narayan , Mario Limonciello , Shuah Khan , Sasha Levin , trenn@suse.com, shuah@kernel.org, linux-pm@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 10/35] tools/power/cpupower: Fix Pstate frequency reporting on AMD Family 1Ah CPUs Date: Mon, 17 Jun 2024 09:22:08 -0400 Message-ID: <20240617132309.2588101-10-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240617132309.2588101-1-sashal@kernel.org> References: <20240617132309.2588101-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.34 Content-Transfer-Encoding: 8bit From: Dhananjay Ugwekar [ Upstream commit 43cad521c6d228ea0c51e248f8e5b3a6295a2849 ] Update cpupower's P-State frequency calculation and reporting with AMD Family 1Ah+ processors, when using the acpi-cpufreq driver. This is due to a change in the PStateDef MSR layout in AMD Family 1Ah+. Tested on 4th and 5th Gen AMD EPYC system Signed-off-by: Ananth Narayan Signed-off-by: Dhananjay Ugwekar Reviewed-by: Mario Limonciello Signed-off-by: Shuah Khan Signed-off-by: Sasha Levin --- tools/power/cpupower/utils/helpers/amd.c | 26 +++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c index c519cc89c97f4..0a56e22240fc8 100644 --- a/tools/power/cpupower/utils/helpers/amd.c +++ b/tools/power/cpupower/utils/helpers/amd.c @@ -41,6 +41,16 @@ union core_pstate { unsigned res1:31; unsigned en:1; } pstatedef; + /* since fam 1Ah: */ + struct { + unsigned fid:12; + unsigned res1:2; + unsigned vid:8; + unsigned iddval:8; + unsigned idddiv:2; + unsigned res2:31; + unsigned en:1; + } pstatedef2; unsigned long long val; }; @@ -48,6 +58,10 @@ static int get_did(union core_pstate pstate) { int t; + /* Fam 1Ah onward do not use did */ + if (cpupower_cpu_info.family >= 0x1A) + return 0; + if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF) t = pstate.pstatedef.did; else if (cpupower_cpu_info.family == 0x12) @@ -61,12 +75,18 @@ static int get_did(union core_pstate pstate) static int get_cof(union core_pstate pstate) { int t; - int fid, did, cof; + int fid, did, cof = 0; did = get_did(pstate); if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF) { - fid = pstate.pstatedef.fid; - cof = 200 * fid / did; + if (cpupower_cpu_info.family >= 0x1A) { + fid = pstate.pstatedef2.fid; + if (fid > 0x0f) + cof = (fid * 5); + } else { + fid = pstate.pstatedef.fid; + cof = 200 * fid / did; + } } else { t = 0x10; fid = pstate.pstate.fid; -- 2.43.0