Skip to contentSkip to conversation

lib: fdt: Fix fdtdec_setup_mem..() conversion to livetree API

PATCH New Marek Vasut 4 participants 5 messages Sep 12, 2020 – Sep 17, 2020 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: fdt: Fix fdtdec_setup_mem..() conversion to livetree API

Repair incorrectly negated condition in the original patch which broke DT memory node parsing on everything which has more than one DT memory node, e.g. R-Car3.

In case multiple valid memory nodes are present in the DT, the original patch would complete parsing cycle for the first memory node, then move on to the next one, identify it as a valid, and end the parsing. The fix is to invert the condition, to make the code behave as it did before the livetree conversion, so it would continue parsing the subsequent memory nodes as well.

Fixes c2f0950c33 ("lib: fdt: Convert fdtdes_setup_mem..() to livetree API")
Cc Michal Simek <[email protected]>
Cc Simon Glass <[email protected]>
Cc Tom Rini <[email protected]>
---
 lib/fdtdec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/fdtdec.c +2 -2
index d3b22ec323..5f41f58a63 100644
@@ -1101,7 +1101,7 @@ int fdtdec_setup_memory_banksize(void)
 		if (ret < 0) {
 			reg = 0;
 			mem = get_next_memory_node(mem);
-			if (ofnode_valid(mem))
+			if (!ofnode_valid(mem))
 				break;
 
 			ret = ofnode_read_resource(mem, reg++, &res);
@@ -1146,7 +1146,7 @@ int fdtdec_setup_mem_size_base_lowest(void)
 		if (ret < 0) {
 			reg = 0;
 			mem = get_next_memory_node(mem);
-			if (ofnode_valid(mem))
+			if (!ofnode_valid(mem))
 				break;
 
 			ret = ofnode_read_resource(mem, reg++, &res);
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/1 lib: fdt: Fix fdtdec_setup_mem..() conversion to livetree API

Hi Marek,

Thanks for the patch.

Quoted 20 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Marek Vasut
Sent: 12 September 2020 11:43
To: u-boot at lists.denx.de
Cc: Marek Vasut <[email protected]>; Michal Simek <[email protected]>; Simon Glass <[email protected]>; Tom Rini <[email protected]>
Subject: [PATCH] lib: fdt: Fix fdtdec_setup_mem..() conversion to livetree API

Repair incorrectly negated condition in the original patch which broke DT memory node parsing on everything which has more than one DT memory node, e.g. R-Car3.

In case multiple valid memory nodes are present in the DT, the original patch would complete parsing cycle for the first memory node, then move on to the next one, identify it as a valid, and end the parsing. The fix is to invert the condition, to make the code behave as it did before the livetree conversion, so it would continue parsing the subsequent memory nodes as well.

Quoted 5 lines
Fixes c2f0950c33 ("lib: fdt: Convert fdtdes_setup_mem..() to livetree API")
Cc Michal Simek <[email protected]>
Cc Simon Glass <[email protected]>
Cc Tom Rini <[email protected]>

Tested this patch on following RZ/G2 Boards and it reports correct DRAM size with 2020.10 uboot master branch.

1) RZ/G2H (a.k.a r8a774e1)
2) RZ/G2M (a.k.a r8a774a1)
3) RZ/G2N (a.k.a r8a774b1)

Cheers,
Biju

Quoted 26 lines
---
 lib/fdtdec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/fdtdec.c +2 -3
@@ -1101,7 +1101,7 @@ int fdtdec_setup_memory_banksize(void)
 if (ret < 0) {
 reg = 0;
 mem = get_next_memory_node(mem);
-if (ofnode_valid(mem))
+if (!ofnode_valid(mem))
 break;
 
 ret = ofnode_read_resource(mem, reg++, &res);
@@ -1146,7 +1146,7 @@ int fdtdec_setup_mem_size_base_lowest(void)
 if (ret < 0) {
 reg = 0;
 mem = get_next_memory_node(mem);
-if (ofnode_valid(mem))
+if (!ofnode_valid(mem))
 break;
 
 ret = ofnode_read_resource(mem, reg++, &res);
--
Quoted 1 line

2.28.0

Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647

#2 lore raw

PATCH 1/1 lib: fdt: Fix fdtdec_setup_mem..() conversion to livetree API

In reply to Marek Vasut
Quoted 35 lines · Marek Vasut

Repair incorrectly negated condition in the original patch which broke DT memory node parsing on everything which has more than one DT memory node, e.g. R-Car3.

In case multiple valid memory nodes are present in the DT, the original patch would complete parsing cycle for the first memory node, then move on to the next one, identify it as a valid, and end the parsing. The fix is to invert the condition, to make the code behave as it did before the livetree conversion, so it would continue parsing the subsequent memory nodes as well.

Fixes c2f0950c33 ("lib: fdt: Convert fdtdes_setup_mem..() to livetree API")
Cc Michal Simek <[email protected]>
Cc Simon Glass <[email protected]>
Cc Tom Rini <[email protected]>
---
 lib/fdtdec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/fdtdec.c +1 -1
index d3b22ec323..5f41f58a63 100644
@@ -1101,7 +1101,7 @@ int fdtdec_setup_memory_banksize(void)
 		if (ret < 0) {
 			reg = 0;
 			mem = get_next_memory_node(mem);
-			if (ofnode_valid(mem))
+			if (!ofnode_valid(mem))
 				break;
 
 			ret = ofnode_read_resource(mem, reg++, &res);

lib/fdtdec.c int fdtdec_setup_mem_size_base_lowest(void) · line 1152

Quoted 8 lines
lib/fdtdec.c +1 -1
@@ -1146,7 +1146,7 @@ int fdtdec_setup_mem_size_base_lowest(void)
 		if (ret < 0) {
 			reg = 0;
 			mem = get_next_memory_node(mem);
-			if (ofnode_valid(mem))
+			if (!ofnode_valid(mem))
 				break;
 
 			ret = ofnode_read_resource(mem, reg++, &res);

We are not using multiple memory node. We use multiple tuples inside one memory node that's why it didn't come up. Good catch.

Tom: Can you please take it to your tree?

Thanks,
Michal

#3 lore raw

PATCH 1/1 lib: fdt: Fix fdtdec_setup_mem..() conversion to livetree API

Quoted 50 lines · Michal Simek
Quoted 35 lines · Marek Vasut

Repair incorrectly negated condition in the original patch which broke DT memory node parsing on everything which has more than one DT memory node, e.g. R-Car3.

In case multiple valid memory nodes are present in the DT, the original patch would complete parsing cycle for the first memory node, then move on to the next one, identify it as a valid, and end the parsing. The fix is to invert the condition, to make the code behave as it did before the livetree conversion, so it would continue parsing the subsequent memory nodes as well.

Fixes c2f0950c33 ("lib: fdt: Convert fdtdes_setup_mem..() to livetree API")
Cc Michal Simek <[email protected]>
Cc Simon Glass <[email protected]>
Cc Tom Rini <[email protected]>
---
 lib/fdtdec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/fdtdec.c +1 -1
index d3b22ec323..5f41f58a63 100644
@@ -1101,7 +1101,7 @@ int fdtdec_setup_memory_banksize(void)
 		if (ret < 0) {
 			reg = 0;
 			mem = get_next_memory_node(mem);
-			if (ofnode_valid(mem))
+			if (!ofnode_valid(mem))
 				break;
 
 			ret = ofnode_read_resource(mem, reg++, &res);

lib/fdtdec.c int fdtdec_setup_mem_size_base_lowest(void) · line 1152

Quoted 8 lines
lib/fdtdec.c +1 -1
@@ -1146,7 +1146,7 @@ int fdtdec_setup_mem_size_base_lowest(void)
 		if (ret < 0) {
 			reg = 0;
 			mem = get_next_memory_node(mem);
-			if (ofnode_valid(mem))
+			if (!ofnode_valid(mem))
 				break;
 
 			ret = ofnode_read_resource(mem, reg++, &res);

We are not using multiple memory node. We use multiple tuples inside one memory node that's why it didn't come up. Good catch.

Quoted 3 lines

Tom: Can you please take it to your tree?

Will do, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200915/7933c93e/attachment.sig>
#4 lore raw

PATCH 1/1 lib: fdt: Fix fdtdec_setup_mem..() conversion to livetree API

In reply to Marek Vasut
Quoted 11 lines · Marek Vasut

Repair incorrectly negated condition in the original patch which broke DT memory node parsing on everything which has more than one DT memory node, e.g. R-Car3.

In case multiple valid memory nodes are present in the DT, the original patch would complete parsing cycle for the first memory node, then move on to the next one, identify it as a valid, and end the parsing. The fix is to invert the condition, to make the code behave as it did before the livetree conversion, so it would continue parsing the subsequent memory nodes as well.

Quoted 7 lines
Fixes c2f0950c33 ("lib: fdt: Convert fdtdes_setup_mem..() to livetree API")
Cc Michal Simek <[email protected]>
Cc Simon Glass <[email protected]>
Cc Tom Rini <[email protected]>

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200917/da12ad53/attachment.sig>