Skip to contentSkip to conversation

ARM: stm32mp: Fix dram_bank_mmu_setup() for ram_top=0

PATCH In review Marek Vasut 2 participants 3 messages Mar 9, 2025 – Mar 10, 2025

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

PATCH 1/1 ARM: stm32mp: Fix dram_bank_mmu_setup() for ram_top=0

On STM32MP15xx with 1 GiB of DRAM, the gd->ram_top becomes 0, because DRAM base 0xc0000000 + DRAM size 0x40000000 leads to gd->ram_top overflow which resets it to 0. Handle this special case simply by checking for gd->ram_top being zero, and if it is, assume there is no addr >= gd->ram_top .

This fixes boot hang on STM32MP15xx with 1 GiB of DRAM.

Fixes 25fb58e88aba ("ARM: stm32mp: Fix dram_bank_mmu_setup() for LMB located above ram_top")

---
Cc: Ilias Apalodimas <[email protected]>
Cc: Lukasz Majewski <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Patrice Chotard <[email protected]>
Cc: Patrick Delaunay <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Sughosh Ganu <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 arch/arm/mach-stm32mp/stm32mp1/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-stm32mp/stm32mp1/cpu.c +1 -1
index cb1b84c9af9..d5eaf6711b6 100644
@@ -82,7 +82,7 @@ void dram_bank_mmu_setup(int bank)
 		option = DCACHE_DEFAULT_OPTION;
 		if (use_lmb &&
 		    (lmb_is_reserved_flags(i << MMU_SECTION_SHIFT, LMB_NOMAP) ||
-		    addr >= gd->ram_top)
+		     (gd->ram_top && addr >= gd->ram_top))
 		   )
 			option = 0; /* INVALID ENTRY in TLB */
 		set_section_dcache(i, option);
Signature · 1 line
2.47.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 30 lines · Marek Vasut

On STM32MP15xx with 1 GiB of DRAM, the gd->ram_top becomes 0, because DRAM base 0xc0000000 + DRAM size 0x40000000 leads to gd->ram_top overflow which resets it to 0. Handle this special case simply by checking for gd->ram_top being zero, and if it is, assume there is no addr >= gd->ram_top .

This fixes boot hang on STM32MP15xx with 1 GiB of DRAM.

Fixes 25fb58e88aba ("ARM: stm32mp: Fix dram_bank_mmu_setup() for LMB located above ram_top")

---
Cc: Ilias Apalodimas <[email protected]>
Cc: Lukasz Majewski <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Patrice Chotard <[email protected]>
Cc: Patrick Delaunay <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Sughosh Ganu <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 arch/arm/mach-stm32mp/stm32mp1/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-stm32mp/stm32mp1/cpu.c +0 -0
index cb1b84c9af9..d5eaf6711b6 100644

arch/arm/mach-stm32mp/stm32mp1/cpu.c void dram_bank_mmu_setup(int bank) · line 88

Quoted 8 lines
arch/arm/mach-stm32mp/stm32mp1/cpu.c +1 -1
@@ -82,7 +82,7 @@ void dram_bank_mmu_setup(int bank)
 		option = DCACHE_DEFAULT_OPTION;
 		if (use_lmb &&
 		    (lmb_is_reserved_flags(i << MMU_SECTION_SHIFT, LMB_NOMAP) ||
-		    addr >= gd->ram_top)
+		     (gd->ram_top && addr >= gd->ram_top))
 		   )
 			option = 0; /* INVALID ENTRY in TLB */
 		set_section_dcache(i, option);

Hi Marek

Thanks
Patrice

#2 lore raw
Quoted 45 lines · Patrice CHOTARD
Quoted 30 lines · Marek Vasut

On STM32MP15xx with 1 GiB of DRAM, the gd->ram_top becomes 0, because DRAM base 0xc0000000 + DRAM size 0x40000000 leads to gd->ram_top overflow which resets it to 0. Handle this special case simply by checking for gd->ram_top being zero, and if it is, assume there is no addr >= gd->ram_top .

This fixes boot hang on STM32MP15xx with 1 GiB of DRAM.

Fixes 25fb58e88aba ("ARM: stm32mp: Fix dram_bank_mmu_setup() for LMB located above ram_top")

---
Cc: Ilias Apalodimas <[email protected]>
Cc: Lukasz Majewski <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Patrice Chotard <[email protected]>
Cc: Patrick Delaunay <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Sughosh Ganu <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 arch/arm/mach-stm32mp/stm32mp1/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-stm32mp/stm32mp1/cpu.c +0 -0
index cb1b84c9af9..d5eaf6711b6 100644

arch/arm/mach-stm32mp/stm32mp1/cpu.c void dram_bank_mmu_setup(int bank) · line 88

Quoted 8 lines
arch/arm/mach-stm32mp/stm32mp1/cpu.c +1 -1
@@ -82,7 +82,7 @@ void dram_bank_mmu_setup(int bank)
 		option = DCACHE_DEFAULT_OPTION;
 		if (use_lmb &&
 		    (lmb_is_reserved_flags(i << MMU_SECTION_SHIFT, LMB_NOMAP) ||
-		    addr >= gd->ram_top)
+		     (gd->ram_top && addr >= gd->ram_top))
 		   )
 			option = 0; /* INVALID ENTRY in TLB */
 		set_section_dcache(i, option);

Hi Marek

Quoted 5 lines

Thanks
Patrice

Applied to u-boot-stm32/master

Thanks
Patrice