[PATCH 2/2] ARM: rockchip: atf: Fix memend
Sascha Hauer
s.hauer at pengutronix.de
Mon Feb 23 00:56:50 PST 2026
In rk3588_barebox_entry() we do a:
endmem = rk3588_ram0_size();
This is wrong, as the function name says it returns the (usable in this
case) RAM size. It doesn't count from 0x0 as we assume, but from
RK3588_DRAM_BOTTOM, which means that endmem is calculated by
RK3588_DRAM_BOTTOM too low.
Fix this and while at it use rk3588_ram_sizes(), as this returns usable
DRAM start and size, so exactly the data we need.
Without this fix we run into trouble on boards with 4GB or more of DRAM.
On these boards the 32bit DRAM space is limited by the beginning of the
internal register space. Without this fix the end of the memory range
we pass to barebox overlaps the internal register space. This likely
only didn't blow up because we ultimately do not use the end of DRAM
as OPTEE_SIZE is substracted from it. OP-TEE is in the lower DRAM on
Rockchip though, so the space we reserve for OP-TEE in the upper DRAM
was just unused.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
arch/arm/mach-rockchip/atf.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-rockchip/atf.c b/arch/arm/mach-rockchip/atf.c
index c4ed84aae6..a57c8d94e2 100644
--- a/arch/arm/mach-rockchip/atf.c
+++ b/arch/arm/mach-rockchip/atf.c
@@ -194,12 +194,14 @@ static int rk3588_fixup_mem(void *fdt)
void __noreturn rk3588_barebox_entry(void *fdt)
{
- unsigned long membase, endmem;
+ phys_addr_t membase, memend;
+ resource_size_t memsize;
- membase = RK3588_DRAM_BOTTOM;
- endmem = rk3588_ram0_size();
+ rk3588_ram_sizes(&membase, &memsize, 1);
- rk_scratch = (void *)arm_mem_scratch(endmem);
+ memend = membase + memsize;
+
+ rk_scratch = (void *)arm_mem_scratch(memend);
if (current_el() == 3) {
void *fdt_scratch = NULL;
@@ -223,7 +225,7 @@ void __noreturn rk3588_barebox_entry(void *fdt)
}
optee_set_membase(rk_scratch_get_optee_hdr());
- barebox_arm_entry(membase, endmem - membase, fdt);
+ barebox_arm_entry(membase, memsize, fdt);
}
void rk3576_atf_load_bl31(void *fdt)
--
2.47.3
More information about the barebox
mailing list