public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH 2/2] of: addr: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'
Date: Fri, 26 Feb 2021 15:35:49 +0800	[thread overview]
Message-ID: <1614324949-61314-2-git-send-email-bmeng.cn@gmail.com> (raw)
In-Reply-To: <1614324949-61314-1-git-send-email-bmeng.cn@gmail.com>

'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(-)

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

  reply	other threads:[~2021-02-26  7:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-26  7:35 [PATCH 1/2] of: addr: Abort address translation for parent nodes missing 'ranges' Bin Meng
2021-02-26  7:35 ` Bin Meng [this message]
2021-03-03  1:54   ` [PATCH 2/2] of: addr: Translate 'dma-ranges' for parent nodes missing 'dma-ranges' Simon Glass
2021-03-03  1:54 ` [PATCH 1/2] of: addr: Abort address translation for parent nodes missing 'ranges' Simon Glass
2021-03-15  7:11   ` Simon Glass
2021-03-15 14:47     ` Bin Meng
2021-03-15 18:23       ` Simon Glass
2021-03-15 22:49         ` Dario Binacchi
2021-03-16  1:28           ` Bin Meng
2021-03-16 20:57             ` Dario Binacchi
2021-03-17  1:26               ` Bin Meng
2021-03-18  7:27                 ` Dario Binacchi
2021-03-18 19:51                   ` Tom Rini
2021-03-21 15:19                     ` Dario Binacchi
2021-03-22  1:25                       ` Bin Meng
2021-03-23 17:27                         ` Dario Binacchi
2021-03-24  1:35                           ` Bin Meng
2021-04-06 14:26                 ` Rob Herring
2021-04-06 21:52                   ` Dario Binacchi
2021-04-07 14:42                     ` Rob Herring
2021-04-07 16:14                       ` Simon Glass
2021-04-07 18:45                         ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1614324949-61314-2-git-send-email-bmeng.cn@gmail.com \
    --to=bmeng.cn@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox