All of lore.kernel.org
 help / color / mirror / Atom feed
From: Huang Shijie <shijie@os.amperecomputing.com>
To: util-linux@vger.kernel.org
Cc: kzak@redhat.com, patches@amperecomputing.com,
	zwang@amperecomputing.com, mas@amperecomputing.com,
	ilkka@os.amperecomputing.com, jeremy.linton@arm.com,
	jbastian@redhat.com, m.mizuma@jp.fujitsu.com,
	patrick.zhang@amperecomputing.com,
	Huang Shijie <shijie@os.amperecomputing.com>
Subject: [PATCH] lscpu: remove the old code
Date: Thu, 17 Jun 2021 12:41:16 +0000	[thread overview]
Message-ID: <20210617124116.6841-1-shijie@os.amperecomputing.com> (raw)

The file "/sys/firmware/dmi/tables/DMI" always exists.

The dmi_decode_cputype() can provide more information then arm_smbios_decode().
So remove it to tidy the code.

Before this patch, we can get the output from Centos 7.9 who has
"/sys/firmware/dmi/entries/4-0/raw" and "/sys/firmware/dmi/tables/DMI":
  ----------------------------------------------------
  BIOS Vendor ID:                  Ampere(TM)
  Model name:                     Neoverse-N1
    BIOS Model name:               Ampere(TM) Altra(TM) Processor
  ----------------------------------------------------

 After this patch which uses "/sys/firmware/dmi/tables/DMI", 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
    BIOS CPU family:               257
  ----------------------------------------------------

Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
---
 sys-utils/lscpu-arm.c | 46 +------------------------------------------
 sys-utils/lscpu.h     |  1 -
 2 files changed, 1 insertion(+), 46 deletions(-)

diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c
index 885aadc36..d52765f9d 100644
--- a/sys-utils/lscpu-arm.c
+++ b/sys-utils/lscpu-arm.c
@@ -315,53 +315,9 @@ static int arm_rXpY_decode(struct lscpu_cputype *ct)
 	return 0;
 }
 
-#define PROC_MFR_OFFSET		0x07
-#define PROC_VERSION_OFFSET	0x10
-
-/*
- * Use firmware to get human readable names
- */
-static int arm_smbios_decode(struct lscpu_cputype *ct)
-{
-	uint8_t data[8192];
-	char buf[128], *str;
-	struct lscpu_dmi_header h;
-	int fd;
-	ssize_t rs;
-
-	fd = open(_PATH_SYS_DMI_TYPE4, O_RDONLY);
-	if (fd < 0)
-		return fd;
-
-	rs = read_all(fd, (char *) data, 8192);
-	close(fd);
-
-	if (rs == -1)
-		return -1;
-
-	to_dmi_header(&h, data);
-
-	str = dmi_string(&h, data[PROC_MFR_OFFSET]);
-	if (str) {
-		xstrncpy(buf, str, 127);
-		ct->bios_vendor = xstrdup(buf);
-	}
-
-	str = dmi_string(&h, data[PROC_VERSION_OFFSET]);
-	if (str) {
-		xstrncpy(buf, str, 127);
-		ct->bios_modelname = xstrdup(buf);
-	}
-
-	return 0;
-}
-
 static void arm_decode(struct lscpu_cxt *cxt, struct lscpu_cputype *ct)
 {
-	/* use SMBIOS Type 4 data if available */
-	if (!cxt->noalive && access(_PATH_SYS_DMI_TYPE4, R_OK) == 0)
-		arm_smbios_decode(ct);
-	else if (!cxt->noalive && access(_PATH_SYS_DMI, R_OK) == 0)
+	if (!cxt->noalive && access(_PATH_SYS_DMI, R_OK) == 0)
 		dmi_decode_cputype(ct);
 
 	arm_ids_decode(ct);
diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h
index 79477b469..8cb0d630c 100644
--- a/sys-utils/lscpu.h
+++ b/sys-utils/lscpu.h
@@ -32,7 +32,6 @@ UL_DEBUG_DECLARE_MASK(lscpu);
 #define _PATH_SYS_CPU		_PATH_SYS_SYSTEM "/cpu"
 #define _PATH_SYS_NODE		_PATH_SYS_SYSTEM "/node"
 #define _PATH_SYS_DMI		"/sys/firmware/dmi/tables/DMI"
-#define _PATH_SYS_DMI_TYPE4	"/sys/firmware/dmi/entries/4-0/raw"
 #define _PATH_ACPI_PPTT		"/sys/firmware/acpi/tables/PPTT"
 
 struct lscpu_cache {
-- 
2.30.2


             reply	other threads:[~2021-06-17  4:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17 12:41 Huang Shijie [this message]
2021-06-30  9:28 ` [PATCH] lscpu: remove the old code Karel Zak

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=20210617124116.6841-1-shijie@os.amperecomputing.com \
    --to=shijie@os.amperecomputing.com \
    --cc=ilkka@os.amperecomputing.com \
    --cc=jbastian@redhat.com \
    --cc=jeremy.linton@arm.com \
    --cc=kzak@redhat.com \
    --cc=m.mizuma@jp.fujitsu.com \
    --cc=mas@amperecomputing.com \
    --cc=patches@amperecomputing.com \
    --cc=patrick.zhang@amperecomputing.com \
    --cc=util-linux@vger.kernel.org \
    --cc=zwang@amperecomputing.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.