[PATCH] [RFC] lmb: Optionally limit available memory to 4 GiB on limited systems

Ilias Apalodimas ilias.apalodimas at linaro.org
Wed Jun 3 13:25:40 CEST 2026


On Wed, 3 Jun 2026 at 14:20, Peter Robinson <pbrobinson at gmail.com> wrote:
>
> On Wed, 3 Jun 2026 at 12:12, Marek Vasut <marek.vasut at mailbox.org> wrote:
> >
> > On 6/3/26 1:02 PM, Peter Robinson wrote:
> > > On Sat, 30 May 2026 at 16:06, Marek Vasut <marek.vasut at mailbox.org> wrote:
> > >>
> > >> On 5/30/26 4:45 PM, Marek Vasut wrote:
> > >>> Some architectures can not DMA above 4 GiB boundary,
> > >>> limit available memory to memory below 4 GiB boundary.
> > >>>
> > >>> Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
> > >>> ---
> > >>> Cc: Andrew Goodbody <andrew.goodbody at linaro.org>
> > >>> Cc: David Lechner <dlechner at baylibre.com>
> > >>> Cc: Heiko Schocher <hs at nabladev.com>
> > >>> Cc: Heinrich Schuchardt <xypron.glpk at gmx.de>
> > >>> Cc: Holger Brunck <holger.brunck at hitachienergy.com>
> > >>> Cc: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> > >>> Cc: Peter Robinson <pbrobinson at gmail.com>
> > >>> Cc: Quentin Schulz <quentin.schulz at cherry.de>
> > >>> Cc: Simon Glass <sjg at chromium.org>
> > >>> Cc: Sughosh Ganu <sughosh.ganu at arm.com>
> > >>> Cc: Tom Rini <trini at konsulko.com>
> > >>> Cc: u-boot at lists.denx.de
> > >>> ---
> > >>>    lib/Kconfig |  8 ++++++++
> > >>>    lib/lmb.c   | 20 +++++++++++++++++++-
> > >>>    2 files changed, 27 insertions(+), 1 deletion(-)
> > >>>
> > >>> diff --git a/lib/Kconfig b/lib/Kconfig
> > >>> index 77ebc79e1db..29911068a69 100644
> > >>> --- a/lib/Kconfig
> > >>> +++ b/lib/Kconfig
> > >>> @@ -1295,6 +1295,14 @@ config SPL_LMB_ARCH_MEM_MAP
> > >>>          memory map. Enable this config in such scenarios which allow
> > >>>          architectures and boards to define their own memory map.
> > >>>
> > >>> +config LMB_LIMIT_DMA_BELOW_4G
> > >>> +     bool
> > >>> +     depends on LMB
> > >>> +     default y if ARCH_BCM283X
> > >>> +     help
> > >>> +       Some architectures can not DMA above 4 GiB boundary,
> > >>> +       limit available memory to memory below 4 GiB boundary.
> > >>> +
> > >>>    config PHANDLE_CHECK_SEQ
> > >>>        bool "Enable phandle check while getting sequence number"
> > >>>        help
> > >>> diff --git a/lib/lmb.c b/lib/lmb.c
> > >>> index 8f12c6ad8e5..a8a988eedc0 100644
> > >>> --- a/lib/lmb.c
> > >>> +++ b/lib/lmb.c
> > >>> @@ -611,6 +611,7 @@ static __maybe_unused void lmb_reserve_common_spl(void)
> > >>>    static void lmb_add_memory(void)
> > >>>    {
> > >>>        int i;
> > >>> +     phys_addr_t bank_end;
> > >>>        phys_size_t size;
> > >>>        u64 ram_top = gd->ram_top;
> > >>>        struct bd_info *bd = gd->bd;
> > >>> @@ -625,8 +626,25 @@ static void lmb_add_memory(void)
> > >>>        for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
> > >>>                size = bd->bi_dram[i].size;
> > >>>
> > >>> -             if (size)
> > >>> +             if (size) {
> > >>>                        lmb_add(bd->bi_dram[i].start, size);
> > >>> +                     if (IS_ENABLED(CONFIG_LMB_LIMIT_DMA_BELOW_4G))
> > >>
> > >> This conditional should be inverted.
> > >>
> > >> Peter Robinson , can you test this change on RPi ?
> > >
> > > That doesn't fix the problem for me on a RPi4 4GB or a RPi5 8Gb.
> > Did you invert the if (IS_ENABLED...) conditional ?
> >
> > Was CONFIG_LMB_LIMIT_DMA_BELOW_4G enabled in your config (maybe the
> > Kconfig entry "default y" part needs to be tweaked to cover these devices?)
> >
> > If both conditions are met, that should behave like the old code.
>
> I dropped my revert and applied the patch, checked the new config
> option was in the generated .config (I mean you could test that with a
> "make rpi_arm64_defconfig" and checking the output).

You need to invert the logic of IS_ENABLED() for this patch to work.
Marek obviously missed a !

Cheers
Ilias
>
> Peter


More information about the U-Boot mailing list