Skip to contentSkip to conversation

Two mpfs icicle init fixes

PATCH In review Conor Dooley 2 participants 5 messages May 15, 2024 – May 30, 2024

lore
Share & tools
lore
#0 lore raw

cover Two mpfs icicle init fixes

From: Conor Dooley <[email protected]>

Two fixes for issues that I spotted today while looking into passing a minimal dtb to U-Boot from the first bootloader stage. This minimal dtb had no ethernet nodes, and the code in this patches fell over :\

Cheers,
Conor.
---
CC: Padmarao Begari <[email protected]>
CC: Cyril Jean <[email protected]>
CC: Tom Rini <[email protected]>
CC: Conor Dooley <[email protected]>
CC: [email protected]

Conor Dooley (2):
board: microchip: icicle: correct type for node offset
board: microchip: icicle: make both ethernets optional

 board/microchip/mpfs_icicle/mpfs_icicle.c | 25 ++++++++---------------
 1 file changed, 8 insertions(+), 17 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 board: microchip: icicle: correct type for node offset

From: Conor Dooley <[email protected]>

Node offsets returned by libfdt can contain negative error numbers, so the variable type should be "int". As things stand, if the ethernet nodes are not found in the early init callback, the if (node < 0) tests pass and the code errors out while trying to set the local-mac-address for a non-existent node.

Fixes 64413e1b7c ("riscv: Add Microchip MPFS Icicle Kit support")
---
 board/microchip/mpfs_icicle/mpfs_icicle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/microchip/mpfs_icicle/mpfs_icicle.c +1 -1
index 7beac33cfb..5fd0ec66a9 100644
@@ -72,7 +72,7 @@ int board_early_init_f(void)
 int board_late_init(void)
 {
 	u32 ret;
-	u32 node;
+	int node;
 	u8 idx;
 	u8 device_serial_number[16] = { 0 };
 	unsigned char mac_addr[6];
Signature · 1 line
2.43.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH v1 1/2] board: microchip: icicle: correct type for node offset

Quoted 8 lines · Conor Dooley

From: Conor Dooley <[email protected]>

Node offsets returned by libfdt can contain negative error numbers, so the variable type should be "int". As things stand, if the ethernet nodes are not found in the early init callback, the if (node < 0) tests pass and the code errors out while trying to set the local-mac-address for a non-existent node.

Quoted 5 lines
Fixes 64413e1b7c ("riscv: Add Microchip MPFS Icicle Kit support")
---
 board/microchip/mpfs_icicle/mpfs_icicle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#3 lore raw

PATCH 2/2 board: microchip: icicle: make both ethernets optional

In reply to Conor Dooley

From: Conor Dooley <[email protected]>

A given AMP configuration for a board may make either one, or neither of, the ethernet ports available to U-Boot. The Icicle's init code will fail if mac1 is not present, so move it to the optional approach taken for mac0.

---
 board/microchip/mpfs_icicle/mpfs_icicle.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)
board/microchip/mpfs_icicle/mpfs_icicle.c +7 -16
index 5fd0ec66a9..4d7d843dfa 100644
@@ -79,18 +79,6 @@ int board_late_init(void)
 	char icicle_mac_addr[20];
 	void *blob = (void *)gd->fdt_blob;
 
-	node = fdt_path_offset(blob, "/soc/ethernet@20112000");
-	if (node < 0) {
-		printf("No ethernet0 path offset\n");
-		return -ENODEV;
-	}
-
-	ret = fdtdec_get_byte_array(blob, node, "local-mac-address", mac_addr, 6);
-	if (ret) {
-		printf("No local-mac-address property for ethernet@20112000\n");
-		return -EINVAL;
-	}
-
 	read_device_serial_number(device_serial_number, 16);
 
 	/* Update MAC address with device serial number */
@@ -101,10 +89,13 @@ int board_late_init(void)
 	mac_addr[4] = device_serial_number[1];
 	mac_addr[5] = device_serial_number[0];
 
-	ret = fdt_setprop(blob, node, "local-mac-address", mac_addr, 6);
-	if (ret) {
-		printf("Error setting local-mac-address property for ethernet@20112000\n");
-		return -ENODEV;
+	node = fdt_path_offset(blob, "/soc/ethernet@20112000");
+	if (node >= 0) {
+		ret = fdt_setprop(blob, node, "local-mac-address", mac_addr, 6);
+		if (ret) {
+			printf("Error setting local-mac-address property for ethernet@20112000\n");
+			return -ENODEV;
+		}
 	}
 
 	icicle_mac_addr[0] = '[';
Signature · 1 line
2.43.0
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH v1 2/2] board: microchip: icicle: make both ethernets optional

Quoted 11 lines · Conor Dooley

From: Conor Dooley <[email protected]>

A given AMP configuration for a board may make either one, or neither of, the ethernet ports available to U-Boot. The Icicle's init code will fail if mac1 is not present, so move it to the optional approach taken for mac0.

---
 board/microchip/mpfs_icicle/mpfs_icicle.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)