Skip to content

Commit d6ecd18

Browse files
xiaobo55xpalmer-dabbelt
authored andcommitted
riscv: dmi: Add SMBIOS/DMI support
Enable the dmi driver for riscv which would allow access the SMBIOS info through some userspace file(/sys/firmware/dmi/*). The change was based on that of arm64 and has been verified by dmidecode tool. Signed-off-by: Haibo Xu <[email protected]> Reviewed-by: Ard Biesheuvel <[email protected]> Reviewed-by: Atish Patra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 50b5bae commit d6ecd18

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

arch/riscv/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,17 @@ config EFI
967967
allow the kernel to be booted as an EFI application. This
968968
is only useful on systems that have UEFI firmware.
969969

970+
config DMI
971+
bool "Enable support for SMBIOS (DMI) tables"
972+
depends on EFI
973+
default y
974+
help
975+
This enables SMBIOS/DMI feature for systems.
976+
977+
This option is only useful on systems that have UEFI firmware.
978+
However, even with this option, the resultant kernel should
979+
continue to boot on existing non-UEFI platforms.
980+
970981
config CC_HAVE_STACKPROTECTOR_TLS
971982
def_bool $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=tp -mstack-protector-guard-offset=0)
972983

arch/riscv/include/asm/dmi.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (C) 2024 Intel Corporation
4+
*
5+
* based on arch/arm64/include/asm/dmi.h
6+
*
7+
* This file is subject to the terms and conditions of the GNU General Public
8+
* License. See the file "COPYING" in the main directory of this archive
9+
* for more details.
10+
*/
11+
12+
#ifndef __ASM_DMI_H
13+
#define __ASM_DMI_H
14+
15+
#include <linux/io.h>
16+
#include <linux/slab.h>
17+
18+
#define dmi_early_remap(x, l) memremap(x, l, MEMREMAP_WB)
19+
#define dmi_early_unmap(x, l) memunmap(x)
20+
#define dmi_remap(x, l) memremap(x, l, MEMREMAP_WB)
21+
#define dmi_unmap(x) memunmap(x)
22+
#define dmi_alloc(l) kzalloc(l, GFP_KERNEL)
23+
24+
#endif

drivers/firmware/efi/riscv-runtime.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,16 @@ void arch_efi_call_virt_teardown(void)
152152
{
153153
efi_virtmap_unload();
154154
}
155+
156+
static int __init riscv_dmi_init(void)
157+
{
158+
/*
159+
* On riscv, DMI depends on UEFI, and dmi_setup() needs to
160+
* be called early because dmi_id_init(), which is an arch_initcall
161+
* itself, depends on dmi_scan_machine() having been called already.
162+
*/
163+
dmi_setup();
164+
165+
return 0;
166+
}
167+
core_initcall(riscv_dmi_init);

0 commit comments

Comments
 (0)