diff mbox

[PATCHv4] arm64: dmi: Add SMBIOS/DMI support

Message ID 1412437603-3394-1-git-send-email-yi.li@linaro.org
State New
Headers show

Commit Message

Yi Li Oct. 4, 2014, 3:46 p.m. UTC
SMBIOS is important for server hardware vendors. It implements a spec for
providing descriptive information about the platform. Things like serial
numbers, physical layout of the ports, build configuration data, and the like.

This has been tested by dmidecode and lshw tools.

Signed-off-by: Yi Li <yi.li@linaro.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---

As Ard's suggestion, tested the patch on the kernel with/without EFI
support to boot. The bootlog and dmidecode/lshw works fine.
I will send the log with another email.

 arch/arm64/Kconfig           |   11 +++++++++++
 arch/arm64/include/asm/dmi.h |   31 +++++++++++++++++++++++++++++++
 arch/arm64/kernel/efi.c      |   14 ++++++++++++++
 3 files changed, 56 insertions(+)
 create mode 100644 arch/arm64/include/asm/dmi.h

Comments

Catalin Marinas Oct. 6, 2014, 10:40 a.m. UTC | #1
On Sat, Oct 04, 2014 at 04:46:43PM +0100, Yi Li wrote:
> SMBIOS is important for server hardware vendors. It implements a spec for
> providing descriptive information about the platform. Things like serial
> numbers, physical layout of the ports, build configuration data, and the like.
> 
> This has been tested by dmidecode and lshw tools.
> 
> Signed-off-by: Yi Li <yi.li@linaro.org>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> 
> As Ard's suggestion, tested the patch on the kernel with/without EFI
> support to boot. The bootlog and dmidecode/lshw works fine.
> I will send the log with another email.

Thanks but it's late for 3.18. We'll probably queue it later for 3.19
(hopefully it's ok this time ;)).
Leif Lindholm Jan. 17, 2015, 12:12 p.m. UTC | #2
Hi Jon,

On Sat, Jan 17, 2015 at 12:57:38AM -0500, Jon Masters wrote:
> Hi Yi Li,

Yi has gone back to work inside Huawei, so probably did not receive
your messags.

> I would like some advice on the below patch. First, a little background.
> 
> I /may/ need to use SMBIOS provided data on ARMv8 systems to enumerate
> the number of physical underlying CPU sockets present.

This sounds like a very risky precedent to set. Hardware description for
the kernel comes in the form of DT or ACPI. SMBIOS is hardware
description for userland.

x86 added internal access to SMBIOS tables to be able to work around
known-bad firmware. I would say we're in a much better place today
with regards to people actually testing hardware with Linux than when
that happened, so would really like to avoid opening those floodgates
on ARM*.

The rest of this email is therefore assuming we are talking about a
temporary out-of-tree patch kept for development purposes until a
better solution can be devised to upstream.

> This is provided
> in one Type4 DMI structure per physical socket. Using that fact (such
> data is already provided by all of the reference ARMv8 server systems),
> and a variable interpretation of the CPU affinity data, we can refactor
> the topology.c code to understand threads vs cores vs sockets without
> getting confused by the extra levels of hierarchy for clusters.
> 
> I am going back over some older patches, including this one to
> understand the DMI port, and I notice that you call dmi_scan_machine
> from an early_initcall. This will run from the init thread, after we've
> done basic SMP setup in smp_prepare_cpus, which is where we stash
> cpu_topology data, which is after I already need DMI data available.

Yep.

> So. If I wanted this available prior to early_initcall time, would it be
> reasonable to follow e.g. x86 and move this early in the boot? I'm not
> necessarily going to ask to upstream such a change (since I expect to be
> able to solve the underlying problem I am looking to address in a
> different fashion soon), but first want to know if it would be
> reasonable to ask to do that anyway.

My suggestion would be to not try to over-engineer a patch not going
upstream. Move the call before smp_prepare_cpus() in init/main.c.

Or, if you can be fairly certain your SMBIOS table is covered by the
linear mapping, move the call to setup_arch().

> P.S. I'm not interested at all in replies pointing me to the existing DT
> cpu topology binding, which I am well aware of, but it does also not
> actually solve the problem I have :)

Not going to point, but perhaps the correct answer is to ensure the
information you need is provided via DT/ACPI. As your email hints at.

/
    Leif
diff mbox

Patch

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index fd4e81a..c69ab5a 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -368,6 +368,17 @@  config EFI
 	  allow the kernel to be booted as an EFI application. This
 	  is only useful on systems that have UEFI firmware.
 
+config DMI
+	bool "Enable support for SMBIOS (DMI) tables"
+	depends on EFI
+	default y
+	help
+	  This enables SMBIOS/DMI feature for systems.
+
+	  This option is only useful on systems that have UEFI firmware.
+	  However, even with this option, the resultant kernel should
+	  continue to boot on existing non-UEFI platforms.
+
 endmenu
 
 menu "Userspace binary formats"
diff --git a/arch/arm64/include/asm/dmi.h b/arch/arm64/include/asm/dmi.h
new file mode 100644
index 0000000..69d37d8
--- /dev/null
+++ b/arch/arm64/include/asm/dmi.h
@@ -0,0 +1,31 @@ 
+/*
+ * arch/arm64/include/asm/dmi.h
+ *
+ * Copyright (C) 2013 Linaro Limited.
+ * Written by: Yi Li (yi.li@linaro.org)
+ *
+ * based on arch/ia64/include/asm/dmi.h
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#ifndef __ASM_DMI_H
+#define __ASM_DMI_H
+
+#include <linux/io.h>
+#include <linux/slab.h>
+
+/*
+ * According to section 2.3.6 of the UEFI spec, the firmware should not
+ * request a virtual mapping for configuration tables such as SMBIOS.
+ * This means we have to map them before use.
+ */
+#define dmi_early_remap(x, l)		ioremap_cache(x, l)
+#define dmi_early_unmap(x, l)		iounmap(x)
+#define dmi_remap(x, l)			ioremap_cache(x, l)
+#define dmi_unmap(x)			iounmap(x)
+#define dmi_alloc(l)			kzalloc(l, GFP_KERNEL)
+
+#endif
diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index 03aaa99..f00617f 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -11,6 +11,7 @@ 
  *
  */
 
+#include <linux/dmi.h>
 #include <linux/efi.h>
 #include <linux/export.h>
 #include <linux/memblock.h>
@@ -479,3 +480,16 @@  err_unmap:
 	return -1;
 }
 early_initcall(arm64_enter_virtual_mode);
+
+static int __init arm64_core_init(void)
+{
+/*
+ * DMI depends on EFI on arm64, and dmi_scan_machine() needs to be
+ * called early because dmi_id_init(), which is an arch_initcall itself,
+ * depends on dmi_scan_machine() having been called already.
+ */
+
+	dmi_scan_machine();
+	return 0;
+}
+core_initcall(arm64_core_init);