mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: adriana <adriana@arista.com>
To: ilias.apalodimas@linaro.org, ardb@kernel.org, trini@konsulko.com
Cc: robh@kernel.org, krzk@kernel.org, jdelvare@suse.com,
	frowand.list@gmail.com, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, vasilykh@arista.com,
	arm.ebbr-discuss@arm.com, boot-architecture@lists.linaro.org,
	linux-efi@vger.kernel.org, uefi-discuss@lists.uefi.org,
	linux-arm-kernel@lists.infradead.org,
	Adriana Nicolae <adriana@arista.com>
Subject: [PATCH v3 2/2] drivers: firmware: dmi_scan: Add support for reading SMBIOS from DT
Date: Fri, 31 Oct 2025 01:41:01 -0700	[thread overview]
Message-ID: <20251031084101.701159-3-adriana@arista.com> (raw)
In-Reply-To: <20251031084101.701159-1-adriana@arista.com>

From: Adriana Nicolae <adriana@arista.com>

Signed-off-by: Adriana Nicolae <adriana@arista.com>
---
 drivers/firmware/dmi_scan.c | 58 +++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 70d39adf50dc..acc0e18b8d0f 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -10,6 +10,9 @@
 #include <linux/random.h>
 #include <asm/dmi.h>
 #include <linux/unaligned.h>
+#if IS_ENABLED(CONFIG_OF)
+#include <linux/of.h>
+#endif
 
 #ifndef SMBIOS_ENTRY_POINT_SCAN_START
 #define SMBIOS_ENTRY_POINT_SCAN_START 0xF0000
@@ -670,6 +673,54 @@ static int __init dmi_smbios3_present(const u8 *buf)
 	return 1;
 }
 
+#if IS_ENABLED(CONFIG_OF)
+/**
+ * dmi_scan_from_dt - Find and parse DMI/SMBIOS tables from the Device Tree
+ *
+ * Checks if the bootloader has passed SMBIOS table addresses via the /chosen
+ * node in the Device Tree. This follows the standard kernel DT bindings and
+ * assumes a fixed 32-byte mapping for the entry point.
+ * Returns true if a valid table is found and successfully parsed.
+ */
+static bool __init dmi_scan_from_dt(void)
+{
+	struct device_node *chosen;
+	const __be64 *prop;
+	char buf[32];
+	void __iomem *p;
+	bool dmi_available = false;
+	u64 addr;
+	int len;
+
+	chosen = of_find_node_by_path("/chosen");
+	if (!chosen)
+		return false;
+
+	prop = of_get_property(chosen, "linux,smbios3-table", &len);
+	if (prop && len >= sizeof(u64)) {
+		addr = be64_to_cpup(prop);
+
+		p = dmi_early_remap(addr, 32);
+		if (p == NULL)
+			goto out;
+
+		memcpy_fromio(buf, p, sizeof(buf));
+		dmi_early_unmap(p, 32);
+
+		if (!dmi_smbios3_present(buf)) {
+			dmi_available = true;
+			goto out;
+		}
+	}
+
+out:
+	of_node_put(chosen);
+	return dmi_available;
+}
+#else
+static bool __init dmi_scan_from_dt(void) { return false; }
+#endif /* IS_ENABLED(CONFIG_OF) */
+
 static void __init dmi_scan_machine(void)
 {
 	char __iomem *p, *q;
@@ -718,6 +769,13 @@ static void __init dmi_scan_machine(void)
 			dmi_available = 1;
 			return;
 		}
+	} else if (IS_ENABLED(CONFIG_OF) && dmi_scan_from_dt()) {
+		/*
+		 * If EFI is not present or failed, try getting SMBIOS
+		 * tables from the Device Tree.
+		 */
+		dmi_available = 1;
+		return;
 	} else if (IS_ENABLED(CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK)) {
 		p = dmi_early_remap(SMBIOS_ENTRY_POINT_SCAN_START, 0x10000);
 		if (p == NULL)
-- 
2.51.0


  parent reply	other threads:[~2025-10-31  8:41 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22  8:21 [PATCH 1/1] DMI: Scan for DMI table from DTS info adriana
2025-10-22  9:56 ` Krzysztof Kozlowski
2025-10-22 11:45   ` [PATCH v2 0/2] " adriana
2025-10-22 11:45     ` [PATCH v2 1/2] dt-bindings: firmware: Add binding for SMBIOS /chosen properties adriana
2025-10-22 11:45     ` [PATCH v2 2/2] drivers: firmware: dmi_scan: Add support for reading SMBIOS from DT adriana
2025-10-22 20:19     ` [PATCH v2 0/2] DMI: Scan for DMI table from DTS info Rob Herring
2025-10-23  2:20       ` Adriana Nicolae
2025-10-23  8:21         ` Ard Biesheuvel
2025-10-23 13:34           ` Adriana Nicolae
2025-10-23 13:53             ` Ard Biesheuvel
2025-10-23 14:47               ` Adriana Nicolae
2025-10-24  9:49                 ` Ard Biesheuvel
2025-10-24 11:07                   ` Ilias Apalodimas
2025-10-24 18:07                     ` Tom Rini
2025-10-31  8:51                       ` Adriana Nicolae
2025-10-31  8:40     ` [PATCH v3 " adriana
2025-10-31  8:41       ` [PATCH v3 1/2] dt-bindings: firmware: Add binding for SMBIOS /chosen properties adriana
2025-10-31  8:52         ` Ard Biesheuvel
2025-10-31  9:05           ` Ard Biesheuvel
2025-10-31  8:41       ` adriana [this message]
2025-10-31  9:05         ` [PATCH v3 2/2] drivers: firmware: dmi_scan: Add support for reading SMBIOS from DT Ard Biesheuvel
2025-10-31  9:31         ` Ilias Apalodimas
2025-10-31 10:10       ` [PATCH v4 0/2] DMI: Scan for DMI table from DTS info adriana
2025-10-31 10:10         ` [PATCH v4 1/2] dt-bindings: firmware: Add binding for SMBIOS /chosen properties adriana
2025-10-31 11:15           ` Rob Herring
2025-10-31 11:43             ` Rob Herring
2025-10-31 12:31               ` Adriana Nicolae
2025-10-31 10:10         ` [PATCH v4 2/2] drivers: firmware: dmi_scan: Add support for reading SMBIOS from DT adriana
2025-10-31 10:17         ` [PATCH v4 0/2] DMI: Scan for DMI table from DTS info Ard Biesheuvel
2025-10-31 11:03           ` Ilias Apalodimas
2025-10-31 11:59         ` [PATCH v5 0/1] " adriana
2025-10-31 11:59           ` [PATCH v5 1/1] drivers: firmware: dmi_scan: Add support for reading SMBIOS from DT adriana
2025-10-31 14:19           ` [PATCH v5 0/1] DMI: Scan for DMI table from DTS info Conor Dooley

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=20251031084101.701159-3-adriana@arista.com \
    --to=adriana@arista.com \
    --cc=ardb@kernel.org \
    --cc=arm.ebbr-discuss@arm.com \
    --cc=boot-architecture@lists.linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jdelvare@suse.com \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=trini@konsulko.com \
    --cc=uefi-discuss@lists.uefi.org \
    --cc=vasilykh@arista.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®