From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: fpg@pengutronix.de, chalianis1@gmail.com,
Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH RFT 1/4] efi: payload: ignore ESP state.dtb if device tree is populated
Date: Wed, 26 Aug 2026 14:15:29 +0200 [thread overview]
Message-ID: <20260826121640.2936023-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20260826121640.2936023-1-a.fatoum@pengutronix.de>
In preparation for allowing the state nodes to ship inside the barebox
binary (as we do for non-EFI-payload already), add provisions to skip
the external file if barebox already has a populated DT.
Also for the case that a state had already been set up, skip manual
creation of the state node.
Assisted-by: Claude:opus-5
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
efi/payload/init.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/efi/payload/init.c b/efi/payload/init.c
index 1e5f2eb8cf56..db4bc25682a3 100644
--- a/efi/payload/init.c
+++ b/efi/payload/init.c
@@ -284,6 +284,7 @@ static int efi_late_init(void)
{
const char *state_desc = "/boot/EFI/barebox/state.dtb";
struct device_node *state_root = NULL;
+ struct device_node *root;
size_t size;
void *fdt;
int ret;
@@ -303,6 +304,17 @@ static int efi_late_init(void)
return 0;
}
+ /*
+ * A device tree built into barebox takes precedence: any state it
+ * describes has been instantiated by the state driver already.
+ */
+ root = of_get_root_node();
+ if (root && !list_empty(&root->children)) {
+ pr_warn("device tree is populated, ignoring %s\n", state_desc);
+ free(fdt);
+ return 0;
+ }
+
state_root = of_unflatten_dtb(fdt, size);
free(fdt);
@@ -320,6 +332,10 @@ static int efi_late_init(void)
return 0;
}
+ /* probing the registered tree may have instantiated it already */
+ if (state_by_node(np))
+ return 0;
+
state = state_new_from_node(np, false);
if (IS_ERR(state))
return PTR_ERR(state);
--
2.47.3
next prev parent reply other threads:[~2026-08-26 13:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 12:15 [PATCH RFT 0/4] efi: payload: allow extension via fragments Ahmad Fatoum
2026-08-26 12:15 ` Ahmad Fatoum [this message]
2026-08-26 12:15 ` [PATCH RFT 2/4] kbuild: dtc: introduce empty fallback device tree Ahmad Fatoum
2026-08-26 12:15 ` [PATCH RFT 3/4] efi: payload: export device tree in barebox-dtb EFI variable Ahmad Fatoum
2026-08-26 12:15 ` [PATCH RFT 4/4] Documentation: efi: describe device tree handling Ahmad Fatoum
2026-08-26 22:56 ` [PATCH RFT 0/4] efi: payload: allow extension via fragments chalianis1
2026-08-27 7:31 ` Ahmad Fatoum
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=20260826121640.2936023-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=chalianis1@gmail.com \
--cc=fpg@pengutronix.de \
/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