Skip to contentSkip to conversation

board_f: why is TLB size estimated before board_init_banksize

RFC Anshul Dalal 1 participant 1 message Jun 19, 2025

lore
Share & tools
lore
#0 lore raw

Hi all,

I was trying to create an MMU table (set as mem_map) at runtime when I encountered an issue with the init sequence for u-boot (defined in initcall_run_f at common/board.f:893).

As part of the MMU creation, I am adding entries for all the memory banks as per gd->bd->bi_dram which is set after dram_init_banksize. So I called the function responsible for creating the MMU table after the bi_dram has been populated in gd by dram_init_banksize.

Although as per the initcall sequence, u-boot has already computed a size estimate for the TLB by this point from arch_reserve_mmu. Though u-boot does expose get_page_table_size API to allow boards to reserve their own size for the TLB but I am not sure why arch_reserve_mmu is being called before dram_init_banksize in the first place.

Modifying the sequence from the existing:
dram_init -> arch_reserve_mmu -> dram_init_banksize

To the new:
dram_init -> dram_init_banksize -> arch_reserve_mmu

Will allow for MMU configuration inside dram_init_banksize where we can access the dram bank sizes and also make use of u-boot's default size estimate for the TLB with the drawback being the dram_init_banksize would not be aware of u-boot's reserved memory.

I was unable to find a reason for why the init sequence is structured this way, any inputs are appreciated :)

Regards,
Anshul