util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] lscpu: get more infomation when using  "/sys/firmware/dmi/entries/4-0/raw"
@ 2021-06-21 11:09 Huang Shijie
  2021-06-25  9:23 ` Karel Zak
  0 siblings, 1 reply; 4+ messages in thread
From: Huang Shijie @ 2021-06-21 11:09 UTC (permalink / raw)
  To: util-linux
  Cc: kzak, patches, zwang, mas, ilkka, jeremy.linton, jbastian,
	m.mizuma, patrick.zhang, Huang Shijie

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


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

* Re: [RFC PATCH] lscpu: get more infomation when using "/sys/firmware/dmi/entries/4-0/raw"
  2021-06-21 11:09 [RFC PATCH] lscpu: get more infomation when using "/sys/firmware/dmi/entries/4-0/raw" Huang Shijie
@ 2021-06-25  9:23 ` Karel Zak
  2021-06-25  9:33   ` Huang Shijie
  0 siblings, 1 reply; 4+ messages in thread
From: Karel Zak @ 2021-06-25  9:23 UTC (permalink / raw)
  To: Huang Shijie
  Cc: util-linux, patches, zwang, mas, ilkka, jeremy.linton, jbastian,
	m.mizuma, patrick.zhang

On Mon, Jun 21, 2021 at 11:09:00AM +0000, Huang Shijie wrote:
> 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)

I've lost in your patches :-) 

Your previous patch "[PATCH] lscpu: remove the old code" removes all
arm_smbios_decode() as it's unnecessary. This next patch tries to
extend arm_smbios_decode().

Anyway, I think it's good idea to "normalize" the model name to "%s %s CPU @ %d.%dGHz"
for all ARMs. It seems the same is suggesting:
https://github.com/karelzak/util-linux/pull/1364

 Karel


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


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

* Re: [RFC PATCH] lscpu: get more infomation when using "/sys/firmware/dmi/entries/4-0/raw"
  2021-06-25  9:23 ` Karel Zak
@ 2021-06-25  9:33   ` Huang Shijie
  2021-06-25 11:28     ` Karel Zak
  0 siblings, 1 reply; 4+ messages in thread
From: Huang Shijie @ 2021-06-25  9:33 UTC (permalink / raw)
  To: Karel Zak
  Cc: util-linux, patches, zwang, mas, ilkka, jeremy.linton, jbastian,
	m.mizuma, patrick.zhang

Hi Karel,
On Fri, Jun 25, 2021 at 11:23:01AM +0200, Karel Zak wrote:
> 
> I've lost in your patches :-) 
> 
> Your previous patch "[PATCH] lscpu: remove the old code" removes all
> arm_smbios_decode() as it's unnecessary. This next patch tries to
> extend arm_smbios_decode().
I thought you do not like the patch "[PATCH] lscpu: remove the old code".
So I sent the second patch... 

It is okay that any patch of the two is merged. :)

Thanks
Huang Shijie

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

* Re: [RFC PATCH] lscpu: get more infomation when using "/sys/firmware/dmi/entries/4-0/raw"
  2021-06-25  9:33   ` Huang Shijie
@ 2021-06-25 11:28     ` Karel Zak
  0 siblings, 0 replies; 4+ messages in thread
From: Karel Zak @ 2021-06-25 11:28 UTC (permalink / raw)
  To: Huang Shijie
  Cc: util-linux, patches, zwang, mas, ilkka, jeremy.linton, jbastian,
	m.mizuma, patrick.zhang

On Fri, Jun 25, 2021 at 05:33:11PM +0800, Huang Shijie wrote:
> Hi Karel,
> On Fri, Jun 25, 2021 at 11:23:01AM +0200, Karel Zak wrote:
> > 
> > I've lost in your patches :-) 
> > 
> > Your previous patch "[PATCH] lscpu: remove the old code" removes all
> > arm_smbios_decode() as it's unnecessary. This next patch tries to
> > extend arm_smbios_decode().
> I thought you do not like the patch "[PATCH] lscpu: remove the old code".

If I don't like anything then I provide feedback, ignore contributors
in silent way is not polite from my point of view ;-)

I've thought that jbastian and m.mizuma will provide any feedback
about /sys/firmware/dmi/entries/4-0/raw removal from lscpu.

> It is okay that any patch of the two is merged. :)

OK, removed code is a good code. So it seems the first patch is
probably a good idea.

  Karel

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


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

end of thread, other threads:[~2021-06-25 11:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21 11:09 [RFC PATCH] lscpu: get more infomation when using "/sys/firmware/dmi/entries/4-0/raw" Huang Shijie
2021-06-25  9:23 ` Karel Zak
2021-06-25  9:33   ` Huang Shijie
2021-06-25 11:28     ` Karel Zak

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