From nobody Sun Feb 8 18:31:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8891EB64DA for ; Wed, 5 Jul 2023 11:45:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231561AbjGELpO (ORCPT ); Wed, 5 Jul 2023 07:45:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231177AbjGELpL (ORCPT ); Wed, 5 Jul 2023 07:45:11 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39A39172D for ; Wed, 5 Jul 2023 04:44:46 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3942c6584f0so4537431b6e.3 for ; Wed, 05 Jul 2023 04:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1688557485; x=1691149485; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=t2wHvvnZ9EXs4kZ7PH7ZQmrp8wDzjYqwhR8Lb7Z2dm0=; b=jVG4zai1xG7MtgnncuyhuPAqUUpjFnE9G3irewRE18y6iFyE/sSIGF23/BN9GqjedI zyE5d5WvPIsC2FoCMXz6YBxr+JP9d4N15NZq5ymkBEZQ9f5R/eqSfpU/6bJ9wyhWX0GY CZn7coRHhPZm1IRexWWv9LxGNpN/kk927lkfVslnarGWO0nM7CTFWJ6ITIo3KHTUnDnf FykR8jIUlH6tBDEJwoMXPppRQhPKve5atGYBKA4SFBp23WeY7rXeoIGbL2Lfb9ToKbu8 gEhKKIYhaaWc9JldVwFllp+Ar8BmfPkSiuuXdmcH5Dd5lugkgvKVkJ8u7MiK/YyWjCVd zxew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688557485; x=1691149485; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t2wHvvnZ9EXs4kZ7PH7ZQmrp8wDzjYqwhR8Lb7Z2dm0=; b=lOxLoijUhIDQzwxq3gx+E1QQnxy5IAkFP4WjIhakDIRsaQ6vNNOQfJTMFjHmOFNBDq eNM2wqsLQ6r2ULpWX4Iw8apuus613y82w/xSYyIO9xHVlLB/35cueAFfodryCbCfk57K HfkeomG7Lwz4YBgjhyO0/+Kkli+KkHO+VVPSyKwwkNbmdZTn4FUSX7Cc0NqofAAXSYBE vB1D7XWkSHymWkFcSc5v1o6MAMh/ltZRwo42PGMEah90sDuGaJo1fGvqTzQ0aSETywkx EEYEulJQ+2F6AK2smUpHO0Cm1xVrNTceN+KSEF3XvOtjNwZuI+nVBfNU+jgw8b037M/V ORHA== X-Gm-Message-State: AC+VfDy4N0v0x1WseaoLnpLRjwMmvd+1xjG+nh5z/7Njox4VXr0k9Hk4 I66n4lEhBWukWep4skqUwe8TSA== X-Google-Smtp-Source: ACHHUZ4ap87VDxLx6PJqpSNbm9olTnoBIzaTi9rOfKW8IJ4lqYlS+3MO2AfgOPiU74NZ5qWJSAcOSw== X-Received: by 2002:a05:6808:197:b0:39e:ffc5:c450 with SMTP id w23-20020a056808019700b0039effc5c450mr15121527oic.47.1688557485518; Wed, 05 Jul 2023 04:44:45 -0700 (PDT) Received: from PF2E59YH-BKX.inc.bytedance.com ([61.213.176.5]) by smtp.gmail.com with ESMTPSA id 3-20020a17090a194300b00263f6687690sm1177900pjh.18.2023.07.05.04.44.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 04:44:45 -0700 (PDT) From: Yunhui Cui To: conor@kernel.org, sunilvl@ventanamicro.com, ardb@kernel.org, palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, rminnich@gmail.com, mark.rutland@arm.com, lpieralisi@kernel.org, rafael@kernel.org, lenb@kernel.org, jdelvare@suse.com, yc.hung@mediatek.com, angelogioacchino.delregno@collabora.com, allen-kh.cheng@mediatek.com, pierre-louis.bossart@linux.intel.com, tinghan.shen@mediatek.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, geshijian@bytedance.com, weidong.wd@bytedance.com, cuiyunhui@bytedance.com Subject: [PATCH v3 1/4] riscv: obtain ACPI RSDP from devicetree Date: Wed, 5 Jul 2023 19:42:48 +0800 Message-Id: <20230705114251.661-2-cuiyunhui@bytedance.com> X-Mailer: git-send-email 2.37.3.windows.1 In-Reply-To: <20230705114251.661-1-cuiyunhui@bytedance.com> References: <20230705114251.661-1-cuiyunhui@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On RISC-V, Coreboot does not support booting using EFI, only devicetree nor does RISC-V have a reserved address segment. To allow using Coreboot on platforms that require ACPI, the ACPI RSDP needs to be passed to supervisor mode software using devicetree. Add support for parsing the "ffitbl" devicetree node to find the ACPI entry point and use wire up acpi_arch_get_root_pointer(). This feature is known as FDT Firmware Interface (FFI). Signed-off-by: Yunhui Cui --- MAINTAINERS | 6 ++++++ arch/riscv/include/asm/acpi.h | 9 +++++++++ arch/riscv/include/asm/ffi.h | 14 +++++++++++++ arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/ffi.c | 38 +++++++++++++++++++++++++++++++++++ arch/riscv/kernel/setup.c | 2 ++ 6 files changed, 70 insertions(+) create mode 100644 arch/riscv/include/asm/ffi.h create mode 100644 arch/riscv/kernel/ffi.c diff --git a/MAINTAINERS b/MAINTAINERS index cd5388a33410..e592f489e757 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18363,6 +18363,12 @@ F: arch/riscv/boot/dts/ X: arch/riscv/boot/dts/allwinner/ X: arch/riscv/boot/dts/renesas/ =20 +RISC-V FDT FIRMWARE INTERFACE (FFI) SUPPORT +M: Yunhui Cui cuiyunhui@bytedance.com +S: Maintained +F: arch/riscv/include/asm/ffi.h +F: arch/riscv/kernel/ffi.c + RISC-V PMU DRIVERS M: Atish Patra R: Anup Patel diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h index f71ce21ff684..5574f9a152f5 100644 --- a/arch/riscv/include/asm/acpi.h +++ b/arch/riscv/include/asm/acpi.h @@ -15,6 +15,8 @@ /* Basic configuration for ACPI */ #ifdef CONFIG_ACPI =20 +#include + typedef u64 phys_cpuid_t; #define PHYS_CPUID_INVALID INVALID_HARTID =20 @@ -66,6 +68,13 @@ int acpi_get_riscv_isa(struct acpi_table_header *table, unsigned int cpu, const char **isa); =20 static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NOD= E; } + +#define ACPI_HAVE_ARCH_GET_ROOT_POINTER +static inline u64 acpi_arch_get_root_pointer(void) +{ + return riscv_acpi_rsdp(); +} + #else static inline void acpi_init_rintc_map(void) { } static inline struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu) diff --git a/arch/riscv/include/asm/ffi.h b/arch/riscv/include/asm/ffi.h new file mode 100644 index 000000000000..d5e8309cc06f --- /dev/null +++ b/arch/riscv/include/asm/ffi.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _ASM_FFI_H +#define _ASM_FFI_H + +#ifdef CONFIG_FDT_FW_INTERFACE +extern void ffi_init(void); +extern u64 riscv_acpi_rsdp(void); +#else +#define ffi_init() +static inline u64 riscv_acpi_rsdp(void) { return 0; } +#endif + +#endif /* _ASM_FFI_H */ diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index 506cc4a9a45a..71831cf7f934 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -92,6 +92,7 @@ obj-$(CONFIG_CRASH_CORE) +=3D crash_core.o obj-$(CONFIG_JUMP_LABEL) +=3D jump_label.o =20 obj-$(CONFIG_EFI) +=3D efi.o +obj-$(CONFIG_FDT_FW_INTERFACE) +=3D ffi.o obj-$(CONFIG_COMPAT) +=3D compat_syscall_table.o obj-$(CONFIG_COMPAT) +=3D compat_signal.o obj-$(CONFIG_COMPAT) +=3D compat_vdso/ diff --git a/arch/riscv/kernel/ffi.c b/arch/riscv/kernel/ffi.c new file mode 100644 index 000000000000..147d06a5acff --- /dev/null +++ b/arch/riscv/kernel/ffi.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * ffi.c - FDT FIRMWARE INTERFACE + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include + +static u64 acpi_rsdp; + +void __init ffi_acpi_root_pointer(void) +{ + u32 ffitbl, acpi, len; + fdt64_t *prop; + + ffitbl =3D fdt_subnode_offset(initial_boot_params, 0, "ffitbl"); + acpi =3D fdt_subnode_offset(initial_boot_params, ffitbl, "acpi"); + prop =3D fdt_getprop_w(initial_boot_params, acpi, "entry", &len); + if (!prop || len !=3D sizeof(u64)) { + pr_debug("acpi rsdp not found.\n"); + return; + } + acpi_rsdp =3D fdt64_to_cpu(*prop); + pr_debug("acpi rsdp: %llx\n", acpi_rsdp); +} + +u64 __init riscv_acpi_rsdp(void) +{ + return acpi_rsdp; +} + +void __init ffi_init(void) +{ + ffi_acpi_root_pointer(); +} diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index 971fe776e2f8..5a933d6b6acb 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -36,6 +36,7 @@ #include #include #include +#include =20 #include "head.h" =20 @@ -279,6 +280,7 @@ void __init setup_arch(char **cmdline_p) parse_early_param(); =20 efi_init(); + ffi_init(); paging_init(); =20 /* Parse the ACPI tables for possible boot-time configuration */ --=20 2.20.1 From nobody Sun Feb 8 18:31:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 254DFC001B0 for ; Wed, 5 Jul 2023 11:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231475AbjGELpB (ORCPT ); Wed, 5 Jul 2023 07:45:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231561AbjGELo5 (ORCPT ); Wed, 5 Jul 2023 07:44:57 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD4A01981 for ; Wed, 5 Jul 2023 04:44:53 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-262dc1ced40so4739072a91.3 for ; Wed, 05 Jul 2023 04:44:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1688557493; x=1691149493; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vxuPbxVgF3zfcM/BRF/LLNBZgbT5czHHRuVcSzACvZ4=; b=USieFHEI7eCXkkZlxw91812OEPriTznOhYAAyi2cXQlf49JdMjM71QTNZhPXsv+nhz qj4BRAuXZjJzjZvy0kzeIKh5Hlmy5UmwfmwNgsyAbOWDZkARdCb/7bjGCHW+BaBbgZGt vr9aZZfYLHoDEDPC4mmRW8/GdKX7beelO5Vz4Ex2zA1yD90Qmut/5ZtmWcOo8PTfUPV/ 9wMTOaufrebObZG2kdeeHjoZ4dVZGvqSHK/p3ChlcMXQNJEjW3SUkAXyGAlYSNlUTWhd c9vbIApSePRVpayGJIb4QKHu377JeUxTSSiobs63TsC7Vbfo079dl4/ZzfesOMe4QhJe 4o6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688557493; x=1691149493; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vxuPbxVgF3zfcM/BRF/LLNBZgbT5czHHRuVcSzACvZ4=; b=NQcrTWdLK/K5yZkbjSok1twjHMqnXbAsOxG2lN36mTBZz4azDb2jTJLdqMHQ6M1w0/ 4moWH+9aaHMrMQpml+8k5s7eh/RMkifdpW4EE3x7lKavnL+stbHXUaeuKmVPngUr/aC9 b4ZXuOl09uuIUTf4pb0FG+1/cGIY6MDoVHgVvdMERb723lM8T0PThFNIe4jD1n2wgFcG NmXrmuvzC4MfbIVyfTs8p9fLXnHnDDqGiZNAfo0eTqaN3zMnzbfsn4n/Td/44/HFIBEd TX8QXRDE8XfhrMnh8n+KkmooUYPJysORfz2Yj4oNzUQkcr81YRNeKt4EPbQtRXWoFJq2 7/FA== X-Gm-Message-State: ABy/qLYIF3AQ4XzS+GJqAsbQmzev27ssanmQYP8eq2pYMCpzzhuBZk4F lAvYVM1oAMYNXa7QV1wGO3Q/sg== X-Google-Smtp-Source: APBJJlGR3P54rhDcdlAlLclU9MYRdR5Ld0I3S9zquD63eupWzYEBKVWsWxUQA1BhQ1YV526dFMH7KQ== X-Received: by 2002:a17:90a:54:b0:261:113e:50d2 with SMTP id 20-20020a17090a005400b00261113e50d2mr16503592pjb.31.1688557493100; Wed, 05 Jul 2023 04:44:53 -0700 (PDT) Received: from PF2E59YH-BKX.inc.bytedance.com ([61.213.176.5]) by smtp.gmail.com with ESMTPSA id 3-20020a17090a194300b00263f6687690sm1177900pjh.18.2023.07.05.04.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 04:44:52 -0700 (PDT) From: Yunhui Cui To: conor@kernel.org, sunilvl@ventanamicro.com, ardb@kernel.org, palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, rminnich@gmail.com, mark.rutland@arm.com, lpieralisi@kernel.org, rafael@kernel.org, lenb@kernel.org, jdelvare@suse.com, yc.hung@mediatek.com, angelogioacchino.delregno@collabora.com, allen-kh.cheng@mediatek.com, pierre-louis.bossart@linux.intel.com, tinghan.shen@mediatek.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, geshijian@bytedance.com, weidong.wd@bytedance.com, cuiyunhui@bytedance.com Subject: [PATCH v3 2/4] firmware: introduce FFI for SMBIOS entry Date: Wed, 5 Jul 2023 19:42:49 +0800 Message-Id: <20230705114251.661-3-cuiyunhui@bytedance.com> X-Mailer: git-send-email 2.37.3.windows.1 In-Reply-To: <20230705114251.661-1-cuiyunhui@bytedance.com> References: <20230705114251.661-1-cuiyunhui@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" To enable DMI functionality on platforms where the bootloader does not support EFI and the architecture does not support reserved addresses. Add a "ffitbl" device tree node to find the SMBIOS entry point and use wire up dmi_scan_machine().This feature is known as the FDT Firmware Interface (FFI). Signed-off-by: Yunhui Cui --- MAINTAINERS | 6 +++ drivers/firmware/Kconfig | 11 +++++ drivers/firmware/Makefile | 1 + drivers/firmware/dmi_scan.c | 97 ++++++++++++++++++++++--------------- drivers/firmware/ffi.c | 42 ++++++++++++++++ include/linux/ffi.h | 29 +++++++++++ 6 files changed, 146 insertions(+), 40 deletions(-) create mode 100644 drivers/firmware/ffi.c create mode 100644 include/linux/ffi.h diff --git a/MAINTAINERS b/MAINTAINERS index e592f489e757..9b886ef36587 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7871,6 +7871,12 @@ F: arch/x86/platform/efi/ F: drivers/firmware/efi/ F: include/linux/efi*.h =20 +FDT FIRMWARE INTERFACE (FFI) +M: Yunhui Cui cuiyunhui@bytedance.com +S: Maintained +F: drivers/firmware/ffi.c +F: include/linux/ffi.h + EXTERNAL CONNECTOR SUBSYSTEM (EXTCON) M: MyungJoo Ham M: Chanwoo Choi diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index b59e3041fd62..3579d9bc22ff 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -303,6 +303,17 @@ config TURRIS_MOX_RWTM other manufacturing data and also utilize the Entropy Bit Generator for hardware random number generation. =20 +config FDT_FW_INTERFACE + bool "An interface for passing firmware info through FDT" + depends on OF && OF_FLATTREE + default n + help + Enable this option to support the transfer of firmware information, + such as smbios tables, for bootloaders that do not support EFI, such + as coreboot. + + Say Y here if you want to transfer firmware information by FDT. + source "drivers/firmware/arm_ffa/Kconfig" source "drivers/firmware/broadcom/Kconfig" source "drivers/firmware/cirrus/Kconfig" diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 28fcddcd688f..3b8b5d0868a6 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -33,6 +33,7 @@ obj-y +=3D cirrus/ obj-y +=3D meson/ obj-$(CONFIG_GOOGLE_FIRMWARE) +=3D google/ obj-y +=3D efi/ +obj-$(CONFIG_FDT_FW_INTERFACE) +=3D ffi.o obj-y +=3D imx/ obj-y +=3D psci/ obj-y +=3D smccc/ diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 015c95a825d3..c29ea050b5b9 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -655,54 +656,70 @@ static int __init dmi_smbios3_present(const u8 *buf) return 1; } =20 -static void __init dmi_scan_machine(void) +/* + * According to the DMTF SMBIOS reference spec v3.0.0, it is + * allowed to define both the 64-bit entry point (smbios3) and + * the 32-bit entry point (smbios), in which case they should + * either both point to the same SMBIOS structure table, or the + * table pointed to by the 64-bit entry point should contain a + * superset of the table contents pointed to by the 32-bit entry + * point (section 5.2) + * This implies that the 64-bit entry point should have + * precedence if it is defined and supported by the OS. If we + * have the 64-bit entry point, but fail to decode it, fall + * back to the legacy one (if available) + */ +static int __init dmi_sacn_smbios(unsigned long smbios3, unsigned long smb= ios) { - char __iomem *p, *q; + char __iomem *p; char buf[32]; - - if (efi_enabled(EFI_CONFIG_TABLES)) { - /* - * According to the DMTF SMBIOS reference spec v3.0.0, it is - * allowed to define both the 64-bit entry point (smbios3) and - * the 32-bit entry point (smbios), in which case they should - * either both point to the same SMBIOS structure table, or the - * table pointed to by the 64-bit entry point should contain a - * superset of the table contents pointed to by the 32-bit entry - * point (section 5.2) - * This implies that the 64-bit entry point should have - * precedence if it is defined and supported by the OS. If we - * have the 64-bit entry point, but fail to decode it, fall - * back to the legacy one (if available) - */ - if (efi.smbios3 !=3D EFI_INVALID_TABLE_ADDR) { - p =3D dmi_early_remap(efi.smbios3, 32); - if (p =3D=3D NULL) - goto error; - memcpy_fromio(buf, p, 32); - dmi_early_unmap(p, 32); - - if (!dmi_smbios3_present(buf)) { - dmi_available =3D 1; - return; - } - } - if (efi.smbios =3D=3D EFI_INVALID_TABLE_ADDR) - goto error; - - /* This is called as a core_initcall() because it isn't - * needed during early boot. This also means we can - * iounmap the space when we're done with it. - */ - p =3D dmi_early_remap(efi.smbios, 32); + #define INVALID_TABLE_ADDR (~0UL) + if (smbios3 !=3D INVALID_TABLE_ADDR) { + p =3D dmi_early_remap(smbios3, 32); if (p =3D=3D NULL) - goto error; + return -1; memcpy_fromio(buf, p, 32); dmi_early_unmap(p, 32); =20 - if (!dmi_present(buf)) { + if (!dmi_smbios3_present(buf)) { dmi_available =3D 1; - return; + return 0; } + } + if (smbios =3D=3D INVALID_TABLE_ADDR) + return -1; + /* + * This is called as a core_initcall() because it isn't + * needed during early boot. This also means we can + * iounmap the space when we're done with it. + */ + p =3D dmi_early_remap(smbios, 32); + if (p =3D=3D NULL) + return -1; + memcpy_fromio(buf, p, 32); + dmi_early_unmap(p, 32); + + if (!dmi_present(buf)) { + dmi_available =3D 1; + return 0; + } + + return -1; +} + +static void __init dmi_scan_machine(void) +{ + char __iomem *p, *q; + char buf[32]; + + if (ffi_enabled(FFI_CONFIG_TABLES)) { + if (!dmi_sacn_smbios(ffi.smbios3, ffi.smbios)) + return; + } + + if (efi_enabled(EFI_CONFIG_TABLES)) { + if (dmi_sacn_smbios(efi.smbios3, efi.smbios)) + goto error; } else if (IS_ENABLED(CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK)) { p =3D dmi_early_remap(SMBIOS_ENTRY_POINT_SCAN_START, 0x10000); if (p =3D=3D NULL) diff --git a/drivers/firmware/ffi.c b/drivers/firmware/ffi.c new file mode 100644 index 000000000000..d4994a22438b --- /dev/null +++ b/drivers/firmware/ffi.c @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include + +#define FFI_INVALID_TABLE_ADDR (~0UL) + +struct ffi __read_mostly ffi =3D { + .smbios =3D FFI_INVALID_TABLE_ADDR, + .smbios3 =3D FFI_INVALID_TABLE_ADDR, +}; + +void __init ffi_smbios_root_pointer(void) +{ + u32 ffitbl, smbios, len, ver; + u64 entry; + fdt64_t *prop; + + ffitbl =3D fdt_subnode_offset(initial_boot_params, 0, "ffitbl"); + smbios =3D fdt_subnode_offset(initial_boot_params, ffitbl, "smbios"); + prop =3D fdt_getprop_w(initial_boot_params, smbios, "entry", &len); + if (!prop || len !=3D sizeof(u64)) { + pr_debug("smbios entry not found.\n"); + return; + } + entry =3D fdt64_to_cpu(*prop); + + prop =3D fdt_getprop_w(initial_boot_params, smbios, "reg", &len); + if (!prop || len !=3D sizeof(u32)) { + pr_debug("smbios reg not found.\n"); + return; + } + ver =3D fdt32_to_cpu(*prop); + (ver =3D=3D 3) ? (ffi.smbios3 =3D entry) : (ffi.smbios =3D entry); + set_bit(FFI_CONFIG_TABLES, &ffi.flags); + pr_debug("smbios%d entry: %llx\n", ver, entry); +} + diff --git a/include/linux/ffi.h b/include/linux/ffi.h new file mode 100644 index 000000000000..a99c2a290556 --- /dev/null +++ b/include/linux/ffi.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _LINUX_FFI_H +#define _LINUX_FFI_H + +extern struct ffi { + unsigned long smbios; /* SMBIOS table (32 bit entry point) */ + unsigned long smbios3; /* SMBIOS table (64 bit entry point) */ + unsigned long flags; + +} ffi; + +#define FFI_CONFIG_TABLES 2 /* Can we use FFI config tables? */ + +#ifdef CONFIG_FDT_FW_INTERFACE +extern void ffi_smbios_root_pointer(void); +static inline bool ffi_enabled(int feature) +{ + return test_bit(feature, &ffi.flags) !=3D 0; +} +#else +static inline bool ffi_enabled(int feature) +{ + return false; +} +void ffi_smbios_root_pointer(void) { return; }; +#endif + +#endif /* _LINUX_FFI_H */ --=20 2.20.1 From nobody Sun Feb 8 18:31:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3E49C001DD for ; Wed, 5 Jul 2023 11:45:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231631AbjGELpQ (ORCPT ); Wed, 5 Jul 2023 07:45:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231514AbjGELpM (ORCPT ); Wed, 5 Jul 2023 07:45:12 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D24D01990 for ; Wed, 5 Jul 2023 04:45:00 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1b89b75dc1cso4279145ad.1 for ; Wed, 05 Jul 2023 04:45:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1688557500; x=1691149500; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=2/7mU7LG0/LoivTbyL8zN+ZBZKcFo4rglaRaqylxhfQ=; b=Ltfa/6PMTzVFKvupHYoIu25JvZQEj8+TG279VMGSVCFID+E3BGc5M/0cOuZAjs8bL2 z9Cgl0L5iCAGnnQ/SuOGo7Tlk2zQTK9bQPleevr+vBadbtzutwf63D4nRPP3IF+qUaFx EvP//jSB2BrpV79rZnIxTxbFyGU2bFXfQ00+rYLUlKKiHn2sM+6/jwg1lRkSLa9Axgpj Txv/dFC2aNPc+fLwMIpNaBCDQ/ZOdivCtVpmurWLgY2ltsQ8x9kA03yypVf4nBnyOGiw Zc7G9su5n0GMnMCvvb8mRkoltS9mmH76Z7KN16SNl20HeoY+KKNBQTu61nHeHB/My8I5 vr4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688557500; x=1691149500; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2/7mU7LG0/LoivTbyL8zN+ZBZKcFo4rglaRaqylxhfQ=; b=a/f64R/pLqSG2VpqHHQCr7odyUeWb0fghED8OcBcGR2CEMGog93lxfwi1wM2lg4tBg gyxaCx1LAHuzi/Cs9B8dDOsTn58Hv78Q009k+rp0UOuU/x1xxgz10MhiLHzgA4Sx6s+d LiiROZHcpo3kzAtZ/1P494yXnfjx6yD0w7EizUt3NBFWDjcRVE072uS2RGJo9Ax2UUBj 3EpOM+7OWYEF3phiBtENJWSoDzwYchRbSBBBgu5qQ/o+gR2XYNLDKFueEztwKxmb1RNs s6Z1GHS5v3NMJ0vJ5a7gZ+eolnOiVTAkt7S0+/l52SxM7Fi5P3Bnq3crZOW8C0paNcvV jo1A== X-Gm-Message-State: ABy/qLbEIRLsROh/y6eWNREI/lUZJj7ERuqI+lCzGtsRhZJ0Dpu317gz 2ICagKuIbuwYg9/6SSyVtqFxag== X-Google-Smtp-Source: APBJJlE+p5F5PIvo05kj7fIPA1p9K+VjhFZ7LXhkzaKK45+ZK+JAauB4t1oRak5U+mKJZRNdHuxLkA== X-Received: by 2002:a17:90a:f40a:b0:263:f674:490e with SMTP id ch10-20020a17090af40a00b00263f674490emr1749692pjb.3.1688557499886; Wed, 05 Jul 2023 04:44:59 -0700 (PDT) Received: from PF2E59YH-BKX.inc.bytedance.com ([61.213.176.5]) by smtp.gmail.com with ESMTPSA id 3-20020a17090a194300b00263f6687690sm1177900pjh.18.2023.07.05.04.44.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 04:44:59 -0700 (PDT) From: Yunhui Cui To: conor@kernel.org, sunilvl@ventanamicro.com, ardb@kernel.org, palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, rminnich@gmail.com, mark.rutland@arm.com, lpieralisi@kernel.org, rafael@kernel.org, lenb@kernel.org, jdelvare@suse.com, yc.hung@mediatek.com, angelogioacchino.delregno@collabora.com, allen-kh.cheng@mediatek.com, pierre-louis.bossart@linux.intel.com, tinghan.shen@mediatek.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, geshijian@bytedance.com, weidong.wd@bytedance.com, cuiyunhui@bytedance.com Subject: [PATCH v3 3/4] riscv: obtain SMBIOS entry from FFI Date: Wed, 5 Jul 2023 19:42:50 +0800 Message-Id: <20230705114251.661-4-cuiyunhui@bytedance.com> X-Mailer: git-send-email 2.37.3.windows.1 In-Reply-To: <20230705114251.661-1-cuiyunhui@bytedance.com> References: <20230705114251.661-1-cuiyunhui@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On RISC-V, Coreboot does not support EFI booting, only supports devicetree, and RISC-V does not have reserved address segments. To support Coreboot on RISC-V platforms that require DMI functionality, SMBIOS entry need to be passed through FFI. Signed-off-by: Yunhui Cui --- arch/riscv/kernel/ffi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/riscv/kernel/ffi.c b/arch/riscv/kernel/ffi.c index 147d06a5acff..b959d16fe0b3 100644 --- a/arch/riscv/kernel/ffi.c +++ b/arch/riscv/kernel/ffi.c @@ -8,6 +8,7 @@ #include #include #include +#include =20 static u64 acpi_rsdp; =20 @@ -35,4 +36,5 @@ u64 __init riscv_acpi_rsdp(void) void __init ffi_init(void) { ffi_acpi_root_pointer(); + ffi_smbios_root_pointer(); } --=20 2.20.1 From nobody Sun Feb 8 18:31:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CEF4EB64DD for ; Wed, 5 Jul 2023 11:45:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231695AbjGELpu (ORCPT ); Wed, 5 Jul 2023 07:45:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbjGELps (ORCPT ); Wed, 5 Jul 2023 07:45:48 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D482E1BC3 for ; Wed, 5 Jul 2023 04:45:07 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-263121cd04eso2969444a91.2 for ; Wed, 05 Jul 2023 04:45:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1688557507; x=1691149507; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=v+ITQvowAXOXD8H4U5Ak65JYD6vo7/xikUkbFThVisc=; b=JdOIUPCcVgRbkHL6lKC2twEROgaAL4yJ8ZwTGhCaGWbZQF9aFGaRYNPGYzOGyghzhg +xgjWXfn01h1SKYk1tCnUwym7zJigY1FB2L5nLJ9K9xF+V96OcBaG8t1Nvd3B2sJD/Ls 4hF63PIb9gGwLm7I9MhvBmuNYQeSd2x4nd+O5gtyCppqbUmkWKDhM+rfZ0oSgKLAnmyh ef/1usAQUA9CcwFdOCMOZiXTJMrJ22ZEPa8whSjBMypJAPO7J2gk5zs4iFCdj7s8Fcrk ie3LhugAEg6iQhA7aaj/0X0A/wWygp1ho0cDLjVJrYds9JfqZ7MvJZbTR5YNypqp+lHX hrow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688557507; x=1691149507; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v+ITQvowAXOXD8H4U5Ak65JYD6vo7/xikUkbFThVisc=; b=F5ihyu/b0AJ7qhDa9e53sHnJwTGAtuJxiJEDxjbzZKh3azlLt0Q4605bTxs019pjVV BHG20rUjkHG0CkSyyuFkHY560+ngRJTp+o4dMHeoRweAty2lOVPU/rIblEE4xpRJzGGu hF7gEWiRCkr13OYH7fsWAaWFccPA4vNaev1JTvLU5lhy6PKtsPS/Lb6/eyu/IpLQ3vol AawwTsFWwPwoVYqGQ0cMWbFfdSOukJu8jOEHXnuA95RWpY2GwbxsD6ChL4Objk80yXrw Eg+xuinWu5ImA9uyMzDCLBCi0JH04ZXfUsa8pI0DeNRF1e4NiM8c6KA/hWfomywgvZLE Crkw== X-Gm-Message-State: ABy/qLadAND+okTOFOdlqzcV3nYdJwuvTFsHFK5aj33Q+qY2Zh56+Vrs kNlsQ4bf9YWSp3T6lmz30med5QGOYm5H05dhKb2bjA== X-Google-Smtp-Source: APBJJlFcrKCShSuwPuLAA2ZOXSGBben7z55N7jwvIQjxqZ8xyVRdttDLfGixeJRGpz3xqUvIJ1x13w== X-Received: by 2002:a17:90b:5109:b0:263:5c78:4b63 with SMTP id sc9-20020a17090b510900b002635c784b63mr12763480pjb.45.1688557506871; Wed, 05 Jul 2023 04:45:06 -0700 (PDT) Received: from PF2E59YH-BKX.inc.bytedance.com ([61.213.176.5]) by smtp.gmail.com with ESMTPSA id 3-20020a17090a194300b00263f6687690sm1177900pjh.18.2023.07.05.04.45.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 04:45:06 -0700 (PDT) From: Yunhui Cui To: conor@kernel.org, sunilvl@ventanamicro.com, ardb@kernel.org, palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, rminnich@gmail.com, mark.rutland@arm.com, lpieralisi@kernel.org, rafael@kernel.org, lenb@kernel.org, jdelvare@suse.com, yc.hung@mediatek.com, angelogioacchino.delregno@collabora.com, allen-kh.cheng@mediatek.com, pierre-louis.bossart@linux.intel.com, tinghan.shen@mediatek.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, geshijian@bytedance.com, weidong.wd@bytedance.com, cuiyunhui@bytedance.com Subject: [PATCH v3 4/4] dt-bindings: firmware: Document ffitbl binding Date: Wed, 5 Jul 2023 19:42:51 +0800 Message-Id: <20230705114251.661-5-cuiyunhui@bytedance.com> X-Mailer: git-send-email 2.37.3.windows.1 In-Reply-To: <20230705114251.661-1-cuiyunhui@bytedance.com> References: <20230705114251.661-1-cuiyunhui@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add the description for ffitbl subnode. Signed-off-by: Yunhui Cui --- .../devicetree/bindings/firmware/ffitbl.txt | 27 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 28 insertions(+) create mode 100644 Documentation/devicetree/bindings/firmware/ffitbl.txt diff --git a/Documentation/devicetree/bindings/firmware/ffitbl.txt b/Docume= ntation/devicetree/bindings/firmware/ffitbl.txt new file mode 100644 index 000000000000..c42368626199 --- /dev/null +++ b/Documentation/devicetree/bindings/firmware/ffitbl.txt @@ -0,0 +1,27 @@ +FFI(FDT FIRMWARE INTERFACE) driver + +Required properties: + - entry : acpi or smbios root pointer, u64 + - reg : acpi or smbios version, u32 + +Some bootloaders, such as Coreboot do not support EFI, +only devicetree and some arches do not have a reserved +address segment. Add "ffitbl" subnode to obtain ACPI RSDP +and SMBIOS entry. +This feature is known as FDT Firmware Interface (FFI). + +Example: + ffitbl { + + smbios { + entry =3D ""; + reg =3D < 0x03 >; + + } + acpi { + entry =3D ""; + reg =3D < 0x06 >; + + } + } + diff --git a/MAINTAINERS b/MAINTAINERS index 9b886ef36587..008257e55062 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7874,6 +7874,7 @@ F: include/linux/efi*.h FDT FIRMWARE INTERFACE (FFI) M: Yunhui Cui cuiyunhui@bytedance.com S: Maintained +F: Documentation/devicetree/bindings/firmware/ffitbl.txt F: drivers/firmware/ffi.c F: include/linux/ffi.h =20 --=20 2.20.1