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

Ilias Apalodimas ilias.apalodimas at linaro.org
Wed Apr 29 09:07:34 CEST 2026


On Wed, 29 Apr 2026 at 04:07, Marek Vasut <marek.vasut at mailbox.org> wrote:
>
> On 4/28/26 9:31 AM, Ilias Apalodimas wrote:
> > 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().
> That I do understand, I think board_get_usable_ram_top(top) should by
> default return its input parameter "top" . If user does need to adjust
> their ram_top, they can override board_get_usable_ram_top() and possibly
> consume the "top" parameter too. That way, the user has the actual ram
> top at their disposal, and they can use it if they need it, instead of
> reimplementing the logic to get their ram top. Most users should ideally
> not override board_get_usable_ram_top() of course.

Ok, I'll add a call to that and adjust the default behavior of
board_get_usable_ram_top()


More information about the U-Boot mailing list