All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bingsong Si <owen.si@ucloud.cn>
To: linux-pm@vger.kernel.org
Cc: lenb@kernel.org
Subject: [PATCH] tools/power turbostat: fix offset and idx on Amd F17h and newer
Date: Sat, 20 Feb 2021 19:27:49 +0800	[thread overview]
Message-ID: <20210220112749.3415192-1-owen.si@ucloud.cn> (raw)

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 --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:
-- 
2.27.0


                 reply	other threads:[~2021-02-20 11:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210220112749.3415192-1-owen.si@ucloud.cn \
    --to=owen.si@ucloud.cn \
    --cc=lenb@kernel.org \
    --cc=linux-pm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.