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

* Re: [PATCH v5] lscpu-arm: Add "BIOS Vendor ID" and "BIOS Model name" to show the SMBIOS information.
  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
  1 sibling, 0 replies; 5+ messages in thread
From: Karel Zak @ 2020-11-11  8:43 UTC (permalink / raw)
  To: Masayoshi Mizuma; +Cc: util-linux, jbastian, jeremy.linton, Masayoshi Mizuma

On Tue, Nov 10, 2020 at 08:24:00PM -0500, Masayoshi Mizuma wrote:
> 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(-)

OK, I'll integrate it to my new lscpu later this week. Thanks!

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


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

* Re: [PATCH v5] lscpu-arm: Add "BIOS Vendor ID" and "BIOS Model name" to show the SMBIOS information.
  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
  1 sibling, 1 reply; 5+ messages in thread
From: Karel Zak @ 2020-11-13  9:59 UTC (permalink / raw)
  To: Masayoshi Mizuma; +Cc: util-linux, jbastian, jeremy.linton, Masayoshi Mizuma

On Tue, Nov 10, 2020 at 08:24:00PM -0500, Masayoshi Mizuma wrote:
>  sys-utils/lscpu-arm.c | 22 ++++++++--------------
>  sys-utils/lscpu.c     |  4 ++++
>  sys-utils/lscpu.h     |  2 ++
>  3 files changed, 14 insertions(+), 14 deletions(-)

Ported to the new lscpu and merged. Thanks (and extra thanks for
your patience :-).

I see one issue with the stuff from BIOS. It seems it reads the
information always from the same place. How does it work if I have two
different CPUs? I guess it always return the same model name, but what
if I have Cortex-A53 and Cortex-A72 on the same board?

Maybe we should disable reading from BIOS on systems with more than
one CPU type.

  Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


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

* Re: [PATCH v5] lscpu-arm: Add "BIOS Vendor ID" and "BIOS Model name" to show the SMBIOS information.
  2020-11-13  9:59 ` Karel Zak
@ 2020-11-13 16:47   ` Masayoshi Mizuma
  2020-11-13 18:21     ` Jeffrey Bastian
  0 siblings, 1 reply; 5+ messages in thread
From: Masayoshi Mizuma @ 2020-11-13 16:47 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux, jbastian, jeremy.linton, Masayoshi Mizuma

On Fri, Nov 13, 2020 at 10:59:06AM +0100, Karel Zak wrote:
> On Tue, Nov 10, 2020 at 08:24:00PM -0500, Masayoshi Mizuma wrote:
> >  sys-utils/lscpu-arm.c | 22 ++++++++--------------
> >  sys-utils/lscpu.c     |  4 ++++
> >  sys-utils/lscpu.h     |  2 ++
> >  3 files changed, 14 insertions(+), 14 deletions(-)
> 
> Ported to the new lscpu and merged. Thanks (and extra thanks for
> your patience :-).

Thank you so much!

> 
> I see one issue with the stuff from BIOS. It seems it reads the
> information always from the same place. How does it work if I have two
> different CPUs? I guess it always return the same model name, but what
> if I have Cortex-A53 and Cortex-A72 on the same board?

The first entry, /sys/firmware/dmi/entries/4-0/raw, is only used,
so lscpu will show the same information of the SMBIOS type4 from
the entry even if the system has two diffrent cpu models, like
Cortex-A53 and Cortex-A72.
I'm not familiar with the heterogenous SoC, probably each
CPU model has own SMBIOS type4, right? for example, /sys/firmware/dmi/entries/4-0/raw
is for Cortex-A53 and /sys/firmware/dmi/entries/4-1/raw is for Cortex-A72.

> 
> Maybe we should disable reading from BIOS on systems with more than
> one CPU type.

I agree with you.

Thanks,
Masa

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

* Re: [PATCH v5] lscpu-arm: Add "BIOS Vendor ID" and "BIOS Model name" to show the SMBIOS information.
  2020-11-13 16:47   ` Masayoshi Mizuma
@ 2020-11-13 18:21     ` Jeffrey Bastian
  0 siblings, 0 replies; 5+ messages in thread
From: Jeffrey Bastian @ 2020-11-13 18:21 UTC (permalink / raw)
  To: util-linux

On Fri, Nov 13, 2020 at 11:47:05AM -0500, Masayoshi Mizuma wrote:
>On Fri, Nov 13, 2020 at 10:59:06AM +0100, Karel Zak wrote:
>> On Tue, Nov 10, 2020 at 08:24:00PM -0500, Masayoshi Mizuma wrote:
>> >  sys-utils/lscpu-arm.c | 22 ++++++++--------------
>> >  sys-utils/lscpu.c     |  4 ++++
>> >  sys-utils/lscpu.h     |  2 ++
>> >  3 files changed, 14 insertions(+), 14 deletions(-)
>>
>> Ported to the new lscpu and merged. Thanks (and extra thanks for
>> your patience :-).
>
>Thank you so much!
>
>>
>> I see one issue with the stuff from BIOS. It seems it reads the
>> information always from the same place. How does it work if I have two
>> different CPUs? I guess it always return the same model name, but what
>> if I have Cortex-A53 and Cortex-A72 on the same board?
>
>The first entry, /sys/firmware/dmi/entries/4-0/raw, is only used,
>so lscpu will show the same information of the SMBIOS type4 from
>the entry even if the system has two diffrent cpu models, like
>Cortex-A53 and Cortex-A72.
>I'm not familiar with the heterogenous SoC, probably each
>CPU model has own SMBIOS type4, right? for example, /sys/firmware/dmi/entries/4-0/raw
>is for Cortex-A53 and /sys/firmware/dmi/entries/4-1/raw is for Cortex-A72.

That's correct: there will be a 4-x/raw file for each CPU type.  So far
it's been safe to assume that all CPUs are the same in a system, but
with ARM big.LITTLE, that's no longer a safe assumption.  It will take a
bit more work to associate each SMBIOS entry with each CPU in
/proc/cpuinfo.

https://en.wikipedia.org/wiki/ARM_big.LITTLE


-- 
Jeff Bastian
Kernel QE - Hardware Enablement
Red Hat


^ permalink raw reply	[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).