linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: mx28: Skip OCOTP FEC MAC setup if in DT
@ 2012-09-21  2:40 Marek Vasut
  2012-09-25  5:14 ` Shawn Guo
  0 siblings, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2012-09-21  2:40 UTC (permalink / raw)
  To: linux-arm-kernel

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 <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
---
 arch/arm/mach-mxs/mach-mxs.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
index 71d47f5..3f29a52 100644
--- a/arch/arm/mach-mxs/mach-mxs.c
+++ b/arch/arm/mach-mxs/mach-mxs.c
@@ -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);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] ARM: mx28: Skip OCOTP FEC MAC setup if in DT
  2012-09-21  2:40 [PATCH] ARM: mx28: Skip OCOTP FEC MAC setup if in DT Marek Vasut
@ 2012-09-25  5:14 ` Shawn Guo
  2012-09-25 11:01   ` Marek Vasut
  0 siblings, 1 reply; 5+ messages in thread
From: Shawn Guo @ 2012-09-25  5:14 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Sep 21, 2012 at 04:40:14AM +0200, Marek Vasut wrote:
> 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 <marex@denx.de>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> ---
>  arch/arm/mach-mxs/mach-mxs.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
> index 71d47f5..3f29a52 100644
> --- a/arch/arm/mach-mxs/mach-mxs.c
> +++ b/arch/arm/mach-mxs/mach-mxs.c
> @@ -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.

>  		from = np;

Shawn

>  
>  		newmac = kzalloc(sizeof(*newmac) + 6, GFP_KERNEL);
> -- 
> 1.7.10.4
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] ARM: mx28: Skip OCOTP FEC MAC setup if in DT
  2012-09-25  5:14 ` Shawn Guo
@ 2012-09-25 11:01   ` Marek Vasut
  2012-09-25 11:24     ` Shawn Guo
  0 siblings, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2012-09-25 11:01 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Shawn Guo,

> On Fri, Sep 21, 2012 at 04:40:14AM +0200, Marek Vasut wrote:
> > 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 <marex@denx.de>
> > Cc: Fabio Estevam <fabio.estevam@freescale.com>
> > Cc: Shawn Guo <shawn.guo@linaro.org>
> > ---
> > 
> >  arch/arm/mach-mxs/mach-mxs.c |    4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
> > index 71d47f5..3f29a52 100644
> > --- a/arch/arm/mach-mxs/mach-mxs.c
> > +++ b/arch/arm/mach-mxs/mach-mxs.c
> > @@ -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.

Can you please elaborate why would that be necessary?

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] ARM: mx28: Skip OCOTP FEC MAC setup if in DT
  2012-09-25 11:01   ` Marek Vasut
@ 2012-09-25 11:24     ` Shawn Guo
  2012-09-25 11:27       ` Marek Vasut
  0 siblings, 1 reply; 5+ messages in thread
From: Shawn Guo @ 2012-09-25 11:24 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 25, 2012 at 01:01:46PM +0200, Marek Vasut wrote:
> > >  		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.
> 
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] ARM: mx28: Skip OCOTP FEC MAC setup if in DT
  2012-09-25 11:24     ` Shawn Guo
@ 2012-09-25 11:27       ` Marek Vasut
  0 siblings, 0 replies; 5+ messages in thread
From: Marek Vasut @ 2012-09-25 11:27 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Shawn Guo,

> On Tue, Sep 25, 2012 at 01:01:46PM +0200, Marek Vasut wrote:
> > > >  		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.
> > 
> > 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.

> Shawn

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-09-25 11:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-21  2:40 [PATCH] ARM: mx28: Skip OCOTP FEC MAC setup if in DT Marek Vasut
2012-09-25  5:14 ` Shawn Guo
2012-09-25 11:01   ` Marek Vasut
2012-09-25 11:24     ` Shawn Guo
2012-09-25 11:27       ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).