mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] ARM: Rockchip: RK3588: fix memory layout
@ 2026-02-23  8:56 Sascha Hauer
  2026-02-23  8:56 ` [PATCH 1/2] ARM: rockchip: dmc: use define instead of hardcoded value Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sascha Hauer @ 2026-02-23  8:56 UTC (permalink / raw)
  To: BAREBOX

On Rockchip boards with 4GB and more of DRAM the memory we pass to
barebox overlaps the internal register space which only didn't blow
up because the affected area was not used by barebox. Fix this.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
Sascha Hauer (2):
      ARM: rockchip: dmc: use define instead of hardcoded value
      ARM: rockchip: atf: Fix memend

 arch/arm/mach-rockchip/atf.c | 12 +++++++-----
 arch/arm/mach-rockchip/dmc.c |  4 ++--
 2 files changed, 9 insertions(+), 7 deletions(-)
---
base-commit: ffd4db2ea98ea1b8713382ca3d7a8ea7dadca4da
change-id: 20260223-rockchip-optee-928e467db78a

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] ARM: rockchip: dmc: use define instead of hardcoded value
  2026-02-23  8:56 [PATCH 0/2] ARM: Rockchip: RK3588: fix memory layout Sascha Hauer
@ 2026-02-23  8:56 ` Sascha Hauer
  2026-02-23  8:56 ` [PATCH 2/2] ARM: rockchip: atf: Fix memend Sascha Hauer
  2026-02-23 12:06 ` [PATCH 0/2] ARM: Rockchip: RK3588: fix memory layout Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2026-02-23  8:56 UTC (permalink / raw)
  To: BAREBOX

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-rockchip/dmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-rockchip/dmc.c b/arch/arm/mach-rockchip/dmc.c
index 3cb17b9694..9d056ada55 100644
--- a/arch/arm/mach-rockchip/dmc.c
+++ b/arch/arm/mach-rockchip/dmc.c
@@ -215,8 +215,8 @@ size_t rk3588_ram_sizes(phys_addr_t *base, resource_size_t *size, size_t n)
 
 	memsize = size1 + size2;
 
-	base[i] = 0xa00000;
-	size[i] = min_t(resource_size_t, RK3588_INT_REG_START, memsize) - 0xa00000;
+	base[i] = RK3588_DRAM_BOTTOM;
+	size[i] = min_t(resource_size_t, RK3588_INT_REG_START, memsize) - RK3588_DRAM_BOTTOM;
 	i++;
 
 	if (i < n && memsize > SZ_4G) {

-- 
2.47.3




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] ARM: rockchip: atf: Fix memend
  2026-02-23  8:56 [PATCH 0/2] ARM: Rockchip: RK3588: fix memory layout Sascha Hauer
  2026-02-23  8:56 ` [PATCH 1/2] ARM: rockchip: dmc: use define instead of hardcoded value Sascha Hauer
@ 2026-02-23  8:56 ` Sascha Hauer
  2026-02-23 12:06 ` [PATCH 0/2] ARM: Rockchip: RK3588: fix memory layout Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2026-02-23  8:56 UTC (permalink / raw)
  To: BAREBOX

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@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




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] ARM: Rockchip: RK3588: fix memory layout
  2026-02-23  8:56 [PATCH 0/2] ARM: Rockchip: RK3588: fix memory layout Sascha Hauer
  2026-02-23  8:56 ` [PATCH 1/2] ARM: rockchip: dmc: use define instead of hardcoded value Sascha Hauer
  2026-02-23  8:56 ` [PATCH 2/2] ARM: rockchip: atf: Fix memend Sascha Hauer
@ 2026-02-23 12:06 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2026-02-23 12:06 UTC (permalink / raw)
  To: BAREBOX, Sascha Hauer


On Mon, 23 Feb 2026 09:56:48 +0100, Sascha Hauer wrote:
> On Rockchip boards with 4GB and more of DRAM the memory we pass to
> barebox overlaps the internal register space which only didn't blow
> up because the affected area was not used by barebox. Fix this.
> 
> 

Applied, thanks!

[1/2] ARM: rockchip: dmc: use define instead of hardcoded value
      https://git.pengutronix.de/cgit/barebox/commit/?id=698768100e5d (link may not be stable)
[2/2] ARM: rockchip: atf: Fix memend
      https://git.pengutronix.de/cgit/barebox/commit/?id=502ef444770e (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-02-23 12:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-23  8:56 [PATCH 0/2] ARM: Rockchip: RK3588: fix memory layout Sascha Hauer
2026-02-23  8:56 ` [PATCH 1/2] ARM: rockchip: dmc: use define instead of hardcoded value Sascha Hauer
2026-02-23  8:56 ` [PATCH 2/2] ARM: rockchip: atf: Fix memend Sascha Hauer
2026-02-23 12:06 ` [PATCH 0/2] ARM: Rockchip: RK3588: fix memory layout Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox