Skip to contentSkip to conversation

ARM: mx28: Skip OCOTP FEC MAC setup if in DT

PATCH Superseded Marek Vasut 2 participants 11 messages Sep 25, 2012 – Oct 30, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

Cc Fabio Estevam <[email protected]>
Cc Shawn Guo <[email protected]>
---
 arch/arm/mach-mxs/mach-mxs.c |    4 ++++
 1 file changed, 4 insertions(+)

V2: Assign from variable before checking for the "local-mac-address" property.
As Shawn explained, this prevents the function from repeatedly finding the first FEC.

arch/arm/mach-mxs/mach-mxs.c +4 -0
index 86a9343..c1f3c79 100644
@@ -175,8 +175,12 @@ static void __init update_fec_mac_prop(enum mac_oui oui)
 		np = of_find_compatible_node(from, NULL, "fsl,imx28-fec");
 		if (!np)
 			return;
+
 		from = np;
 
+		if (of_get_property(np, "local-mac-address", NULL))
+			continue;
+
 		newmac = kzalloc(sizeof(*newmac) + 6, GFP_KERNEL);
 		if (!newmac)
 			return;
Signature · 1 line
1.7.10.4
Applied
#1 lore raw

PATCH v2 1/1 ARM: mx28: Skip OCOTP FEC MAC setup if in DT

Quoted 15 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.

Quoted 6 lines

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.

Cc Fabio Estevam <[email protected]>
Cc Shawn Guo <[email protected]>

Queued for 3.8, thanks.

#2 lore raw

PATCH v2 1/1 ARM: mx28: Skip OCOTP FEC MAC setup if in DT

Dear Shawn Guo,

Quoted 16 lines · Marek Vasut
Quoted 15 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.

Quoted 8 lines
Quoted 6 lines

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.

Cc Fabio Estevam <[email protected]>
Cc Shawn Guo <[email protected]>

Queued for 3.8, thanks.

Ain't this a bugfix? So maybe CC stable etc. ?

Best regards,
Marek Vasut

#3 lore raw

PATCH v2 1/1 ARM: mx28: Skip OCOTP FEC MAC setup if in DT

Sorry, I just dropped the patch, and you need to convince me that the patch is actually needed to fix a bug.

Quoted 9 lines · Marek Vasut

Dear Shawn Guo,

Quoted 7 lines · Marek Vasut
Quoted 6 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.

The function update_fec_mac_prop is only called for imx28-evk and m28evk boards which are known having valid/unique MAC address programmed in OCOTP. In that case, shouldn't we always read MAC from OCOTP instead of trusting the "local-mac-address" property from device tree, which might stand a chance that it's not valid or unique?

Shawn

Quoted 22 lines
Quoted 9 lines
Quoted 9 lines

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.

Quoted 8 lines
Quoted 6 lines

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.

Cc Fabio Estevam <[email protected]>
Cc Shawn Guo <[email protected]>

Queued for 3.8, thanks.

Ain't this a bugfix? So maybe CC stable etc. ?

Best regards,
Marek Vasut

#4 lore raw

PATCH v2 1/1 ARM: mx28: Skip OCOTP FEC MAC setup if in DT

Dear Shawn Guo,

Quoted 13 lines

Sorry, I just dropped the patch, and you need to convince me that the patch is actually needed to fix a bug.

Quoted 8 lines · Marek Vasut

Dear Shawn Guo,

Quoted 6 lines · Marek Vasut
Quoted 5 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.

Quoted 3 lines

The function update_fec_mac_prop is only called for imx28-evk and m28evk boards which are known having valid/unique MAC address programmed in OCOTP.

Actually I disabled it on m28, since the OCOTP is not always programmed. The board is shipped with blank OCOTP. The imx28-evk is shipped with blank OCOTP as well, no?

Quoted 3 lines

In that case, shouldn't we always read MAC from OCOTP instead of trusting the "local-mac-address" property from device tree, which might stand a chance that it's not valid or unique?

Definitelly not. If the bootloader doesn't pass correct local-mac-address property, the bootloader is broken and it is not our problem (any invalid DT passed from bootloader is not our problem and is not fixed by us ... most of the time). On the other hand:

1) if it doesn't pass any local-mac-address property, it is safe to read from OCOTP (this is the case of bootlets) to fill in the blank with at least something ... even though if the OCOTP is empty, FEC won't work anyway.

2) if the bootloader does pass a local-mac-address property, then it is intentional and it can be later overriden anyway by "ifconfig ... hw ether" if needed .

If the bootloader does pass such information, it is either sourced from OCOTP (in which case it might fall back to 1) and pass nothing ) or elsewhere, in which case it's 2) and the bootloader has obviously better knowledge of the hardware than we do.

I firmly disagree with force-overriding the DT properties, since esp. in case of development kits, it doesn't give the users the freedom to program their OCOTP the way they need it to.

Also, the users don't have freedom to frob with their MAC address easily -- when the OCOTP isn't programmed yet, their FEC won't work, for example in case of NFS root filesystem, this is a problem. With this patch, you don't have the problem.

Quoted 24 lines

Shawn

Quoted 22 lines
Quoted 9 lines
Quoted 9 lines

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.

Quoted 8 lines
Quoted 6 lines

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.

Cc Fabio Estevam <[email protected]>
Cc Shawn Guo <[email protected]>

Queued for 3.8, thanks.

Ain't this a bugfix? So maybe CC stable etc. ?

Best regards,
Marek Vasut

Best regards,
Marek Vasut

#5 lore raw

PATCH v2 1/1 ARM: mx28: Skip OCOTP FEC MAC setup if in DT

Quoted 15 lines · Marek Vasut

Dear Shawn Guo,

Quoted 13 lines

Sorry, I just dropped the patch, and you need to convince me that the patch is actually needed to fix a bug.

Quoted 8 lines · Marek Vasut

Dear Shawn Guo,

Quoted 6 lines · Marek Vasut
Quoted 5 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.

Quoted 6 lines
Quoted 3 lines

The function update_fec_mac_prop is only called for imx28-evk and m28evk boards which are known having valid/unique MAC address programmed in OCOTP.

Actually I disabled it on m28, since the OCOTP is not always programmed. The board is shipped with blank OCOTP.

Then removing the call to update_fec_mac_prop for m28 is enough.

Quoted 3 lines

The imx28-evk is shipped with blank OCOTP as
well, no?

No. imx28-evk is shipped with MAC programmed into OCOTP.

Quoted 8 lines
Quoted 3 lines

In that case, shouldn't we always read MAC from OCOTP instead of trusting the "local-mac-address" property from device tree, which might stand a chance that it's not valid or unique?

Definitelly not. If the bootloader doesn't pass correct local-mac-address property, the bootloader is broken and it is not our problem (any invalid DT passed from bootloader is not our problem and is not fixed by us ... most of the time).

It is our problem. We shouldn't trust bootloader on that whenever it's possible for ourselves to figure it out. You can say "hey bootloader, this is your problem not ours", but FEC driver in kernel is not working. Isn't it a problem for kernel when FEC is not working?

Quoted 15 lines

On the other hand:

1) if it doesn't pass any local-mac-address property, it is safe to read from OCOTP (this is the case of bootlets) to fill in the blank with at least something ... even though if the OCOTP is empty, FEC won't work anyway.

2) if the bootloader does pass a local-mac-address property, then it is intentional and it can be later overriden anyway by "ifconfig ... hw ether" if needed .

If the bootloader does pass such information, it is either sourced from OCOTP (in which case it might fall back to 1) and pass nothing ) or elsewhere, in which case it's 2) and the bootloader has obviously better knowledge of the hardware than we do.

Quoted 8 lines

I firmly disagree with force-overriding the DT properties, since esp. in case of development kits, it doesn't give the users the freedom to program their OCOTP the way they need it to.

Also, the users don't have freedom to frob with their MAC address easily -- when the OCOTP isn't programmed yet, their FEC won't work, for example in case of NFS root filesystem, this is a problem. With this patch, you don't have the problem.

Please bear in mind, we only call update_fec_mac_prop for boards that are known having MAC programmed in OCOTP.

Shawn

#6 lore raw

PATCH v2 1/1 ARM: mx28: Skip OCOTP FEC MAC setup if in DT

Dear Shawn Guo,

Quoted 16 lines · Marek Vasut
Quoted 15 lines

Dear Shawn Guo,

Quoted 13 lines

Sorry, I just dropped the patch, and you need to convince me that the patch is actually needed to fix a bug.

Quoted 8 lines · Marek Vasut

Dear Shawn Guo,

Quoted 6 lines · Marek Vasut
Quoted 5 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.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

The function update_fec_mac_prop is only called for imx28-evk and m28evk boards which are known having valid/unique MAC address programmed in OCOTP.

Actually I disabled it on m28, since the OCOTP is not always programmed. The board is shipped with blank OCOTP.

Then removing the call to update_fec_mac_prop for m28 is enough.

It is not. We do not want to loost OCOTP completely. I would actually like to add the call back, with this patch in that would be possible and fine solution.

Quoted 4 lines
Quoted 2 lines

The imx28-evk is shipped with blank OCOTP as
well, no?

No. imx28-evk is shipped with MAC programmed into OCOTP.

Does that not limit the users of that kit then ?

Quoted 11 lines
Quoted 8 lines
Quoted 3 lines

In that case, shouldn't we always read MAC from OCOTP instead of trusting the "local-mac-address" property from device tree, which might stand a chance that it's not valid or unique?

Definitelly not. If the bootloader doesn't pass correct local-mac-address property, the bootloader is broken and it is not our problem (any invalid DT passed from bootloader is not our problem and is not fixed by us ... most of the time).

It is our problem. We shouldn't trust bootloader on that whenever it's possible for ourselves to figure it out.

Correct. You can not reliably figure out the MAC address. See, on sparc (this is where DT came from), it was all about relying on bootloader to pass the proper data to kernel.

Quoted 1 line

You can say "hey bootloader, this is your problem not ours"

If it mangles the DT? You are right, it is not our problem, we can not do anything about it.

My understanding of your claim is like saying that you can't trust the "interrupts" property of GPMI nand controller ... because you can figure out the value from the CPU ID. If bootloader mangles this part, you will also override it in kernel?

Quoted 2 lines

, but FEC driver in kernel is not working. Isn't it a problem for kernel when FEC is not working?

But the _main_ question here is not about working vs. not-working . The point of this patch is to make OCOTP recommended, but overridable via _standard_ means. Thus giving users more freedom!

Quoted 20 lines
Quoted 20 lines

On the other hand:

1) if it doesn't pass any local-mac-address property, it is safe to read from OCOTP (this is the case of bootlets) to fill in the blank with at least something ... even though if the OCOTP is empty, FEC won't work anyway.

2) if the bootloader does pass a local-mac-address property, then it is intentional and it can be later overriden anyway by "ifconfig ... hw ether" if needed .

If the bootloader does pass such information, it is either sourced from OCOTP (in which case it might fall back to 1) and pass nothing ) or elsewhere, in which case it's 2) and the bootloader has obviously better knowledge of the hardware than we do.

I firmly disagree with force-overriding the DT properties, since esp. in case of development kits, it doesn't give the users the freedom to program their OCOTP the way they need it to.

Quoted 7 lines
Quoted 4 lines

Also, the users don't have freedom to frob with their MAC address easily -- when the OCOTP isn't programmed yet, their FEC won't work, for example in case of NFS root filesystem, this is a problem. With this patch, you don't have the problem.

Please bear in mind, we only call update_fec_mac_prop for boards that are known having MAC programmed in OCOTP.

Agreed, now we do. This can change (I would like to see it change).

Quoted 1 line

Shawn

Best regards,
Marek Vasut

#7 lore raw

PATCH v2 1/1 ARM: mx28: Skip OCOTP FEC MAC setup if in DT

In reply to Marek Vasut

Dear Shawn Guo,

Quoted 15 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.

Quoted 6 lines

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.

Cc Fabio Estevam <[email protected]>
Cc Shawn Guo <[email protected]>

[...]

Can we apply this for 3.7? I believe it is harmless and beneficial for some parties at least.

Best regards,
Marek Vasut

#8 lore raw

PATCH v2 1/1 ARM: mx28: Skip OCOTP FEC MAC setup if in DT

Quoted 1 line · Marek Vasut

Can we apply this for 3.7?

You meant for 3.8?

Shawn

Quoted 3 lines

I believe it is harmless and beneficial for some
parties at least.

#9 lore raw

PATCH v2 1/1 ARM: mx28: Skip OCOTP FEC MAC setup if in DT

Dear Shawn Guo,

Quoted 4 lines · Marek Vasut
Quoted 1 line

Can we apply this for 3.7?

You meant for 3.8?

3.7 would be nice, but it's too late now.

Best regards,
Marek Vasut

#10 lore raw

PATCH v2 1/1 ARM: mx28: Skip OCOTP FEC MAC setup if in DT

Quoted 9 lines · Marek Vasut

Dear Shawn Guo,

Quoted 4 lines · Marek Vasut
Quoted 1 line

Can we apply this for 3.7?

You meant for 3.8?

3.7 would be nice, but it's too late now.

Applied for 3.8.