util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5] lscpu-arm: Add "BIOS Vendor ID" and "BIOS Model name" to show the SMBIOS information.
@ 2020-11-11  1:24 Masayoshi Mizuma
  2020-11-11  8:43 ` Karel Zak
  2020-11-13  9:59 ` Karel Zak
  0 siblings, 2 replies; 5+ messages in thread
From: Masayoshi Mizuma @ 2020-11-11  1:24 UTC (permalink / raw)
  To: util-linux, jbastian, jeremy.linton; +Cc: Masayoshi Mizuma, Masayoshi Mizuma

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-13 18:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11  1:24 [PATCH v5] lscpu-arm: Add "BIOS Vendor ID" and "BIOS Model name" to show the SMBIOS information Masayoshi Mizuma
2020-11-11  8:43 ` Karel Zak
2020-11-13  9:59 ` Karel Zak
2020-11-13 16:47   ` Masayoshi Mizuma
2020-11-13 18:21     ` Jeffrey Bastian

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).