From: Huang Shijie <shijie@os.amperecomputing.com>
To: util-linux@vger.kernel.org
Cc: kzak@redhat.com, patches@amperecomputing.com,
zwang@amperecomputing.com, mas@amperecomputing.com,
ilkka@os.amperecomputing.com, jeremy.linton@arm.com,
jbastian@redhat.com, m.mizuma@jp.fujitsu.com,
patrick.zhang@amperecomputing.com,
Huang Shijie <shijie@os.amperecomputing.com>
Subject: [RFC PATCH] lscpu: get more infomation when using "/sys/firmware/dmi/entries/4-0/raw"
Date: Mon, 21 Jun 2021 11:09:00 +0000 [thread overview]
Message-ID: <20210621110900.41043-1-shijie@os.amperecomputing.com> (raw)
This patch gets more infomation for "BIOS Model name"
from the file "/sys/firmware/dmi/entries/4-0/raw"
Before this patch, we can get the output from Centos 7.9:
----------------------------------------------------
BIOS Vendor ID: Ampere(TM)
Model name: Neoverse-N1
BIOS Model name: Ampere(TM) Altra(TM) Processor
----------------------------------------------------
After this patch, in Centos 7.9, we get:
----------------------------------------------------
BIOS Vendor ID: Ampere(TM)
Model name: Neoverse-N1
BIOS Model name: Ampere(TM) Altra(TM) Processor Q00-00 CPU @ 2.8GHz
----------------------------------------------------
Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
---
sys-utils/lscpu-arm.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c
index 885aadc36..1af689649 100644
--- a/sys-utils/lscpu-arm.c
+++ b/sys-utils/lscpu-arm.c
@@ -317,6 +317,8 @@ static int arm_rXpY_decode(struct lscpu_cputype *ct)
#define PROC_MFR_OFFSET 0x07
#define PROC_VERSION_OFFSET 0x10
+#define PROC_CURRENT_SPEED 0x16
+#define PROC_PART_NUM 0x22
/*
* Use firmware to get human readable names
@@ -324,7 +326,8 @@ static int arm_rXpY_decode(struct lscpu_cputype *ct)
static int arm_smbios_decode(struct lscpu_cputype *ct)
{
uint8_t data[8192];
- char buf[128], *str;
+ char buf[128], *str, *str1;
+ uint16_t current_speed;
struct lscpu_dmi_header h;
int fd;
ssize_t rs;
@@ -348,8 +351,12 @@ static int arm_smbios_decode(struct lscpu_cputype *ct)
}
str = dmi_string(&h, data[PROC_VERSION_OFFSET]);
- if (str) {
- xstrncpy(buf, str, 127);
+ str1 = dmi_string(&h, data[PROC_PART_NUM]);
+ current_speed = *((uint16_t *)(&data[PROC_CURRENT_SPEED]));
+ if (str || str1) {
+ snprintf(buf, sizeof(buf), "%s %s CPU @ %d.%dGHz",
+ (str ?: ""), (str1 ?: ""),
+ current_speed / 1000, (current_speed % 1000) / 100);
ct->bios_modelname = xstrdup(buf);
}
--
2.30.2
next reply other threads:[~2021-06-21 3:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-21 11:09 Huang Shijie [this message]
2021-06-25 9:23 ` [RFC PATCH] lscpu: get more infomation when using "/sys/firmware/dmi/entries/4-0/raw" Karel Zak
2021-06-25 9:33 ` Huang Shijie
2021-06-25 11:28 ` Karel Zak
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=20210621110900.41043-1-shijie@os.amperecomputing.com \
--to=shijie@os.amperecomputing.com \
--cc=ilkka@os.amperecomputing.com \
--cc=jbastian@redhat.com \
--cc=jeremy.linton@arm.com \
--cc=kzak@redhat.com \
--cc=m.mizuma@jp.fujitsu.com \
--cc=mas@amperecomputing.com \
--cc=patches@amperecomputing.com \
--cc=patrick.zhang@amperecomputing.com \
--cc=util-linux@vger.kernel.org \
--cc=zwang@amperecomputing.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox