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

Ilias Apalodimas ilias.apalodimas at linaro.org
Tue Apr 28 09:31:58 CEST 2026


On Tue, 28 Apr 2026 at 09:43, Marek Vasut <marek.vasut at mailbox.org> wrote:
>
> 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 .

I don't think you are confused but what I am trying to do with this
option here is make the process of relocating to the last bank
standard. So people that want U-Boot to calculate the reloc address
based on the information they initalized on dram_init_banksize() _ the
reserved DT regions should enable this option. if they have their own
per board calculation logic, they can leave it as is, in which case
we'll still call board_get_usable_ram_top().

Cheers
/Ilias


More information about the U-Boot mailing list