* [PATCH] ARM: rockchip: pass smaller device tree to OP-TEE
@ 2026-03-05 7:01 Sascha Hauer
0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2026-03-05 7:01 UTC (permalink / raw)
To: Barebox List; +Cc: Michael Tretter
From: Michael Tretter <m.tretter@pengutronix.de>
libfdt is slow on larger device tree, especially fdt_subnode_offset.
Adding the memory nodes to the ROCK 5T device tree takes about 2 seconds
on my machine.
OP-TEE doesn't need the entire tree, but only the memory nodes.
Create a fresh device tree, which is much smaller, and add the memory
nodes there to avoid the costly search through the device tree.
Since OP-TEE uses libfdt, too, this saves another 2.5 seconds in OP-TEE.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-rockchip/atf.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-rockchip/atf.c b/arch/arm/mach-rockchip/atf.c
index 37f027740c..a60b55ae24 100644
--- a/arch/arm/mach-rockchip/atf.c
+++ b/arch/arm/mach-rockchip/atf.c
@@ -230,6 +230,20 @@ static int rk3588_fixup_mem(void *fdt)
return fdt_fixup_mem(fdt, base, size, i);
}
+static int rk3588_open_fdt(const void *fdt, void *buf, int bufsize)
+{
+ int root;
+
+ if (fdt_create_empty_tree(buf, bufsize) != 0)
+ return -1;
+ root = fdt_path_offset(buf, "/");
+
+ fdt_setprop_u32(buf, root, "#address-cells", 2);
+ fdt_setprop_u32(buf, root, "#size-cells", 2);
+
+ return 0;
+}
+
void __noreturn rk3588_barebox_entry(void *fdt)
{
phys_addr_t membase, memend;
@@ -250,7 +264,7 @@ void __noreturn rk3588_barebox_entry(void *fdt)
if (IS_ENABLED(CONFIG_ARCH_ROCKCHIP_ATF_PASS_FDT)) {
pr_debug("Copy fdt to scratch area 0x%p (%zu bytes)\n",
rk_scratch->fdt, sizeof(rk_scratch->fdt));
- if (fdt_open_into(fdt, rk_scratch->fdt, sizeof(rk_scratch->fdt)) == 0)
+ if (rk3588_open_fdt(fdt, rk_scratch->fdt, sizeof(rk_scratch->fdt)) == 0)
fdt_scratch = rk_scratch->fdt;
else
pr_warn("Failed to copy fdt to scratch: Continue without fdt\n");
--
2.47.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-05 7:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-05 7:01 [PATCH] ARM: rockchip: pass smaller device tree to OP-TEE Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox