[PATCH v2 01/16] lib: fdtdec: Handle multiple memory nodes

Simon Glass sjg at chromium.org
Thu Jul 2 12:22:14 CEST 2026


Hi Jiaxun,

On 2026-07-01T11:17:53, Yao Zi <me at ziyao.cc> wrote:
> lib: fdtdec: Handle multiple memory nodes
>
> Current code only tries to fetch the first memory node found in
> fdt tree and determine memory banks from multiple reg properties.
>
> Specification allows multiple memory nodes in devicetree, rework
> fdtdec_setup_mem_size_base_lowest and fdtdec_setup_memory_banksize
> to iterate over all memory nodes.
>
> Signed-off-by: Jiaxun Yang <jiaxun.yang at flygoat.com>
> Signed-off-by: Yao Zi <me at ziyao.cc>
>
> include/asm-generic/global_data.h |   2 +-
>  lib/fdtdec.c                      | 129 ++++++++++++++++++++++----------------
>  2 files changed, 76 insertions(+), 55 deletions(-)

> diff --git a/lib/fdtdec.c b/lib/fdtdec.c
> @@ -1115,90 +1116,110 @@ ofnode fdtdec_get_next_memory_node(ofnode mem)
> +too_may_memory_banks:
> +     log_warning("%s: Too many memory banks\n", __func__);
> +     return -EINVAL;
> +}

Typo - too_may_memory_banks should be too_many_memory_banks. While
you are here, please drop the goto... bank is bounded, so a single
check after the loops (or bank < CONFIG_NR_DRAM_BANKS in the inner
while) gives a single return path.

> diff --git a/lib/fdtdec.c b/lib/fdtdec.c
> @@ -1115,90 +1116,110 @@ ofnode fdtdec_get_next_memory_node(ofnode mem)
> +                     log_debug("%s: DRAM Bank #%d %s.%d: start = 0x%llx, size = 0x%llx\n",
> +                               __func__, bank, ofnode_get_name(mem), reg,
> +                              (unsigned long long)gd->dram[bank].start,
> +                              (unsigned long long)gd->dram[bank].size);

The current code uses %pap with &gd->dram[bank].start, which is the
idiomatic way to print phys_addr_t/phys_size_t iand should avoid
needing casts. Can you keep %pap here (and in the message below)?

> diff --git a/lib/fdtdec.c b/lib/fdtdec.c
> @@ -1115,90 +1116,110 @@ ofnode fdtdec_get_next_memory_node(ofnode mem)
> +     while (true) {
> +             struct resource res;
> +             phys_size_t base, size;
> +             int reg = 0;

You should really use phys_addr_t for base

Regards,
Simon


More information about the U-Boot mailing list