netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Heiko Stübner" <heiko@sntech.de>
To: Max Schwarz <max.schwarz@online.de>
Cc: "David S. Miller" <davem@davemloft.net>,
	Alexey Brodkin <Alexey.Brodkin@synopsys.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arc_emac: write initial MAC address from devicetree to hw
Date: Mon, 21 Apr 2014 22:01:59 +0200	[thread overview]
Message-ID: <1991077.DWMmAhPCQt@phil> (raw)
In-Reply-To: <1664530.jeK9vBIgft@typ>

Am Freitag, 18. April 2014, 02:17:32 schrieb Max Schwarz:
> The MAC address retrieved from dt was not actually written to the
> hardware. This meant proper communication was only possible after
> changing the MAC address.
> 
> Fix that by always writing the mac address during probing.
> 
> Signed-off-by: Max Schwarz <max.schwarz@online.de>
Acked-by: Heiko Stuebner <heiko@sntech.de>
On the same hardware (rk3188 radxa rock)
Tested-by: Heiko Stuebner <heiko@sntech.de>

> ---
> 
> I recently noticed this problem on the Radxa Rock board. I'm not
> sure how this has ever worked on other platforms, though. I can
> only receive broadcast packets without configuring the address.
> 
> Running ifconfig eth0 hw ether XYZ or applying the patch fixes
> the problem for me.
> 
> CCing Heiko Stübner because he has seen the problem as well.
> 
>  drivers/net/ethernet/arc/emac_main.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/arc/emac_main.c
> b/drivers/net/ethernet/arc/emac_main.c index eeecc29..9f45782 100644
> --- a/drivers/net/ethernet/arc/emac_main.c
> +++ b/drivers/net/ethernet/arc/emac_main.c
> @@ -574,6 +574,18 @@ static int arc_emac_tx(struct sk_buff *skb, struct
> net_device *ndev) return NETDEV_TX_OK;
>  }
> 
> +static void arc_emac_set_address_internal(struct net_device *ndev)
> +{
> +	struct arc_emac_priv *priv = netdev_priv(ndev);
> +	unsigned int addr_low, addr_hi;
> +
> +	addr_low = le32_to_cpu(*(__le32 *) &ndev->dev_addr[0]);
> +	addr_hi = le16_to_cpu(*(__le16 *) &ndev->dev_addr[4]);
> +
> +	arc_reg_set(priv, R_ADDRL, addr_low);
> +	arc_reg_set(priv, R_ADDRH, addr_hi);
> +}
> +
>  /**
>   * arc_emac_set_address - Set the MAC address for this device.
>   * @ndev:	Pointer to net_device structure.
> @@ -587,9 +599,7 @@ static int arc_emac_tx(struct sk_buff *skb, struct
> net_device *ndev) */
>  static int arc_emac_set_address(struct net_device *ndev, void *p)
>  {
> -	struct arc_emac_priv *priv = netdev_priv(ndev);
>  	struct sockaddr *addr = p;
> -	unsigned int addr_low, addr_hi;
> 
>  	if (netif_running(ndev))
>  		return -EBUSY;
> @@ -599,11 +609,7 @@ static int arc_emac_set_address(struct net_device
> *ndev, void *p)
> 
>  	memcpy(ndev->dev_addr, addr->sa_data, ndev->addr_len);
> 
> -	addr_low = le32_to_cpu(*(__le32 *) &ndev->dev_addr[0]);
> -	addr_hi = le16_to_cpu(*(__le16 *) &ndev->dev_addr[4]);
> -
> -	arc_reg_set(priv, R_ADDRL, addr_low);
> -	arc_reg_set(priv, R_ADDRH, addr_hi);
> +	arc_emac_set_address_internal(ndev);
> 
>  	return 0;
>  }
> @@ -713,6 +719,7 @@ static int arc_emac_probe(struct platform_device *pdev)
>  	else
>  		eth_hw_addr_random(ndev);
> 
> +	arc_emac_set_address_internal(ndev);
>  	dev_info(&pdev->dev, "MAC address is now %pM\n", ndev->dev_addr);
> 
>  	/* Do 1 allocation instead of 2 separate ones for Rx and Tx BD rings */

  reply	other threads:[~2014-04-21 20:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-18  0:17 [PATCH] arc_emac: write initial MAC address from devicetree to hw Max Schwarz
2014-04-21 20:01 ` Heiko Stübner [this message]
2014-04-22 19:55 ` David Miller
2014-05-01  4:58 ` Vineet Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1991077.DWMmAhPCQt@phil \
    --to=heiko@sntech.de \
    --cc=Alexey.Brodkin@synopsys.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=max.schwarz@online.de \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).