Skip to contentSkip to conversation

arm64: mvebu: handle non-zero base address for RAM

PATCH In review Chris Packham 2 participants 3 messages May 20, 2022 – Jul 21, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: mvebu: handle non-zero base address for RAM

board_get_usable_ram_top() conflated the RAM size with the top address of RAM. On systems where RAM starts at address 0 these numbers are the same so it went unnoticed. Update board_get_usable_ram_top() to take CONFIG_SYS_SDRAM_BASE into account when determining the top address.

---
I've got a 64-bit mvebu SoC/board that I plan on submitting in a few weeks. One of the gotchas with this board is that the physical address of the RAM starts at 0x2_00000000 (there's some seemingly unmovable I/O occupying the lower addresses).

This was one of the earlier issues I hit with porting. I figured it was independent enough that I could send it out while I'm still working on the rest of the series.

 arch/arm/mach-mvebu/arm64-common.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/arm/mach-mvebu/arm64-common.c +3 -4
index 5357aa554db4..238edbe6ba56 100644
@@ -28,14 +28,13 @@ DECLARE_GLOBAL_DATA_PTR;
  * Currently only 2GiB are mapped for system memory. This is what
  * we pass to the U-Boot subsystem here.
  */
-#define USABLE_RAM_SIZE		0x80000000
+#define USABLE_RAM_SIZE		0x80000000ULL
 
 ulong board_get_usable_ram_top(ulong total_size)
 {
-	if (gd->ram_size > USABLE_RAM_SIZE)
-		return USABLE_RAM_SIZE;
+	unsigned long top = CONFIG_SYS_SDRAM_BASE + min(gd->ram_size, USABLE_RAM_SIZE);
 
-	return gd->ram_size;
+	return (gd->ram_top > top) ? top : gd->ram_top;
 }
 
 /*
Signature · 1 line
2.36.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · Chris Packham

board_get_usable_ram_top() conflated the RAM size with the top address of RAM. On systems where RAM starts at address 0 these numbers are the same so it went unnoticed. Update board_get_usable_ram_top() to take CONFIG_SYS_SDRAM_BASE into account when determining the top address.

---
I've got a 64-bit mvebu SoC/board that I plan on submitting in a few weeks. One of the gotchas with this board is that the physical address of the RAM starts at 0x2_00000000 (there's some seemingly unmovable I/O occupying the lower addresses).

This was one of the earlier issues I hit with porting. I figured it was independent enough that I could send it out while I'm still working on the rest of the series.

  arch/arm/mach-mvebu/arm64-common.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
arch/arm/mach-mvebu/arm64-common.c +1 -1
index 5357aa554db4..238edbe6ba56 100644
@@ -28,14 +28,13 @@ DECLARE_GLOBAL_DATA_PTR;
   * Currently only 2GiB are mapped for system memory. This is what
   * we pass to the U-Boot subsystem here.
   */
-#define USABLE_RAM_SIZE		0x80000000
+#define USABLE_RAM_SIZE		0x80000000ULL

arch/arm/mach-mvebu/arm64-common.c DECLARE_GLOBAL_DATA_PTR; · line 38

Quoted 10 lines
arch/arm/mach-mvebu/arm64-common.c +2 -3
 
  ulong board_get_usable_ram_top(ulong total_size)
  {
-	if (gd->ram_size > USABLE_RAM_SIZE)
-		return USABLE_RAM_SIZE;
+	unsigned long top = CONFIG_SYS_SDRAM_BASE + min(gd->ram_size, USABLE_RAM_SIZE);
 
-	return gd->ram_size;
+	return (gd->ram_top > top) ? top : gd->ram_top;
  }

Thanks,
Stefan

#2 lore raw
In reply to Chris Packham
Quoted 12 lines · Chris Packham

board_get_usable_ram_top() conflated the RAM size with the top address of RAM. On systems where RAM starts at address 0 these numbers are the same so it went unnoticed. Update board_get_usable_ram_top() to take CONFIG_SYS_SDRAM_BASE into account when determining the top address.

---
I've got a 64-bit mvebu SoC/board that I plan on submitting in a few weeks. One of the gotchas with this board is that the physical address of the RAM starts at 0x2_00000000 (there's some seemingly unmovable I/O occupying the lower addresses).

Quoted 6 lines

This was one of the earlier issues I hit with porting. I figured it was independent enough that I could send it out while I'm still working on the rest of the series.

  arch/arm/mach-mvebu/arm64-common.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)

Applied to u-boot-marvell/master

Thanks,
Stefan

Quoted 12 lines
arch/arm/mach-mvebu/arm64-common.c +1 -1
index 5357aa554db4..238edbe6ba56 100644
@@ -28,14 +28,13 @@ DECLARE_GLOBAL_DATA_PTR;
   * Currently only 2GiB are mapped for system memory. This is what
   * we pass to the U-Boot subsystem here.
   */
-#define USABLE_RAM_SIZE		0x80000000
+#define USABLE_RAM_SIZE		0x80000000ULL
 
  ulong board_get_usable_ram_top(ulong total_size)

arch/arm/mach-mvebu/arm64-common.c DECLARE_GLOBAL_DATA_PTR; · line 40

Quoted 10 lines
arch/arm/mach-mvebu/arm64-common.c +2 -3
  {
-	if (gd->ram_size > USABLE_RAM_SIZE)
-		return USABLE_RAM_SIZE;
+	unsigned long top = CONFIG_SYS_SDRAM_BASE + min(gd->ram_size, USABLE_RAM_SIZE);
 
-	return gd->ram_size;
+	return (gd->ram_top > top) ? top : gd->ram_top;
  }
 
  /*

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]