Re: [PATCH v3] of: reserved_mem: only support one <base size> entry in reg property
From: Rob Herring (Arm)
Date: Tue Jun 02 2026 - 11:25:47 EST
On Mon, 25 May 2026 20:17:00 +0800, Wandun Chen wrote:
> From: Wandun Chen <chenwandun@xxxxxxxxxxx>
>
> A /reserved-memory child node may have multiple <base size> tuples in
> 'reg' property, but multiple entries in 'reg' have never been fully
> functional:
> - fdt_scan_reserved_mem() in the early pass loops over every
> tuple and reserves them all.
>
> - fdt_scan_reserved_mem_late() reads 'reg' by
> of_flat_dt_get_addr_size(), which returns false if entries != 1.
> So 'reg' property with multiple <base size> entries will be
> skipped, no reserved_mem entry is created in reserved_mem[].
>
> Supporting multiple <base size> tuples is not a good idea:
> - It requires reserved_mem_ops->node_init support. Currently,
> CMA(rmem_cma_setup) and DMA(rmem_dma_setup) are not supported.
>
> - of_reserved_mem_lookup() is name-based, only the first entry in
> multiple <base size> tuples will be found.
>
> So change to support one <base size> entry in 'reg' property.
>
> Also update dt binding:
> https://github.com/devicetree-org/dt-schema/pull/197
>
> Suggested-by: Rob Herring <robh@xxxxxxxxxx>
> Signed-off-by: Wandun Chen <chenwandun@xxxxxxxxxxx>
> Tested-by: Meijing Zhao <zhaomeijing@xxxxxxxxxxx>
> Link: https://lore.kernel.org/all/20260506014752.GA280279-robh@xxxxxxxxxx/
>
> ---
> v2 --> v3:
> 1. Fix out-of-bounds issue in v2 if device tree contains an empty reg
> property [1].
>
> v1 --> v2:
> 1. Support only one entry in reg property, suggested by
> Rob Herring [2].
>
> [1] https://sashiko.dev/#/patchset/20260519082427.4181476-1-chenwandun%40lixiang.com?part=3
> [2] https://lore.kernel.org/all/20260429065831.1510858-1-chenwandun@xxxxxxxxxxx/T/#m29fa0f1c22c23e6343070e70f905c9482f930901
> ---
> drivers/of/of_reserved_mem.c | 43 ++++++++++++++++++++----------------
> 1 file changed, 24 insertions(+), 19 deletions(-)
>
Applied, thanks!