[PATCH v2 6/6] common: Add an option to relocate on ram top

Marek Vasut marek.vasut at mailbox.org
Mon Apr 27 19:32:47 CEST 2026


On 4/27/26 4:33 PM, Ilias Apalodimas wrote:

[...]

>>>>> +++ b/common/board_f.c
>>>>> @@ -339,7 +339,22 @@ static int setup_ram_base(void)
>>>>>     static int setup_ram_config(void)
>>>>>     {
>>>>>         debug("Monitor len: %08x\n", gd->mon_len);
>>>>> -#if CONFIG_VAL(SYS_MEM_TOP_HIDE)
>>>>> +
>>>>> +     if (CONFIG_IS_ENABLED(RELOC_ADDR_TOP)) {
>>>>> +             int bank;
>>>>> +             phys_size_t total_size = 0;
>>>>> +
>>>>> +             for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
>>>>> +                     if (gd->ram_top <= gd->bi_dram[bank].start)
>>>>> +                             gd->ram_top = gd->bi_dram[bank].start +
>>>>> +                                             gd->bi_dram[bank].size;
>>>>> +                     total_size += gd->bi_dram[bank].size;
>>>>> +             }
>>>>> +             gd->ram_size = total_size;
>>>>
>>>> Shouldn't this also apply board_get_usable_ram_top() to be consistent ?
>>>
>>> Simon asked the same thing. I'd rather keep this option strict for now
>>> and always relocate to the upper memory boundary fnor now. Once I do
>>> further cleanups, I can either add it or remove the function entirely
>>> since dram_init_banksize() (which hs also board specific) runs really
>>> early now.
>>
>> Maybe the default board_get_usable_ram_top() can return the ram top if
>> CONFIG_IS_ENABLED(RELOC_ADDR_TOP) ? That would still allow users to use
>> board_get_usable_ram_top() consistently to reduce the ram top.
> 
> dram_init_banksize() can be used instead now to reduce that and we can
> remove this option eventually. Is there anything that we can't achieve
> with only that ?
I think I might be confused, but it seems board_get_usable_ram_top() is 
used to set gd->ram_top , which is U-Boot's top of RAM and may not be 
the same as physical top of RAM . So no, dram_init_banksize() has to 
configure the correct physical RAM topology, board_get_usable_ram_top() 
can be used to make space at ram_top unavailable to U-Boot .


More information about the U-Boot mailing list