Hi Torsten, On 2026-09-25T10:54:32, Torsten Duwe <[email protected]> wrote: > core: skip parent device nodes without a DT reference when looking for > dma-ranges
How about 'dm: core: walk up to the first DT-associated parent for dma-ranges' ? > > 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 <[email protected]> > Signed-off-by: Torsten Duwe <[email protected]> > Reviewed-by: Peter Robinson <[email protected]> > Tested-by: Peter Robinson <[email protected]> > > drivers/core/device.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > diff --git a/drivers/core/device.c b/drivers/core/device.c > @@ -459,7 +459,19 @@ static int device_get_dma_constraints(struct udevice > *dev) > - 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; The comment 'Look for the first node in the parent chain' reads as if the loop finds any node - please make it explicit, e.g. 'Walk up until we find a parent that has a DT node'. The loop itself can drop the break: while (parent && !dev_has_ofnode(parent)) parent = dev_get_parent(parent); The existing comment immediately below says 'We start parsing for dma-ranges from the device's bus node. This is specially important on nested buses.' When we skip past dynamically-created intermediate buses we are no longer starting at the immediate bus node. I think that is fine because those nodes cannot carry a dma-ranges property anyway, but please spell that out in the commit message. Regards, Simon
