[PATCH v1 4/4] common: Add an optionto relocate on ram top

Ilias Apalodimas ilias.apalodimas at linaro.org
Fri Apr 10 07:21:06 CEST 2026


Hi Simon

[...]

> >
> > Also add a Kconfig option and allow the common code to relocate U-Boot
> > [...]
>
> > diff --git a/Kconfig b/Kconfig
> > @@ -491,6 +491,14 @@ config SKIP_RELOCATE_CODE_DATA_OFFSET
> > +config RELOC_ADDR_TOP
> > +     bool "Relocate to the topmost memory address"
> > +     help
> > +       When U-Boot relocates, it chooses the end of the first memory bank.
>
> Adding an explicit "depends on EXPERT" would be clearer, even though
> the surrounding menu structure implies it.

Fair enough, in the future we might not even need since I plan to fix
the 32 bit DMA issue.
Ideally we want this to be the default.

> Please can you add a
> warning in the help text that this should only be used if all devices
> can DMA to high memory?
>

Sure

> > diff --git a/common/board_f.c b/common/board_f.c
> > @@ -353,8 +357,19 @@ static int setup_ram_config(void)
> > +#if CONFIG_IS_ENABLED(RELOC_ADDR_TOP)
> > +     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;
> > +#else
> > +     gd->ram_top = gd->ram_base + get_effective_memsize();
> > +     gd->ram_top = board_get_usable_ram_top(gd->mon_len);
> > +#endif
>
> The RELOC_ADDR_TOP path does not call board_get_usable_ram_top()
>
> Some boards override this to keep ram_top below 4 GiB for DMA reasons
> (see arch/arm/mach-tegra/board2.c). Bypassing it means those
> constraints are silently ignored. Should board_get_usable_ram_top() be
> called after the loop?

I plan to fix the 32bit DMA. Calling board_get_usable_ram_top()
basically behaves as if RELOC_ADDR_TOP was not selected. So I prefer
leaving it as is. The commit message also hints about the fact that
board_get_usable_ram_top() will be skipped. If it's unclear I'd rather
tweak the Kconfig description.

Thanks
/Ilias
>
> Regards,
> Simon


More information about the U-Boot mailing list