[PATCH 2/2] of: addr: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'

Bin Meng bmeng.cn at gmail.com
Fri Feb 26 08:35:49 CET 2021


'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 at gmail.com>
---

 drivers/core/of_addr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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");
-- 
2.7.4



More information about the U-Boot mailing list