diff mbox series

rpi: limit size of the RAM to the multiple of the MMU_SECTION_SIZE

Message ID 20210201111633.9771-1-m.szyprowski@samsung.com
State Accepted
Commit 6b3d18c2cb61e5beefbce2de589fe7707ac78fe3
Headers show
Series rpi: limit size of the RAM to the multiple of the MMU_SECTION_SIZE | expand

Commit Message

Marek Szyprowski Feb. 1, 2021, 11:16 a.m. UTC
When RPi4 is booted from USB Mass Storage, the firmware reports 947MiB of
the ARM memory (948 in case of the standard SD-card boot). This value is
not MMU_SECTION_SIZE aligned, so the dram_bank_mmu_setup() skips mapping
of the last 1MiB. This later causes u-boot in ARM 32bit mode to freeze,
because it relocated itself into that unmapped memory and fails to
execute.

Fix this by limiting the size of the first bank to the multiple of
MMU_SECTION_SIZE.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

---
 board/raspberrypi/rpi/rpi.c | 7 +++++++
 1 file changed, 7 insertions(+)

-- 
2.17.1

Comments

Nicolas Saenz Julienne Feb. 3, 2021, 12:20 p.m. UTC | #1
On Mon, 2021-02-01 at 12:16 +0100, Marek Szyprowski wrote:
> When RPi4 is booted from USB Mass Storage, the firmware reports 947MiB of

> the ARM memory (948 in case of the standard SD-card boot). This value is

> not MMU_SECTION_SIZE aligned, so the dram_bank_mmu_setup() skips mapping

> of the last 1MiB. This later causes u-boot in ARM 32bit mode to freeze,

> because it relocated itself into that unmapped memory and fails to

> execute.

> 

> Fix this by limiting the size of the first bank to the multiple of

> MMU_SECTION_SIZE.

> 

> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---


Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>


Regards,
Nicolas
Jaehoon Chung Feb. 3, 2021, 10:20 p.m. UTC | #2
On 2/3/21 9:20 PM, Nicolas Saenz Julienne wrote:
> On Mon, 2021-02-01 at 12:16 +0100, Marek Szyprowski wrote:

>> When RPi4 is booted from USB Mass Storage, the firmware reports 947MiB of

>> the ARM memory (948 in case of the standard SD-card boot). This value is

>> not MMU_SECTION_SIZE aligned, so the dram_bank_mmu_setup() skips mapping

>> of the last 1MiB. This later causes u-boot in ARM 32bit mode to freeze,

>> because it relocated itself into that unmapped memory and fails to

>> execute.

>>

>> Fix this by limiting the size of the first bank to the multiple of

>> MMU_SECTION_SIZE.

>>

>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

>> ---

> 

> Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>


With latest eeprom firmware, it was stuck when boot from USB storage on 32bit.
After applied this patch, it's working fine.

Tested-by: Jaehoon Chung <jh80.chung@samsung.com>

Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>


Best Regards,
Jaehoon Chung

> 

> Regards,

> Nicolas

> 

>
diff mbox series

Patch

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index 6b1fa5fc14..83ccd3e3fc 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -268,6 +268,13 @@  int dram_init(void)
 
 	gd->ram_size = msg->get_arm_mem.body.resp.mem_size;
 
+	/*
+	 * In some configurations the memory size returned by VideoCore
+	 * is not aligned to the section size, what is mandatory for
+	 * the u-boot's memory setup.
+	 */
+	gd->ram_size &= ~MMU_SECTION_SIZE;
+
 	return 0;
 }