Skip to contentSkip to conversation

DMI: log system, BIOS, and board information

PATCH Superseded Bjorn Helgaas 2 participants 5 messages Sep 30, 2010 – Oct 5, 2010 Dmi/smbios support

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 DMI: log system, BIOS, and board information

Put basic system information in the dmesg log. There are lots of dmesg logs on the web, and it would be useful if they contained this information for debugging platform problems.

---

 drivers/firmware/dmi_scan.c |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)
drivers/firmware/dmi_scan.c +34 -1
index b3d22d6..d625e53 100644
@@ -2,6 +2,7 @@
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/ctype.h>
 #include <linux/dmi.h>
 #include <linux/efi.h>
 #include <linux/bootmem.h>
@@ -361,6 +362,36 @@ static void __init dmi_decode(const struct dmi_header *dm, void *dummy)
 	}
 }
 
+static const char * __init dmi_printable_system_info(int field)
+{
+	const char *info, *p;
+
+	info = dmi_get_system_info(field);
+	if (!info)
+		return NULL;
+
+	for (p = info; *p; p++)
+		if (!isprint(*p))
+			return "<...>";
+
+	return info;
+}
+
+static void __init dmi_dump_ids(void)
+{
+	const char *board;
+
+	printk(KERN_DEBUG "DMI: system: %s %s",
+	       dmi_printable_system_info(DMI_SYS_VENDOR),
+	       dmi_printable_system_info(DMI_PRODUCT_NAME));
+	board = dmi_printable_system_info(DMI_BOARD_NAME);
+	if (board)
+		printk(KERN_CONT " (%s board)", board);
+	printk(KERN_CONT ", BIOS: %s %s\n",
+	       dmi_printable_system_info(DMI_BIOS_VERSION),
+	       dmi_printable_system_info(DMI_BIOS_DATE));
+}
+
 static int __init dmi_present(const char __iomem *p)
 {
 	u8 buf[15];
@@ -381,8 +412,10 @@ static int __init dmi_present(const char __iomem *p)
 			       buf[14] >> 4, buf[14] & 0xF);
 		else
 			printk(KERN_INFO "DMI present.\n");
-		if (dmi_walk_early(dmi_decode) == 0)
+		if (dmi_walk_early(dmi_decode) == 0) {
+			dmi_dump_ids();
 			return 0;
+		}
 	}
 	return 1;
 }
#1 lore raw
Quoted 32 lines · On Thu, 30 Sep 2010 10:49:05 -0600 Bjorn Helgaas <[email protected]> wrote:

Put basic system information in the dmesg log. There are lots of dmesg logs on the web, and it would be useful if they contained this information for debugging platform problems.

---

 drivers/firmware/dmi_scan.c |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)
drivers/firmware/dmi_scan.c +5 -0
index b3d22d6..d625e53 100644
@@ -2,6 +2,7 @@
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/ctype.h>
 #include <linux/dmi.h>
 #include <linux/efi.h>
 #include <linux/bootmem.h>
@@ -361,6 +362,36 @@ static void __init dmi_decode(const struct dmi_header *dm, void *dummy)
 	}
 }
 
+static const char * __init dmi_printable_system_info(int field)
+{
+	const char *info, *p;
+

drivers/firmware/dmi_scan.c static void __init dmi_decode(const struct dmi_header *dm, void *dummy) · line 378

Quoted 10 lines
drivers/firmware/dmi_scan.c +10 -0
+	info = dmi_get_system_info(field);
+	if (!info)
+		return NULL;
+
+	for (p = info; *p; p++)
+		if (!isprint(*p))
+			return "<...>";
+
+	return info;
+}

So if the string contains any non-printable character, we suppress the whole string.

Is that the best thing to do? Would it be better to present the oddball character as \xNN or such?

Quoted 30 lines
drivers/firmware/dmi_scan.c +18 -1
+static void __init dmi_dump_ids(void)
+{
+	const char *board;
+
+	printk(KERN_DEBUG "DMI: system: %s %s",
+	       dmi_printable_system_info(DMI_SYS_VENDOR),
+	       dmi_printable_system_info(DMI_PRODUCT_NAME));
+	board = dmi_printable_system_info(DMI_BOARD_NAME);
+	if (board)
+		printk(KERN_CONT " (%s board)", board);
+	printk(KERN_CONT ", BIOS: %s %s\n",
+	       dmi_printable_system_info(DMI_BIOS_VERSION),
+	       dmi_printable_system_info(DMI_BIOS_DATE));
+}
+
 static int __init dmi_present(const char __iomem *p)
 {
 	u8 buf[15];
@@ -381,8 +412,10 @@ static int __init dmi_present(const char __iomem *p)
 			       buf[14] >> 4, buf[14] & 0xF);
 		else
 			printk(KERN_INFO "DMI present.\n");
-		if (dmi_walk_early(dmi_decode) == 0)
+		if (dmi_walk_early(dmi_decode) == 0) {
+			dmi_dump_ids();
 			return 0;
+		}
 	}
 	return 1;
 }
#2 lore raw
Quoted 49 lines · Andrew Morton
Quoted 32 lines · On Thu, 30 Sep 2010 10:49:05 -0600 Bjorn Helgaas <[email protected]> wrote:

Put basic system information in the dmesg log. There are lots of dmesg logs on the web, and it would be useful if they contained this information for debugging platform problems.

---

 drivers/firmware/dmi_scan.c |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)
drivers/firmware/dmi_scan.c +5 -0
index b3d22d6..d625e53 100644
@@ -2,6 +2,7 @@
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/ctype.h>
 #include <linux/dmi.h>
 #include <linux/efi.h>
 #include <linux/bootmem.h>
@@ -361,6 +362,36 @@ static void __init dmi_decode(const struct dmi_header *dm, void *dummy)
 	}
 }
 
+static const char * __init dmi_printable_system_info(int field)
+{
+	const char *info, *p;
+

drivers/firmware/dmi_scan.c static void __init dmi_decode(const struct dmi_header *dm, void *dummy) · line 378

Quoted 10 lines
drivers/firmware/dmi_scan.c +10 -0
+	info = dmi_get_system_info(field);
+	if (!info)
+		return NULL;
+
+	for (p = info; *p; p++)
+		if (!isprint(*p))
+			return "<...>";
+
+	return info;
+}

So if the string contains any non-printable character, we suppress the whole string.

Quoted 2 lines

Is that the best thing to do? Would it be better to present the oddball character as \xNN or such?

I would definitely prefer to do that, but that would mean allocating memory, and this happens so early that it looked like it would be more trouble than it's worth. I'm not saying I couldn't be convinced, though.

Bjorn

#3 lore raw
Quoted 50 lines · On Mon, 4 Oct 2010 20:45:29 -0600 Bjorn Helgaas <[email protected]> wrote:
Quoted 49 lines · Andrew Morton
Quoted 32 lines · On Thu, 30 Sep 2010 10:49:05 -0600 Bjorn Helgaas <[email protected]> wrote:

Put basic system information in the dmesg log. There are lots of dmesg logs on the web, and it would be useful if they contained this information for debugging platform problems.

---

 drivers/firmware/dmi_scan.c |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)
drivers/firmware/dmi_scan.c +5 -0
index b3d22d6..d625e53 100644
@@ -2,6 +2,7 @@
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/ctype.h>
 #include <linux/dmi.h>
 #include <linux/efi.h>
 #include <linux/bootmem.h>
@@ -361,6 +362,36 @@ static void __init dmi_decode(const struct dmi_header *dm, void *dummy)
 	}
 }
 
+static const char * __init dmi_printable_system_info(int field)
+{
+	const char *info, *p;
+

drivers/firmware/dmi_scan.c static void __init dmi_decode(const struct dmi_header *dm, void *dummy) · line 378

Quoted 10 lines
drivers/firmware/dmi_scan.c +10 -0
+	info = dmi_get_system_info(field);
+	if (!info)
+		return NULL;
+
+	for (p = info; *p; p++)
+		if (!isprint(*p))
+			return "<...>";
+
+	return info;
+}

So if the string contains any non-printable character, we suppress the whole string.

Quoted 7 lines
Quoted 2 lines

Is that the best thing to do? Would it be better to present the oddball character as \xNN or such?

I would definitely prefer to do that, but that would mean allocating memory, and this happens so early that it looked like it would be more trouble than it's worth. I'm not saying I couldn't be convinced, though.

Well, one could print the data one char at a time. If we're running early in boot with a single CPU up then that wouldn't make too big a mess.

Is there some upper bound to the length of a DMI string? If so, use a static initdata buffer dimensioned to 4x that?

#4 lore raw
Quoted 60 lines · Andrew Morton
Quoted 50 lines · On Mon, 4 Oct 2010 20:45:29 -0600 Bjorn Helgaas <[email protected]> wrote:
Quoted 49 lines · Andrew Morton
Quoted 32 lines · On Thu, 30 Sep 2010 10:49:05 -0600 Bjorn Helgaas <[email protected]> wrote:

Put basic system information in the dmesg log. There are lots of dmesg logs on the web, and it would be useful if they contained this information for debugging platform problems.

---

 drivers/firmware/dmi_scan.c |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)
drivers/firmware/dmi_scan.c +5 -0
index b3d22d6..d625e53 100644
@@ -2,6 +2,7 @@
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/ctype.h>
 #include <linux/dmi.h>
 #include <linux/efi.h>
 #include <linux/bootmem.h>
@@ -361,6 +362,36 @@ static void __init dmi_decode(const struct dmi_header *dm, void *dummy)
 	}
 }
 
+static const char * __init dmi_printable_system_info(int field)
+{
+	const char *info, *p;
+

drivers/firmware/dmi_scan.c static void __init dmi_decode(const struct dmi_header *dm, void *dummy) · line 378

Quoted 10 lines
drivers/firmware/dmi_scan.c +10 -0
+	info = dmi_get_system_info(field);
+	if (!info)
+		return NULL;
+
+	for (p = info; *p; p++)
+		if (!isprint(*p))
+			return "<...>";
+
+	return info;
+}

So if the string contains any non-printable character, we suppress the whole string.

Quoted 7 lines
Quoted 2 lines

Is that the best thing to do? Would it be better to present the oddball character as \xNN or such?

I would definitely prefer to do that, but that would mean allocating memory, and this happens so early that it looked like it would be more trouble than it's worth. I'm not saying I couldn't be convinced, though.

Quoted 6 lines

Well, one could print the data one char at a time. If we're running early in boot with a single CPU up then that wouldn't make too big a mess.

Is there some upper bound to the length of a DMI string? If so, use a static initdata buffer dimensioned to 4x that?

Yeah, good ideas. I'll push on that a little bit more.

Bjorn