diff mbox

[U-Boot] net/eth.c: fix eth_write_hwaddr() to use dev->enetaddr as fall back

Message ID 1313559224-4627-1-git-send-email-eric.miao@linaro.org
State Accepted
Commit 6937664426446b76308e7125e9f357e0f12c731a
Delegated to: Stefan Roese
Headers show

Commit Message

Eric Miao Aug. 17, 2011, 5:33 a.m. UTC
Ignore the return value of eth_getenv_enetaddr_by_index(), and if it
fails, fall back to use dev->enetaddr, which could be filled up by
the ethernet device driver.

Actually, this is the original behavior, and was later changed by
commit 48506a2cde2458fa1f8c5993afc98e5a4617e1d3.

Signed-off-by: Eric Miao <eric.miao@linaro.org>
---
 net/eth.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

Comments

Simon Glass Aug. 17, 2011, 6:22 a.m. UTC | #1
On Tue, Aug 16, 2011 at 10:33 PM, Eric Miao <eric.miao@linaro.org> wrote:
> Ignore the return value of eth_getenv_enetaddr_by_index(), and if it
> fails, fall back to use dev->enetaddr, which could be filled up by
> the ethernet device driver.
>
> Actually, this is the original behavior, and was later changed by
> commit 48506a2cde2458fa1f8c5993afc98e5a4617e1d3.
>
> Signed-off-by: Eric Miao <eric.miao@linaro.org>

Hi Eric,

I found this in u-boot-usb although the commit hash I saw was 7616e7850.

> ---
>  net/eth.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/net/eth.c b/net/eth.c
> index a34fe59..c4fbe11 100644
> --- a/net/eth.c
> +++ b/net/eth.c
> @@ -195,8 +195,7 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
>        unsigned char env_enetaddr[6];
>        int ret = 0;
>
> -       if (!eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr))
> -               return -1;
> +       eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr);
>
>        if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
>                if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) &&

Acked-by: Simon Glass <sjg@chromium.org>

Regards,
Simon

> --
> 1.7.4.1
>
>
Behme Dirk (CM/ESO2) Jan. 11, 2012, 12:23 p.m. UTC | #2
On 17.08.2011 08:22, Simon Glass wrote:
> On Tue, Aug 16, 2011 at 10:33 PM, Eric Miao <eric.miao@linaro.org> wrote:
>> Ignore the return value of eth_getenv_enetaddr_by_index(), and if it
>> fails, fall back to use dev->enetaddr, which could be filled up by
>> the ethernet device driver.
>>
>> Actually, this is the original behavior, and was later changed by
>> commit 48506a2cde2458fa1f8c5993afc98e5a4617e1d3.
>>
>> Signed-off-by: Eric Miao <eric.miao@linaro.org>
> 
> Hi Eric,
> 
> I found this in u-boot-usb although the commit hash I saw was 7616e7850.
> 
>> ---
>>  net/eth.c |    3 +--
>>  1 files changed, 1 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/eth.c b/net/eth.c
>> index a34fe59..c4fbe11 100644
>> --- a/net/eth.c
>> +++ b/net/eth.c
>> @@ -195,8 +195,7 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
>>        unsigned char env_enetaddr[6];
>>        int ret = 0;
>>
>> -       if (!eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr))
>> -               return -1;
>> +       eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr);
>>
>>        if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
>>                if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) &&
> 
> Acked-by: Simon Glass <sjg@chromium.org>

Ping.

Anybody likes to apply this? Or any new comments?

Many thanks and best regards

Dirk

P.S.: I add Wolfgang as he seems to have done the last commits to net/eth.c.
Simon Glass Jan. 12, 2012, 5:12 a.m. UTC | #3
On Wed, Jan 11, 2012 at 4:23 AM, Dirk Behme <dirk.behme@de.bosch.com> wrote:
> On 17.08.2011 08:22, Simon Glass wrote:
>>
>> On Tue, Aug 16, 2011 at 10:33 PM, Eric Miao <eric.miao@linaro.org> wrote:
>>>
>>> Ignore the return value of eth_getenv_enetaddr_by_index(), and if it
>>> fails, fall back to use dev->enetaddr, which could be filled up by
>>> the ethernet device driver.
>>>
>>> Actually, this is the original behavior, and was later changed by
>>> commit 48506a2cde2458fa1f8c5993afc98e5a4617e1d3.
>>>
>>> Signed-off-by: Eric Miao <eric.miao@linaro.org>
>>
>>
>> Hi Eric,
>>
>> I found this in u-boot-usb although the commit hash I saw was 7616e7850.
>>
>>> ---
>>>  net/eth.c |    3 +--
>>>  1 files changed, 1 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/net/eth.c b/net/eth.c
>>> index a34fe59..c4fbe11 100644
>>> --- a/net/eth.c
>>> +++ b/net/eth.c
>>> @@ -195,8 +195,7 @@ int eth_write_hwaddr(struct eth_device *dev, const
>>> char *base_name,
>>>       unsigned char env_enetaddr[6];
>>>       int ret = 0;
>>>
>>> -       if (!eth_getenv_enetaddr_by_index(base_name, eth_number,
>>> env_enetaddr))
>>> -               return -1;
>>> +       eth_getenv_enetaddr_by_index(base_name, eth_number,
>>> env_enetaddr);
>>>
>>>       if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
>>>               if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) &&
>>
>>
>> Acked-by: Simon Glass <sjg@chromium.org>
>
>
> Ping.
>
> Anybody likes to apply this? Or any new comments?
>
> Many thanks and best regards
>
> Dirk
>
> P.S.: I add Wolfgang as he seems to have done the last commits to net/eth.c.

Maybe Stefan might pick it up through the staging tree?

Regards,
Simon
Stefan Roese Jan. 12, 2012, 7:48 a.m. UTC | #4
On Thursday 12 January 2012 06:12:19 Simon Glass wrote:
> On Wed, Jan 11, 2012 at 4:23 AM, Dirk Behme <dirk.behme@de.bosch.com> wrote:
> > On 17.08.2011 08:22, Simon Glass wrote:
> >> On Tue, Aug 16, 2011 at 10:33 PM, Eric Miao <eric.miao@linaro.org> wrote:
> >>> Ignore the return value of eth_getenv_enetaddr_by_index(), and if it
> >>> fails, fall back to use dev->enetaddr, which could be filled up by
> >>> the ethernet device driver.
> >>> 
> >>> Actually, this is the original behavior, and was later changed by
> >>> commit 48506a2cde2458fa1f8c5993afc98e5a4617e1d3.
> >>> 
> >>> Signed-off-by: Eric Miao <eric.miao@linaro.org>
> >> 
> >> Hi Eric,
> >> 
> >> I found this in u-boot-usb although the commit hash I saw was 7616e7850.
> >> 
> >>> ---
> >>>  net/eth.c |    3 +--
> >>>  1 files changed, 1 insertions(+), 2 deletions(-)
> >>> 
> >>> diff --git a/net/eth.c b/net/eth.c
> >>> index a34fe59..c4fbe11 100644
> >>> --- a/net/eth.c
> >>> +++ b/net/eth.c
> >>> @@ -195,8 +195,7 @@ int eth_write_hwaddr(struct eth_device *dev, const
> >>> char *base_name,
> >>>       unsigned char env_enetaddr[6];
> >>>       int ret = 0;
> >>> 
> >>> -       if (!eth_getenv_enetaddr_by_index(base_name, eth_number,
> >>> env_enetaddr))
> >>> -               return -1;
> >>> +       eth_getenv_enetaddr_by_index(base_name, eth_number,
> >>> env_enetaddr);
> >>> 
> >>>       if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
> >>>               if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) &&
> >> 
> >> Acked-by: Simon Glass <sjg@chromium.org>
> > 
> > Ping.
> > 
> > Anybody likes to apply this? Or any new comments?
> > 
> > Many thanks and best regards
> > 
> > Dirk
> > 
> > P.S.: I add Wolfgang as he seems to have done the last commits to
> > net/eth.c.
> 
> Maybe Stefan might pick it up through the staging tree?

Okay, let's take a look...

Best regards,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office@denx.de
Stefan Roese Jan. 12, 2012, 7:55 a.m. UTC | #5
On Wednesday 17 August 2011 07:33:44 Eric Miao wrote:
> Ignore the return value of eth_getenv_enetaddr_by_index(), and if it
> fails, fall back to use dev->enetaddr, which could be filled up by
> the ethernet device driver.
> 
> Actually, this is the original behavior, and was later changed by
> commit 48506a2cde2458fa1f8c5993afc98e5a4617e1d3.

Applied to u-boot-staging/sr@denx.de. Thanks.
 
Best regards,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office@denx.de
Wolfgang Denk Jan. 13, 2012, 7:19 p.m. UTC | #6
Dear Eric Miao,

In message <1313559224-4627-1-git-send-email-eric.miao@linaro.org> you wrote:
> Ignore the return value of eth_getenv_enetaddr_by_index(), and if it
> fails, fall back to use dev->enetaddr, which could be filled up by
> the ethernet device driver.
> 
> Actually, this is the original behavior, and was later changed by
> commit 48506a2cde2458fa1f8c5993afc98e5a4617e1d3.

I'm not going to pull that patch.

Please explain which actual problem you're trying to fix.

Also, fix the commit ID - the one you list above does not exist in
mainline.

Best regards,

Wolfgang Denk
Eric Miao Jan. 16, 2012, 7:03 a.m. UTC | #7
On Sat, Jan 14, 2012 at 3:19 AM, Wolfgang Denk <wd@denx.de> wrote:
> Dear Eric Miao,
>
> In message <1313559224-4627-1-git-send-email-eric.miao@linaro.org> you wrote:
>> Ignore the return value of eth_getenv_enetaddr_by_index(), and if it
>> fails, fall back to use dev->enetaddr, which could be filled up by
>> the ethernet device driver.
>>
>> Actually, this is the original behavior, and was later changed by
>> commit 48506a2cde2458fa1f8c5993afc98e5a4617e1d3.
>
> I'm not going to pull that patch.
>
> Please explain which actual problem you're trying to fix.

Hi Wolfgang,

The problem was with the current code, if there is no eth<n>addr
in the environment variables, eth_write_hwaddr() will fail immediately,
and it's going to use the default reset MAC address in the FEC controller
which is likely all 0.

To make it worse, the current kernel driver actually depends on
the MAC address registers being programmed correctly.

If traced back to the last commit to this file, which added this
eth_getenv_enetaddr_by_index(), that commit actually modified
the original behavior of this eth_write_hwaddr() function.
Eric Miao Jan. 16, 2012, 7:08 a.m. UTC | #8
On Mon, Jan 16, 2012 at 3:03 PM, Eric Miao <eric.miao@linaro.org> wrote:
> On Sat, Jan 14, 2012 at 3:19 AM, Wolfgang Denk <wd@denx.de> wrote:
>> Dear Eric Miao,
>>
>> In message <1313559224-4627-1-git-send-email-eric.miao@linaro.org> you wrote:
>>> Ignore the return value of eth_getenv_enetaddr_by_index(), and if it
>>> fails, fall back to use dev->enetaddr, which could be filled up by
>>> the ethernet device driver.
>>>
>>> Actually, this is the original behavior, and was later changed by
>>> commit 48506a2cde2458fa1f8c5993afc98e5a4617e1d3.

Checked with git.denx.de/u-boot.git, the original commit hash is

7616e7850804c7c69e0a22c179dfcba9e8f3f587

Please note the behavior modification to eth_write_hwaddr() when
it's excerpted from the original eth_initialize().
Philip Balister Jan. 16, 2012, 2:08 p.m. UTC | #9
On 01/13/2012 02:19 PM, Wolfgang Denk wrote:
> Dear Eric Miao,
> 
> In message <1313559224-4627-1-git-send-email-eric.miao@linaro.org> you wrote:
>> Ignore the return value of eth_getenv_enetaddr_by_index(), and if it
>> fails, fall back to use dev->enetaddr, which could be filled up by
>> the ethernet device driver.
>>
>> Actually, this is the original behavior, and was later changed by
>> commit 48506a2cde2458fa1f8c5993afc98e5a4617e1d3.
> 
> I'm not going to pull that patch.
> 
> Please explain which actual problem you're trying to fix.
> 

For u-boot for an overo based product that uses the SMSC911x ethernet
chip (with MAC address set via EEPROM connected to the SMSC911x chip) I
have a local patch to prevent u-boot from printing:

Warning: failed to set MAC address

The MAC address is still OK and we basically removed the code that led
to the message to reduce customer confusion :)

Hopefully, the patch people are talking about here is a proper fix to
this problem.

Philip


> Also, fix the commit ID - the one you list above does not exist in
> mainline.
> 
> Best regards,
> 
> Wolfgang Denk
>
Wolfgang Denk Jan. 16, 2012, 4 p.m. UTC | #10
Dear Philip Balister,

In message <4F142F52.508@balister.org> you wrote:
>
> > I'm not going to pull that patch.
> > 
> > Please explain which actual problem you're trying to fix.
> 
> For u-boot for an overo based product that uses the SMSC911x ethernet
> chip (with MAC address set via EEPROM connected to the SMSC911x chip) I
> have a local patch to prevent u-boot from printing:
> 
> Warning: failed to set MAC address

Something went wrong here.  Either you should not run the operation
that failed, or you should find out why it failed and fixe the cause
of that.

> The MAC address is still OK and we basically removed the code that led
> to the message to reduce customer confusion :)

Papering over errors or warnings is rarely a good thing.  We should
understand what happened and fix the original cause of the problem
instead.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/net/eth.c b/net/eth.c
index a34fe59..c4fbe11 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -195,8 +195,7 @@  int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
 	unsigned char env_enetaddr[6];
 	int ret = 0;
 
-	if (!eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr))
-		return -1;
+	eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr);
 
 	if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
 		if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) &&