Skip to contentSkip to conversation

fdt: Fix regression in fdt_pack_reg()

PATCH New Hans de Goede 5 participants 5 messages Nov 28, 2014 – Dec 1, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fdt: Fix regression in fdt_pack_reg()

After commit 933cdbb479: "fdt: Try to use fdt_address_cells()/fdt_size_cells()" I noticed that allwinner boards would no longer boot.

Switching to fdt_address_cells / fdt_size_cells changes the result from bytes to 32 bit words, so when we increment pointers into the blob, we must do so by 32 bit words now.

This commit makes allwinner boards boot again.

---
Changes in v2:
-Improved patch subject
-s/_len/_cells/ to indicated that adress_cells and size_cells are in cells now

---
 common/fdt_support.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
common/fdt_support.c +6 -6
index ea42c63..6254e34 100644
@@ -370,22 +370,22 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size,
 			int n)
 {
 	int i;
-	int address_len = fdt_address_cells(fdt, 0);
-	int size_len = fdt_size_cells(fdt, 0);
+	int address_cells = fdt_address_cells(fdt, 0);
+	int size_cells = fdt_size_cells(fdt, 0);
 	char *p = buf;
 
 	for (i = 0; i < n; i++) {
-		if (address_len == 2)
+		if (address_cells == 2)
 			*(fdt64_t *)p = cpu_to_fdt64(address[i]);
 		else
 			*(fdt32_t *)p = cpu_to_fdt32(address[i]);
-		p += address_len;
+		p += 4 * address_cells;
 
-		if (size_len == 2)
+		if (size_cells == 2)
 			*(fdt64_t *)p = cpu_to_fdt64(size[i]);
 		else
 			*(fdt32_t *)p = cpu_to_fdt32(size[i]);
-		p += size_len;
+		p += 4 * size_cells;
 	}
 
 	return p - (char *)buf;
Signature · 1 line
2.1.0
#1 lore raw

PATCH v2 1/1 fdt: Fix regression in fdt_pack_reg()

2014-11-28 22:23 GMT+09:00 Hans de Goede <[email protected]>:

Quoted 10 lines

After commit 933cdbb479: "fdt: Try to use fdt_address_cells()/fdt_size_cells()" I noticed that allwinner boards would no longer boot.

Switching to fdt_address_cells / fdt_size_cells changes the result from bytes to 32 bit words, so when we increment pointers into the blob, we must do so by 32 bit words now.

This commit makes allwinner boards boot again.

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw

PATCH v2 1/1 fdt: Fix regression in fdt_pack_reg()

In reply to Hans de Goede
Quoted 12 lines · Hans de Goede

After commit 933cdbb479: "fdt: Try to use fdt_address_cells()/fdt_size_cells()" I noticed that allwinner boards would no longer boot.

Switching to fdt_address_cells / fdt_size_cells changes the result from bytes to 32 bit words, so when we increment pointers into the blob, we must do so by 32 bit words now.

This commit makes allwinner boards boot again.

---
Changes in v2:

Review

Quoted 3 lines
(quoted diff) +0 -3
-Improved patch subject
-s/_len/_cells/ to indicated that adress_cells and size_cells are in cells now
---

Thanks for fixing this.

#3 lore raw

PATCH v2 1/1 fdt: Fix regression in fdt_pack_reg()

In reply to Hans de Goede
Quoted 10 lines · Hans de Goede

After commit 933cdbb479: "fdt: Try to use fdt_address_cells()/fdt_size_cells()" I noticed that allwinner boards would no longer boot.

Switching to fdt_address_cells / fdt_size_cells changes the result from bytes to 32 bit words, so when we increment pointers into the blob, we must do so by 32 bit words now.

This commit makes allwinner boards boot again.

Even if I'm a bit late with this answer, this fixes a regression on Linux booting on one of my mx6 boards. So:

Thanks,
Stefan

#4 lore raw

PATCH v2 1/1 fdt: Fix regression in fdt_pack_reg()

In reply to Hans de Goede

Hi,

Quoted 12 lines · Hans de Goede

After commit 933cdbb479: "fdt: Try to use fdt_address_cells()/fdt_size_cells()" I noticed that allwinner boards would no longer boot.

Switching to fdt_address_cells / fdt_size_cells changes the result from bytes to 32 bit words, so when we increment pointers into the blob, we must do so by 32 bit words now.

This commit makes allwinner boards boot again.

---
Changes in v2:

Review

Quoted 3 lines
(quoted diff) +0 -3
-Improved patch subject
-s/_len/_cells/ to indicated that adress_cells and size_cells are in cells now
---

I just hit this problem on jetson tk1 and tried the same fix. So

Thanks,
Vince

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------