[PATCH] ARM: rockchip: pass smaller device tree to OP-TEE
Sascha Hauer
s.hauer at pengutronix.de
Wed Mar 4 23:01:47 PST 2026
From: Michael Tretter <m.tretter at 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 at pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer at 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
More information about the barebox
mailing list