Skip to content

Commit 997c5ee

Browse files
committed
Merge: tools/power/cpupower: Fix Pstate frequency reporting on AMD Family 1Ah CPUs
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5202 JIRA: https://issues.redhat.com/browse/RHEL-57711 Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=64282974 Tested: By viewing frequency-info on (amd-turin-volcano-02) system. commit 43cad52 Author: Dhananjay Ugwekar <[email protected]> Date: Tue Apr 30 14:07:06 2024 +0530 tools/power/cpupower: Fix Pstate frequency reporting on AMD Family 1Ah CPUs 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 <[email protected]> Signed-off-by: Dhananjay Ugwekar <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Signed-off-by: Shuah Khan <[email protected]> Signed-off-by: Steve Best <[email protected]> Approved-by: David Arcari <[email protected]> Approved-by: Tony Camuso <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: Rado Vrbovsky <[email protected]>
2 parents 9428f3f + 27defb6 commit 997c5ee

File tree

1 file changed

+23
-3
lines changed
  • tools/power/cpupower/utils/helpers

1 file changed

+23
-3
lines changed

tools/power/cpupower/utils/helpers/amd.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,27 @@ union core_pstate {
4141
unsigned res1:31;
4242
unsigned en:1;
4343
} pstatedef;
44+
/* since fam 1Ah: */
45+
struct {
46+
unsigned fid:12;
47+
unsigned res1:2;
48+
unsigned vid:8;
49+
unsigned iddval:8;
50+
unsigned idddiv:2;
51+
unsigned res2:31;
52+
unsigned en:1;
53+
} pstatedef2;
4454
unsigned long long val;
4555
};
4656

4757
static int get_did(union core_pstate pstate)
4858
{
4959
int t;
5060

61+
/* Fam 1Ah onward do not use did */
62+
if (cpupower_cpu_info.family >= 0x1A)
63+
return 0;
64+
5165
if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF)
5266
t = pstate.pstatedef.did;
5367
else if (cpupower_cpu_info.family == 0x12)
@@ -61,12 +75,18 @@ static int get_did(union core_pstate pstate)
6175
static int get_cof(union core_pstate pstate)
6276
{
6377
int t;
64-
int fid, did, cof;
78+
int fid, did, cof = 0;
6579

6680
did = get_did(pstate);
6781
if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF) {
68-
fid = pstate.pstatedef.fid;
69-
cof = 200 * fid / did;
82+
if (cpupower_cpu_info.family >= 0x1A) {
83+
fid = pstate.pstatedef2.fid;
84+
if (fid > 0x0f)
85+
cof = (fid * 5);
86+
} else {
87+
fid = pstate.pstatedef.fid;
88+
cof = 200 * fid / did;
89+
}
7090
} else {
7191
t = 0x10;
7292
fid = pstate.pstate.fid;

0 commit comments

Comments
 (0)