rpi: Fix DRAM size reporting to show total RAM
RFC PATCH 1/1 rpi: Fix DRAM size reporting to show total RAM
The VideoCore mailbox GET_ARM_MEMORY only reports the size of the first accessible memory region (~947 MiB on RPi4 with 8GB), not the total RAM. This causes U-Boot to display "DRAM: 947 MiB (total 7.9 GiB)" instead of "DRAM: 7.9 GiB".
On Raspberry Pi 4 with 8GB RAM, the memory is split across multiple non-contiguous banks. The dram_init() function only sets gd->ram_size to the first bank size reported by the VideoCore firmware, while fdtdec_setup_memory_banksize() correctly populates all memory banks from the device tree.
Fix this by updating gd->ram_size after dram_init_banksize() has populated all memory banks, so it reflects the actual total RAM across all banks.
--- board/raspberrypi/rpi/rpi.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
board/raspberrypi/rpi/rpi.c +15 -1
@@ -332,13 +332,27 @@ int dram_init(void)#ifdef CONFIG_OF_BOARD int dram_init_banksize (void ) { +phys_addr_t total_size =0 ; +int i;int ret; ret =fdtdec_setup_memory_banksize ();if (ret)return ret; -return fdtdec_setup_mem_size_base (); + ret =fdtdec_setup_mem_size_base (); +if (ret) +return ret; + +/* Update gd->ram_size to reflect total RAM across all banks */ +for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { +if (gd->bd->bi_dram[i].size ==0 ) +break ; + total_size += gd->bd->bi_dram[i].size; + } + gd->ram_size = total_size; + +return 0 ; }#endif
Signature · 1 line
2.51.0
Quoted 12 lines · Anders Roxell
The VideoCore mailbox
GET_ARM_MEMORYonly reports the size of the first accessible memory region (~947 MiB on RPi4 with 8GB), not the total RAM. This causes U-Boot to display "DRAM: 947 MiB (total 7.9 GiB)" instead of "DRAM: 7.9 GiB".On Raspberry Pi 4 with 8GB RAM, the memory is split across multiple non-contiguous banks. The
dram_init()function only setsgd->ram_sizeto the first bank size reported by the VideoCore firmware, whilefdtdec_setup_memory_banksize()correctly populates all memory banks from the device tree.
Quoted 5 lines
Fix this by updating
gd->ram_sizeafterdram_init_banksize()has populated all memory banks, so it reflects the actual total RAM across all banks.Signed-off-by Anders Roxell <[email protected]>
Please add details as to why this is RFC? What comments are you actually after?
Quoted 40 lines
--- board/raspberrypi/rpi/rpi.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)board/raspberrypi/rpi/rpi.c +15
-2@@ -332,13 +332,27 @@ int dram_init(void)#ifdef CONFIG_OF_BOARD int dram_init_banksize (void ) { +phys_addr_t total_size =0 ; +int i;int ret; ret =fdtdec_setup_memory_banksize ();if (ret)return ret; -return fdtdec_setup_mem_size_base (); + ret =fdtdec_setup_mem_size_base (); +if (ret) +return ret; + +/* Update gd->ram_size to reflect total RAM across all banks */ +for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { +if (gd->bd->bi_dram[i].size ==0 ) +break ; + total_size += gd->bd->bi_dram[i].size; + } + gd->ram_size = total_size; + +return 0 ; }#endif --2.51.0
Quoted 14 lines · Peter Robinson
Quoted 12 lines · Anders Roxell
The VideoCore mailbox
GET_ARM_MEMORYonly reports the size of the first accessible memory region (~947 MiB on RPi4 with 8GB), not the total RAM. This causes U-Boot to display "DRAM: 947 MiB (total 7.9 GiB)" instead of "DRAM: 7.9 GiB".On Raspberry Pi 4 with 8GB RAM, the memory is split across multiple non-contiguous banks. The
dram_init()function only setsgd->ram_sizeto the first bank size reported by the VideoCore firmware, whilefdtdec_setup_memory_banksize()correctly populates all memory banks from the device tree.
Quoted 7 lines
Quoted 5 lines
Fix this by updating
gd->ram_sizeafterdram_init_banksize()has populated all memory banks, so it reflects the actual total RAM across all banks.Signed-off-by Anders Roxell <[email protected]>Please add details as to why this is RFC? What comments are you actually after?
I don't commit to u-boot that much, so I wasn't sure if this was the right thing to do.
Cheers,
Anders
Quoted 20 lines · Anders Roxell
Quoted 18 lines · Peter Robinson
Quoted 16 lines · Anders Roxell
The VideoCore mailbox
GET_ARM_MEMORYonly reports the size of the first accessible memory region (~947 MiB on RPi4 with 8GB), not the total RAM. This causes U-Boot to display "DRAM: 947 MiB (total 7.9 GiB)" instead of "DRAM: 7.9 GiB".On Raspberry Pi 4 with 8GB RAM, the memory is split across multiple non-contiguous banks. The
dram_init()function only setsgd->ram_sizeto the first bank size reported by the VideoCore firmware, whilefdtdec_setup_memory_banksize()correctly populates all memory banks from the device tree.Fix this by updating
gd->ram_sizeafterdram_init_banksize()has populated all memory banks, so it reflects the actual total RAM across all banks.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Anders Roxell <[email protected]>Please add details as to why this is RFC? What comments are you actually after?
I don't commit to u-boot that much, so I wasn't sure if this was the right thing to do.
Yup, all looked fine, I've applied it.