public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 1/2] of: addr: Abort address translation for parent nodes missing 'ranges'
@ 2021-02-26  7:35 Bin Meng
  2021-02-26  7:35 ` [PATCH 2/2] of: addr: Translate 'dma-ranges' for parent nodes missing 'dma-ranges' Bin Meng
  2021-03-03  1:54 ` [PATCH 1/2] of: addr: Abort address translation for parent nodes missing 'ranges' Simon Glass
  0 siblings, 2 replies; 22+ messages in thread
From: Bin Meng @ 2021-02-26  7:35 UTC (permalink / raw)
  To: u-boot

The implementation of of_translate_one() was taken from the one in
Linux kernel drivers/of/address.c, and the Linux one added a quirk
for Apple Macs that don't have the <ranges> property in the parent
node. Since U-Boot does not support Apple Macs, remove the comment
block and adhere to the spec to abort the translation.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 drivers/core/of_addr.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/core/of_addr.c b/drivers/core/of_addr.c
index 5bc6ca1..36cdfd3 100644
--- a/drivers/core/of_addr.c
+++ b/drivers/core/of_addr.c
@@ -173,25 +173,13 @@ static int of_translate_one(const struct device_node *parent,
 	int rone;
 	u64 offset = OF_BAD_ADDR;
 
-	/*
-	 * Normally, an absence of a "ranges" property means we are
-	 * crossing a non-translatable boundary, and thus the addresses
-	 * below the current cannot be converted to CPU physical ones.
-	 * Unfortunately, while this is very clear in the spec, it's not
-	 * what Apple understood, and they do have things like /uni-n or
-	 * /ht nodes with no "ranges" property and a lot of perfectly
-	 * useable mapped devices below them. Thus we treat the absence of
-	 * "ranges" as equivalent to an empty "ranges" property which means
-	 * a 1:1 translation at that level. It's up to the caller not to try
-	 * to translate addresses that aren't supposed to be translated in
-	 * the first place. --BenH.
-	 *
-	 * As far as we know, this damage only exists on Apple machines, so
-	 * This code is only enabled on powerpc. --gcl
-	 */
-
 	ranges = of_get_property(parent, rprop, &rlen);
-	if (ranges == NULL || rlen == 0) {
+	if (ranges == NULL) {
+		debug("no ranges; cannot translate\n");
+		return 1;
+	}
+
+	if (rlen == 0) {
 		offset = of_read_number(addr, na);
 		memset(addr, 0, pna * 4);
 		debug("empty ranges; 1:1 translation\n");
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2021-04-07 18:45 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 2/2] of: addr: Translate 'dma-ranges' for parent nodes missing 'dma-ranges' Bin Meng
2021-03-03  1:54   ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox