Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 43cad52

Browse files
dhananjay-AMDshuahkh
authored andcommitted
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 <Ananth.Narayan@amd.com> Signed-off-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 1613e60 commit 43cad52

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)