[U-Boot] [PATCH 3/3] fdt: Fix fdtdec_get_pci_addr() for 64-bit
Thierry Reding
thierry.reding at gmail.com
Fri Mar 20 12:51:48 CET 2015
From: Thierry Reding <treding at nvidia.com>
The fdtdec_get_pci_addr() implementation uses fdt_addr_to_cpu() to read
cells from an FDT blob. That is wrong because cells are always 32 bits
wide, irrespective of the architecture's address bus width, which does
not apply to fdt_addr_t.
Besides reading the wrong results, this can also cause aborts on 64-bit
architectures that don't allow unaligned accesses to memory. Fix this by
using fdt32_to_cpu() to read the cells instead.
Cc: Hanna Hawa <hannah at marvell.com>
Cc: Simon Glass <sjg at chromium.org>
Signed-off-by: Thierry Reding <treding at nvidia.com>
---
lib/fdtdec.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index fd244440381e..c26b06f390b8 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -162,13 +162,13 @@ int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type,
for (i = 0; i < num; i++) {
debug("pci address #%d: %08lx %08lx %08lx\n", i,
- (ulong)fdt_addr_to_cpu(cell[0]),
- (ulong)fdt_addr_to_cpu(cell[1]),
- (ulong)fdt_addr_to_cpu(cell[2]));
+ (ulong)fdt32_to_cpu(cell[0]),
+ (ulong)fdt32_to_cpu(cell[1]),
+ (ulong)fdt32_to_cpu(cell[2]));
if ((fdt_addr_to_cpu(*cell) & type) == type) {
- addr->phys_hi = fdt_addr_to_cpu(cell[0]);
- addr->phys_mid = fdt_addr_to_cpu(cell[1]);
- addr->phys_lo = fdt_addr_to_cpu(cell[2]);
+ addr->phys_hi = fdt32_to_cpu(cell[0]);
+ addr->phys_mid = fdt32_to_cpu(cell[1]);
+ addr->phys_lo = fdt32_to_cpu(cell[2]);
break;
} else {
cell += (FDT_PCI_ADDR_CELLS +
--
2.3.2
More information about the U-Boot
mailing list