* [PATCH] state: suppress state overwrite warning for barebox DT
@ 2026-04-13 10:02 Ahmad Fatoum
2026-04-13 11:22 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-04-13 10:02 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
Nowadays, the root != of_get_root_node() check always evaluates to true,
because fixups are never applied onto the barebox live tree directly,
but at a copy. This was necessary to allow repeated fixups, e.g. by
of_diff - + or with multiple boot targets.
The check was useful to have though to differentiate between the case
that the barebox DT is passed to Linux (where it's benign that the state
node is overwritten) or the Linux DT having a state node (which can
mislead as the kernel will be overwritten).
barebox already handles $properties specially in that it refuses to
create them when unflattening and silently drops them when flattening.
This allows associating data with a node for the duration it's
unflattened in barebox memory.
Make use of this by marking the barebox live tree's root node as such,
so even it's duplicates don't trigger the warning while external DTs
would.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
common/state/state.c | 2 +-
drivers/of/base.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/common/state/state.c b/common/state/state.c
index 9bec8ceea762..b421b43da539 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -453,7 +453,7 @@ static int of_state_fixup(struct device_node *root, void *ctx)
* will be overwritten. Warn about this so people do not wonder why
* changes in the kernels state node do not have any effect.
*/
- if (root != of_get_root_node())
+ if (!of_property_read_bool(root, "$barebox,root-node"))
dev_warn(&state->dev, "Warning: Kernel devicetree contains state node, replacing it\n");
} else {
char *of_path, *c;
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 460b5e2f4bbf..5297894f60b0 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2084,6 +2084,7 @@ int of_set_root_node(struct device_node *node)
of_chosen = of_find_node_by_path("/chosen");
of_property_read_string(root_node, "model", &of_model);
+ of_property_write_bool(root_node, "$barebox,root-node", true);
if (of_model)
barebox_set_model(of_model);
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] state: suppress state overwrite warning for barebox DT
2026-04-13 10:02 [PATCH] state: suppress state overwrite warning for barebox DT Ahmad Fatoum
@ 2026-04-13 11:22 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-04-13 11:22 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Mon, 13 Apr 2026 12:02:43 +0200, Ahmad Fatoum wrote:
> Nowadays, the root != of_get_root_node() check always evaluates to true,
> because fixups are never applied onto the barebox live tree directly,
> but at a copy. This was necessary to allow repeated fixups, e.g. by
> of_diff - + or with multiple boot targets.
>
> The check was useful to have though to differentiate between the case
> that the barebox DT is passed to Linux (where it's benign that the state
> node is overwritten) or the Linux DT having a state node (which can
> mislead as the kernel will be overwritten).
>
> [...]
Applied, thanks!
[1/1] state: suppress state overwrite warning for barebox DT
https://git.pengutronix.de/cgit/barebox/commit/?id=40e7f324b675 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-13 11:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-13 10:02 [PATCH] state: suppress state overwrite warning for barebox DT Ahmad Fatoum
2026-04-13 11:22 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox