diff mbox series

tools/power turbostat: fix offset and idx on Amd F17h and newer

Message ID 20210220112749.3415192-1-owen.si@ucloud.cn (mailing list archive)
State Accepted, archived
Delegated to: Len Brown
Headers show
Series tools/power turbostat: fix offset and idx on Amd F17h and newer | expand

Commit Message

Bingsong Si Feb. 20, 2021, 11:27 a.m. UTC
Amd uses a different pkg energy msr, without this fix, turbostat exit
immediately on Amd Epyc Cpu.

Fixes: 3316f99a9f1 ("tools/power turbostat: Also read package power on AMD F17h (Zen)")

Signed-off-by: Bingsong Si <owen.si@ucloud.cn>
---
 tools/power/x86/turbostat/turbostat.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index a7c4f0772e53..68cb2ae632de 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -297,7 +297,10 @@  int idx_to_offset(int idx)
 
 	switch (idx) {
 	case IDX_PKG_ENERGY:
-		offset = MSR_PKG_ENERGY_STATUS;
+		if (do_rapl & RAPL_AMD_F17H)
+			offset = MSR_PKG_ENERGY_STAT;
+		else
+			offset = MSR_PKG_ENERGY_STATUS;
 		break;
 	case IDX_DRAM_ENERGY:
 		offset = MSR_DRAM_ENERGY_STATUS;
@@ -326,6 +329,7 @@  int offset_to_idx(int offset)
 
 	switch (offset) {
 	case MSR_PKG_ENERGY_STATUS:
+	case MSR_PKG_ENERGY_STAT:
 		idx = IDX_PKG_ENERGY;
 		break;
 	case MSR_DRAM_ENERGY_STATUS: