public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Revert "fdt: Fix fdtdec_get_addr_size() for 64-bit"
@ 2015-08-03  0:13 Simon Glass
  2015-08-03 15:12 ` Stephen Warren
                   ` (2 more replies)
  0 siblings, 3 replies; 34+ messages in thread
From: Simon Glass @ 2015-08-03  0:13 UTC (permalink / raw)
  To: u-boot

This reverts commit 5b34436035fc862b5e8d0d2c3eab74ba36f1a7f4.

This function has a few problems. It calls fdt_parent_offset() which as
mentioned in code review is very slow.

https://patchwork.ozlabs.org/patch/499482/
https://patchwork.ozlabs.org/patch/452604/

It also happens to break SPI flash on Minnowboard max which is how I noticed
that this was applied. I can send a patch to tidy that up, but in any case
I think we should consider a revert until the function is better implemented.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 lib/fdtdec.c | 56 ++++++++++++++++++++------------------------------------
 1 file changed, 20 insertions(+), 36 deletions(-)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index a954051..aac4f8d 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -90,45 +90,29 @@ const char *fdtdec_get_compatible(enum fdt_compat_id id)
 fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,
 		const char *prop_name, fdt_size_t *sizep)
 {
-	const fdt32_t *ptr, *end;
-	int parent, na, ns, len;
-	fdt_addr_t addr;
+	const fdt_addr_t *cell;
+	int len;
 
 	debug("%s: %s: ", __func__, prop_name);
-
-	parent = fdt_parent_offset(blob, node);
-	if (parent < 0) {
-		debug("(no parent found)\n");
-		return FDT_ADDR_T_NONE;
-	}
-
-	na = fdt_address_cells(blob, parent);
-	ns = fdt_size_cells(blob, parent);
-
-	ptr = fdt_getprop(blob, node, prop_name, &len);
-	if (!ptr) {
-		debug("(not found)\n");
-		return FDT_ADDR_T_NONE;
-	}
-
-	end = ptr + len / sizeof(*ptr);
-
-	if (ptr + na + ns > end) {
-		debug("(not enough data: expected %d bytes, got %d bytes)\n",
-		      (na + ns) * 4, len);
-		return FDT_ADDR_T_NONE;
-	}
-
-	addr = fdtdec_get_number(ptr, na);
-
-	if (sizep) {
-		*sizep = fdtdec_get_number(ptr + na, ns);
-		debug("addr=%pa, size=%pa\n", &addr, sizep);
-	} else {
-		debug("%pa\n", &addr);
+	cell = fdt_getprop(blob, node, prop_name, &len);
+	if (cell && ((!sizep && len == sizeof(fdt_addr_t)) ||
+		     len == sizeof(fdt_addr_t) * 2)) {
+		fdt_addr_t addr = fdt_addr_to_cpu(*cell);
+		if (sizep) {
+			const fdt_size_t *size;
+
+			size = (fdt_size_t *)((char *)cell +
+					sizeof(fdt_addr_t));
+			*sizep = fdt_size_to_cpu(*size);
+			debug("addr=%08lx, size=%llx\n",
+			      (ulong)addr, (u64)*sizep);
+		} else {
+			debug("%08lx\n", (ulong)addr);
+		}
+		return addr;
 	}
-
-	return addr;
+	debug("(not found)\n");
+	return FDT_ADDR_T_NONE;
 }
 
 fdt_addr_t fdtdec_get_addr(const void *blob, int node,
-- 
2.5.0.rc2.392.g76e840b

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

end of thread, other threads:[~2015-09-17  1:58 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-03  0:13 [U-Boot] [PATCH] Revert "fdt: Fix fdtdec_get_addr_size() for 64-bit" Simon Glass
2015-08-03 15:12 ` Stephen Warren
2015-08-03 15:52   ` Simon Glass
2015-08-03 17:25     ` Tom Rini
2015-08-03 17:27       ` Simon Glass
2015-08-03 18:20     ` Stephen Warren
2015-08-05  4:08       ` Simon Glass
2015-08-05 18:22         ` Stephen Warren
2015-08-05 23:45           ` Simon Glass
2015-08-06  7:09             ` Michal Suchanek
2015-08-06 18:43               ` Stephen Warren
2015-08-06 19:03             ` Stephen Warren
2015-08-09 15:08               ` Simon Glass
2015-08-14  8:10                 ` Bin Meng
2015-08-14  8:32                   ` Thierry Reding
2015-08-14  8:44                     ` Bin Meng
2015-08-14 14:06                       ` Thierry Reding
2015-08-14 14:29                         ` Bin Meng
2015-08-14  9:01                   ` Michal Suchanek
2015-08-14  9:08                     ` Bin Meng
2015-08-14 10:04                       ` Simon Glass
2015-09-02 16:52                         ` Tom Warren
2015-09-02 16:58                           ` Simon Glass
2015-09-02 20:04                           ` Stephen Warren
2015-09-02 20:39                             ` Tom Warren
2015-09-02 20:54                               ` Stephen Warren
2015-09-02 23:43                                 ` Stephen Warren
2015-09-03  2:02                                   ` Tom Warren
2015-09-16 21:46                                   ` Tom Warren
2015-09-17  1:10                                     ` Simon Glass
2015-09-17  1:58                                       ` Tom Warren
2015-08-14 16:50               ` Simon Glass
2015-08-03 15:40 ` Bin Meng
2015-08-04 15:27 ` Thierry Reding

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