[PATCH 1/3] core: Skip parent device nodes without a DT reference when looking for dma-ranges
Simon Glass
sjg at chromium.org
Fri May 8 20:47:45 CEST 2026
Hi Torsten,
On Fri, 8 May 2026 at 09:42, Torsten Duwe <duwe at lst.de> wrote:
>
> From: Torsten Duwe <duwe at suse.de>
>
> If a device node got created dynamically, there is no guarantee that the
> parent node has an associated device tree node which could specify dma
> constraints. Especially PCI(e) enumeration adds intermediate "bus nodes",
> also dynamically.
>
> Try harder to find the correct configuration by walking up the tree until
> a DT association is found.
>
> Suggested-by: Neil Armstrong <neil.armstrong at linaro.org>
> Signed-off-by: Torsten Duwe <duwe at suse.de>
>
> ---
> drivers/core/device.c | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/core/device.c b/drivers/core/device.c
> index 779f371b9d5..9de64dbb3c5 100644
> --- a/drivers/core/device.c
> +++ b/drivers/core/device.c
> @@ -459,7 +459,19 @@ static int device_get_dma_constraints(struct udevice *dev)
> u64 size = 0;
> int ret;
>
> - if (!CONFIG_IS_ENABLED(DM_DMA) || !parent || !dev_has_ofnode(parent))
> + if (!CONFIG_IS_ENABLED(DM_DMA) || !parent)
> + return 0;
> +
> + /* Look for the first node in the parent chain */
> + while (parent) {
> + if (dev_has_ofnode(parent))
> + break;
> +
> + parent = dev_get_parent(parent);
> + }
> +
> + /* No parents have a node, bail out */
> + if (!parent)
> return 0;
>
> /*
> --
> 2.54.0
>
There's already a unit test for device_get_dma_constraints() in
test/dm/read.c (dm_test_dma_ranges). Since you are extending it to
walk past nodes without an ofnode, please can you add a case
exercising the new path - a sandbox device whose immediate parent has
no DT reference should do it.
Regards,
Simon
More information about the U-Boot
mailing list