ARM: mx28: Skip OCOTP FEC MAC setup if in DT
Subsystems (3)
PATCH 1/1 ARM: mx28: Skip OCOTP FEC MAC setup if in DT
Currently, the kernel unconditionally adds "local-mac-address" and "mac-address" properties under both FEC ethernet DT nodes in case the update_fec_mac_prop() function is called. These properties are loaded with MAC address compiled from vendors OUI and a per-device NIC saved in OCOTP storage.
Some more advanced bootloaders do augment the DT passed to the kernel by these properties already. In such case, it is wrong for kernel to override these values.
Adjust the FEC MAC address loading so that in case the DT properties are already present in the DT passed from the bootloader, skip the loading from OCOTP altogether. If the DT properties are not present, load them from OCOTP.
Note that the later case will lead to zeroed out MAC address if OCOTP is not programmed. This will lead to FEC not working at all.
--- arch/arm/mach-mxs/mach-mxs.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/mach-mxs/mach-mxs.c +4 -0
@@ -175,6 +175,10 @@ static void __init update_fec_mac_prop(enum mac_oui oui) np =of_find_compatible_node (from,NULL ,"fsl,imx28-fec" );if (!np)return ; + +if (of_get_property (np,"local-mac-address" ,NULL )) +continue ; + from = np; newmac =kzalloc (sizeof (*newmac) +6 ,GFP_KERNEL );
Signature · 1 line
1.7.10.4
PATCH 1/1 ARM: mx28: Skip OCOTP FEC MAC setup if in DT
Quoted 30 lines · Marek Vasut
Currently, the kernel unconditionally adds "local-mac-address" and "mac-address" properties under both FEC ethernet DT nodes in case the
update_fec_mac_prop()function is called. These properties are loaded with MAC address compiled from vendors OUI and a per-device NIC saved in OCOTP storage.Some more advanced bootloaders do augment the DT passed to the kernel by these properties already. In such case, it is wrong for kernel to override these values.
Adjust the FEC MAC address loading so that in case the DT properties are already present in the DT passed from the bootloader, skip the loading from OCOTP altogether. If the DT properties are not present, load them from OCOTP.
Note that the later case will lead to zeroed out MAC address if OCOTP is not programmed. This will lead to FEC not working at all.
Signed-off-by Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Shawn Guo <[email protected]>--- arch/arm/mach-mxs/mach-mxs.c | 4 ++++ 1 file changed, 4 insertions(+)arch/arm/mach-mxs/mach-mxs.c +0
-0
arch/arm/mach-mxs/mach-mxs.c static void __init update_fec_mac_prop(enum mac_oui oui) · line 181
Quoted 7 lines
arch/arm/mach-mxs/mach-mxs.c +4
-0@@ -175,6 +175,10 @@ static void __init update_fec_mac_prop(enum mac_oui oui) np =of_find_compatible_node (from,NULL ,"fsl,imx28-fec" );if (!np)return ; + +if (of_get_property (np,"local-mac-address" ,NULL )) +continue ; +
The block should be put after "from" assignment below.
arch/arm/mach-mxs/mach-mxs.c static void __init update_fec_mac_prop(enum mac_oui oui) · line 182
Quoted 1 line
arch/arm/mach-mxs/mach-mxs.c +0
-0from = np;
Shawn
Quoted 5 lines
arch/arm/mach-mxs/mach-mxs.c +0
-0newmac =kzalloc (sizeof (*newmac) +6 ,GFP_KERNEL );Signature · 1 line
1.7.10.4
PATCH 1/1 ARM: mx28: Skip OCOTP FEC MAC setup if in DT
Dear Shawn Guo,
Quoted 37 lines · Marek Vasut
Quoted 36 lines
Currently, the kernel unconditionally adds "local-mac-address" and "mac-address" properties under both FEC ethernet DT nodes in case the
update_fec_mac_prop()function is called. These properties are loaded with MAC address compiled from vendors OUI and a per-device NIC saved in OCOTP storage.Some more advanced bootloaders do augment the DT passed to the kernel by these properties already. In such case, it is wrong for kernel to override these values.
Adjust the FEC MAC address loading so that in case the DT properties are already present in the DT passed from the bootloader, skip the loading from OCOTP altogether. If the DT properties are not present, load them from OCOTP.
Note that the later case will lead to zeroed out MAC address if OCOTP is not programmed. This will lead to FEC not working at all.
Signed-off-by Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Shawn Guo <[email protected]>---
arch/arm/mach-mxs/mach-mxs.c | 4 ++++ 1 file changed, 4 insertions(+)arch/arm/mach-mxs/mach-mxs.c +0
-0@@ -175,6 +175,10 @@ static void __init update_fec_mac_prop(enum mac_oui oui) np =of_find_compatible_node (from,NULL ,"fsl,imx28-fec" );if (!np)
Quoted 8 lines
arch/arm/mach-mxs/mach-mxs.c static void __init update_fec_mac_prop(enum mac_oui oui) · line 181
Quoted 6 lines
arch/arm/mach-mxs/mach-mxs.c +4
-0return ; + +if (of_get_property (np,"local-mac-address" ,NULL )) +continue ; +The block should be put after "from" assignment below.
Can you please elaborate why would that be necessary?
Best regards,
Marek Vasut
PATCH 1/1 ARM: mx28: Skip OCOTP FEC MAC setup if in DT
Quoted 5 lines · Marek Vasut
Quoted 5 lines
Quoted 5 lines
arch/arm/mach-mxs/mach-mxs.c +0
-0np =of_find_compatible_node (from,NULL ,"fsl,imx28-fec" );if (!np)return ;
Quoted 9 lines
Quoted 6 lines
arch/arm/mach-mxs/mach-mxs.c static void __init update_fec_mac_prop(enum mac_oui oui) · line 181
Quoted 4 lines
arch/arm/mach-mxs/mach-mxs.c +4
-0+ +if (of_get_property (np,"local-mac-address" ,NULL )) +continue ; +The block should be put after "from" assignment below.
Can you please elaborate why would that be necessary?
Without assigning 'np' to 'from', the next iteration of 'for' loop will still find the first fec node. Then what's point of 'continue'?
Shawn
PATCH 1/1 ARM: mx28: Skip OCOTP FEC MAC setup if in DT
Dear Shawn Guo,
Quoted 2 lines · Marek Vasut
Quoted 1 line
Quoted 1 line
Quoted 1 line
np = of_find_compatible_node(from, NULL, "fsl,imx28-
fec");
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
arch/arm/mach-mxs/mach-mxs.c static void __init update_fec_mac_prop(enum mac_oui oui) · line 181
Quoted 8 lines
arch/arm/mach-mxs/mach-mxs.c +4
-0if (!np)return ; + +if (of_get_property (np,"local-mac-address" ,NULL )) +continue ; +The block should be put after "from" assignment below.
Quoted 4 lines
Quoted 1 line
Can you please elaborate why would that be necessary?
Without assigning 'np' to 'from', the next iteration of 'for' loop will still find the first fec node. Then what's point of 'continue'?
Ewww, you're right.
Quoted 1 line
Shawn
Best regards,
Marek Vasut