From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Cc: Michael Tretter <m.tretter@pengutronix.de>
Subject: [PATCH] ARM: rockchip: pass smaller device tree to OP-TEE
Date: Thu, 5 Mar 2026 08:01:47 +0100 [thread overview]
Message-ID: <20260305070147.3419069-1-s.hauer@pengutronix.de> (raw)
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
reply other threads:[~2026-03-05 7:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260305070147.3419069-1-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=m.tretter@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