lscpu-arm: Set the order to search the model name
PATCH v3 1/2 lscpu-arm: Set the order to search the model name
From: Masayoshi Mizuma <[email protected]>
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.
The SMBIOS info would be great if the system is based on SBBR v1.2E and BBR v1.0 because the specs require the Processor Version of SMBIOS as "This field must provide a human readable description of the processor part number".
However, it's not good for the systems aren't based on the specs, like A64FX. Such systems need to have the model name to the hard corded table.
Let's set the order; first, search the hard corded table, then SMBIOS.
--- sys-utils/lscpu-arm.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-)
sys-utils/lscpu-arm.c +16 -13
@@ -288,6 +288,7 @@ static int __arm_cpu_smbios(struct lscpu_desc *desc)struct lscpu_dmi_header h;int fd;ssize_t rs; +int use_smbios =0 ; fd =open (_PATH_SYS_DMI_TYPE4,O_RDONLY );if (fd <0 )
@@ -301,16 +302,21 @@ static int __arm_cpu_smbios(struct lscpu_desc *desc)to_dmi_header (&h, data); - str =dmi_string (&h, data[PROC_MFR_OFFSET ]); -if (str) { -xstrncpy (buf, str,127 ); - desc->vendor =xstrdup (buf); +if (!desc->modelname) { + str =dmi_string (&h, data[PROC_VERSION_OFFSET ]); +if (str) { +xstrncpy (buf, str,127 ); + desc->modelname =xstrdup (buf); + use_smbios =1 ; + } } - str =dmi_string (&h, data[PROC_VERSION_OFFSET ]); -if (str) { -xstrncpy (buf, str,127 ); - desc->modelname =xstrdup (buf); +if ((startswith (desc->vendor,"0x" )) || use_smbios) { + str =dmi_string (&h, data[PROC_MFR_OFFSET ]); +if (str) { +xstrncpy (buf, str,127 ); + desc->vendor =xstrdup (buf); + } }return 0 ;
@@ -318,14 +324,11 @@ static int __arm_cpu_smbios(struct lscpu_desc *desc)void arm_cpu_decode (struct lscpu_desc *desc,struct lscpu_modifier *mod) { -int rc =-1 ; +__arm_cpu_decode (desc);/* use SMBIOS Type 4 data if available, * else fall back to manual decoding using the tables above */ if (mod->system ==SYSTEM_LIVE &&access (_PATH_SYS_DMI_TYPE4,R_OK ) ==0 ) - rc =__arm_cpu_smbios (desc); - -if (rc) -__arm_cpu_decode (desc); +__arm_cpu_smbios (desc); }
Signature · 1 line
2.27.0
PATCH v3 2/2 lscpu-arm: Remove hard corded model name of Cortex family and X-Gene
From: Masayoshi Mizuma <[email protected]>
Remove hard corded model name of Cortex family and X-Gene so that lscpu can show the model name using Processor Version of SMBIOS Type4.
--- sys-utils/lscpu-arm.c | 32 -------------------------------- 1 file changed, 32 deletions(-)
sys-utils/lscpu-arm.c +0 -32
@@ -53,37 +53,6 @@ static const struct id_part arm_part[] = { { 0xb36, "ARM1136" }, { 0xb56, "ARM1156" }, { 0xb76, "ARM1176" }, - { 0xc05, "Cortex-A5" }, - { 0xc07, "Cortex-A7" }, - { 0xc08, "Cortex-A8" }, - { 0xc09, "Cortex-A9" }, - { 0xc0d, "Cortex-A17" }, /* Originally A12 */ - { 0xc0f, "Cortex-A15" }, - { 0xc0e, "Cortex-A17" }, - { 0xc14, "Cortex-R4" }, - { 0xc15, "Cortex-R5" }, - { 0xc17, "Cortex-R7" }, - { 0xc18, "Cortex-R8" }, - { 0xc20, "Cortex-M0" }, - { 0xc21, "Cortex-M1" }, - { 0xc23, "Cortex-M3" }, - { 0xc24, "Cortex-M4" }, - { 0xc27, "Cortex-M7" }, - { 0xc60, "Cortex-M0+" }, - { 0xd01, "Cortex-A32" }, - { 0xd03, "Cortex-A53" }, - { 0xd04, "Cortex-A35" }, - { 0xd05, "Cortex-A55" }, - { 0xd07, "Cortex-A57" }, - { 0xd08, "Cortex-A72" }, - { 0xd09, "Cortex-A73" }, - { 0xd0a, "Cortex-A75" }, - { 0xd0b, "Cortex-A76" }, - { 0xd0c, "Neoverse-N1" }, - { 0xd13, "Cortex-R52" }, - { 0xd20, "Cortex-M23" }, - { 0xd21, "Cortex-M33" }, - { 0xd4a, "Neoverse-E1" }, { -1, "unknown" }, };
@@ -110,7 +79,6 @@ static const struct id_part cavium_part[] = { };static const struct id_part apm_part[] = { - {0x000 ,"X-Gene" }, {-1 ,"unknown" }, };
Signature · 1 line
2.27.0
Oops... I forgot to add Signed-off. Will resend them soon. Sorry about that.
Quoted 86 lines · Masayoshi Mizuma
From: Masayoshi Mizuma <[email protected]>
After commit:
367c85c47("lscpu: use SMBIOS tables on ARM for lscpu"), Model name for A64FX shows like as:Model name: 461F0010That's because
367c85c47changes to get the modelname from Processor Version of SMBIOS.The SMBIOS info would be great if the system is based on SBBR v1.2E and BBR v1.0 because the specs require the Processor Version of SMBIOS as "This field must provide a human readable description of the processor part number".
However, it's not good for the systems aren't based on the specs, like A64FX. Such systems need to have the model name to the hard corded table.
Let's set the order; first, search the hard corded table, then SMBIOS.
--- sys-utils/lscpu-arm.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-)sys-utils/lscpu-arm.c +16
-13@@ -288,6 +288,7 @@ static int __arm_cpu_smbios(struct lscpu_desc *desc)struct lscpu_dmi_header h;int fd;ssize_t rs; +int use_smbios =0 ; fd =open (_PATH_SYS_DMI_TYPE4,O_RDONLY );if (fd <0 )@@ -301,16 +302,21 @@ static int __arm_cpu_smbios(struct lscpu_desc *desc)to_dmi_header (&h, data); - str =dmi_string (&h, data[PROC_MFR_OFFSET ]); -if (str) { -xstrncpy (buf, str,127 ); - desc->vendor =xstrdup (buf); +if (!desc->modelname) { + str =dmi_string (&h, data[PROC_VERSION_OFFSET ]); +if (str) { +xstrncpy (buf, str,127 ); + desc->modelname =xstrdup (buf); + use_smbios =1 ; + } } - str =dmi_string (&h, data[PROC_VERSION_OFFSET ]); -if (str) { -xstrncpy (buf, str,127 ); - desc->modelname =xstrdup (buf); +if ((startswith (desc->vendor,"0x" )) || use_smbios) { + str =dmi_string (&h, data[PROC_MFR_OFFSET ]); +if (str) { +xstrncpy (buf, str,127 ); + desc->vendor =xstrdup (buf); + } }return 0 ;@@ -318,14 +324,11 @@ static int __arm_cpu_smbios(struct lscpu_desc *desc)void arm_cpu_decode (struct lscpu_desc *desc,struct lscpu_modifier *mod) { -int rc =-1 ; +__arm_cpu_decode (desc);/* use SMBIOS Type 4 data if available, * else fall back to manual decoding using the tables above */ if (mod->system ==SYSTEM_LIVE &&access (_PATH_SYS_DMI_TYPE4,R_OK ) ==0 ) - rc =__arm_cpu_smbios (desc); - -if (rc) -__arm_cpu_decode (desc); +__arm_cpu_smbios (desc); }Signature · 1 line
2.27.0