Message ID | 1614324949-61314-2-git-send-email-bmeng.cn@gmail.com |
---|---|
State | Changes Requested |
Delegated to: | Simon Glass |
Headers | show |
Series | [1/2] of: addr: Abort address translation for parent nodes missing 'ranges' | expand |
On Fri, 26 Feb 2021 at 00:36, Bin Meng <bmeng.cn@gmail.com> wrote: > > 'dma-ranges' frequently exists without parent nodes having 'dma-ranges'. > While this is an error for 'ranges', this is fine because DMA capable > devices always have a translatable DMA address. Also, with no > 'dma-ranges' at all, the assumption is that DMA addresses are 1:1 with > no restrictions unless perhaps the device itself has implicit > restrictions. > > This keeps in sync with Linux kernel commit: > > 81db12ee15cb: of/address: Translate 'dma-ranges' for parent nodes missing 'dma-ranges' > > Signed-off-by: Bin Meng <bmeng.cn@gmail.com> > --- > > drivers/core/of_addr.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/core/of_addr.c b/drivers/core/of_addr.c index 36cdfd3..b9abf90 100644 --- a/drivers/core/of_addr.c +++ b/drivers/core/of_addr.c @@ -174,12 +174,12 @@ static int of_translate_one(const struct device_node *parent, u64 offset = OF_BAD_ADDR; ranges = of_get_property(parent, rprop, &rlen); - if (ranges == NULL) { + if (ranges == NULL && strcmp(rprop, "dma-ranges")) { debug("no ranges; cannot translate\n"); return 1; } - if (rlen == 0) { + if (ranges == NULL || rlen == 0) { offset = of_read_number(addr, na); memset(addr, 0, pna * 4); debug("empty ranges; 1:1 translation\n");
'dma-ranges' frequently exists without parent nodes having 'dma-ranges'. While this is an error for 'ranges', this is fine because DMA capable devices always have a translatable DMA address. Also, with no 'dma-ranges' at all, the assumption is that DMA addresses are 1:1 with no restrictions unless perhaps the device itself has implicit restrictions. This keeps in sync with Linux kernel commit: 81db12ee15cb: of/address: Translate 'dma-ranges' for parent nodes missing 'dma-ranges' Signed-off-by: Bin Meng <bmeng.cn@gmail.com> --- drivers/core/of_addr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)