util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masayoshi Mizuma <msys.mizuma@gmail.com>
To: util-linux@vger.kernel.org, jbastian@redhat.com, jeremy.linton@arm.com
Cc: Masayoshi Mizuma <msys.mizuma@gmail.com>,
	Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Subject: [PATCH v5] lscpu-arm: Add "BIOS Vendor ID" and "BIOS Model name" to show the SMBIOS information.
Date: Tue, 10 Nov 2020 20:24:00 -0500	[thread overview]
Message-ID: <20201111012400.23995-1-msys.mizuma@gmail.com> (raw)

From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>

After commit: 367c85c47 ("lscpu: use SMBIOS tables on ARM for lscpu"),
Model name for A64FX shows like as:

   Model name:       461F0010

That's because 367c85c47 changes to get the modelname from Processor
Version of SMBIOS.

To fix that, use the hard corded table to show the "Model name" and
add two new lines; "BIOS Vendor ID" and "BIOS Model name" to show the
SMBIOS information.

lscpu shows the SMBIOS information when root user runs it because
accessing the SMBIOS information requires root privilege.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
---
 sys-utils/lscpu-arm.c | 22 ++++++++--------------
 sys-utils/lscpu.c     |  4 ++++
 sys-utils/lscpu.h     |  2 ++
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c
index 20c7291e5..52dbff804 100644
--- a/sys-utils/lscpu-arm.c
+++ b/sys-utils/lscpu-arm.c
@@ -281,7 +281,7 @@ static void __arm_cpu_decode(struct lscpu_desc *desc)
 #define PROC_MFR_OFFSET		0x07
 #define PROC_VERSION_OFFSET	0x10
 
-static int __arm_cpu_smbios(struct lscpu_desc *desc)
+static void __arm_cpu_smbios(struct lscpu_desc *desc)
 {
 	uint8_t data[8192];
 	char buf[128], *str;
@@ -291,41 +291,35 @@ static int __arm_cpu_smbios(struct lscpu_desc *desc)
 
 	fd = open(_PATH_SYS_DMI_TYPE4, O_RDONLY);
 	if (fd < 0)
-		return fd;
+		return;
 
 	rs = read_all(fd, (char *) data, 8192);
 	close(fd);
 
 	if (rs == -1)
-		return -1;
+		return;
 
 	to_dmi_header(&h, data);
 
 	str = dmi_string(&h, data[PROC_MFR_OFFSET]);
 	if (str) {
 		xstrncpy(buf, str, 127);
-		desc->vendor = xstrdup(buf);
+		desc->bios_vendor = xstrdup(buf);
 	}
 
 	str = dmi_string(&h, data[PROC_VERSION_OFFSET]);
 	if (str) {
 		xstrncpy(buf, str, 127);
-		desc->modelname = xstrdup(buf);
+		desc->bios_modelname = xstrdup(buf);
 	}
-
-	return 0;
 }
 
 void arm_cpu_decode(struct lscpu_desc *desc, struct lscpu_modifier *mod)
 {
-	int rc = -1;
-
-	/* use SMBIOS Type 4 data if available,
-	 * else fall back to manual decoding using the tables above */
+	/* use SMBIOS Type 4 data if available */
 	if (mod->system == SYSTEM_LIVE &&
 	    access(_PATH_SYS_DMI_TYPE4, R_OK) == 0)
-		rc = __arm_cpu_smbios(desc);
+		__arm_cpu_smbios(desc);
 
-	if (rc)
-		__arm_cpu_decode(desc);
+	__arm_cpu_decode(desc);
 }
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index b7dc4dfb5..a3e7b4445 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -2146,6 +2146,8 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
 		add_summary_n(tb, _("NUMA node(s):"), desc->nnodes);
 	if (desc->vendor)
 		add_summary_s(tb, _("Vendor ID:"), desc->vendor);
+	if (desc->bios_vendor)
+		add_summary_s(tb, _("BIOS Vendor ID:"), desc->bios_vendor);
 	if (desc->machinetype)
 		add_summary_s(tb, _("Machine type:"), desc->machinetype);
 	if (desc->family)
@@ -2154,6 +2156,8 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
 		add_summary_s(tb, _("Model:"), desc->revision ? desc->revision : desc->model);
 	if (desc->modelname || desc->cpu)
 		add_summary_s(tb, _("Model name:"), desc->cpu ? desc->cpu : desc->modelname);
+	if (desc->bios_modelname)
+		add_summary_s(tb, _("BIOS Model name:"), desc->bios_modelname);
 	if (desc->stepping)
 		add_summary_s(tb, _("Stepping:"), desc->stepping);
 	if (desc->freqboost >= 0)
diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h
index 3de0abcce..d73583f77 100644
--- a/sys-utils/lscpu.h
+++ b/sys-utils/lscpu.h
@@ -98,10 +98,12 @@ struct lscpu_desc {
 
 	char	*arch;
 	char	*vendor;
+	char	*bios_vendor;	/* aarch64 */
 	char	*machinetype;	/* s390 */
 	char	*family;
 	char	*model;
 	char	*modelname;
+	char	*bios_modelname;  /* aarch64 */
 	char	*revision;  /* alternative for model (ppc) */
 	char	*cpu;       /* alternative for modelname (ppc, sparc) */
 	char	*virtflag;	/* virtualization flag (vmx, svm) */
-- 
2.27.0


             reply	other threads:[~2020-11-11  1:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11  1:24 Masayoshi Mizuma [this message]
2020-11-11  8:43 ` [PATCH v5] lscpu-arm: Add "BIOS Vendor ID" and "BIOS Model name" to show the SMBIOS information Karel Zak
2020-11-13  9:59 ` Karel Zak
2020-11-13 16:47   ` Masayoshi Mizuma
2020-11-13 18:21     ` Jeffrey Bastian

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=20201111012400.23995-1-msys.mizuma@gmail.com \
    --to=msys.mizuma@gmail.com \
    --cc=jbastian@redhat.com \
    --cc=jeremy.linton@arm.com \
    --cc=m.mizuma@jp.fujitsu.com \
    --cc=util-linux@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).