summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNimrod Andy <B38611@freescale.com>2015-09-10 09:35:39 +0800
committerDavid S. Miller <davem@davemloft.net>2015-09-09 20:30:10 -0700
commit9638d19e481605217f95d9ab3c8896e499b1407d (patch)
tree13c6fe7fa4991859f42ecbaa85068da344675bee /drivers
parent1d68c286384d147838d252e2969f2f787e7fbffb (diff)
downloadlinux-9638d19e481605217f95d9ab3c8896e499b1407d.tar.bz2
net: fec: add netif status check before set mac address
There exist one issue by below case that case system hang: ifconfig eth0 down ifconfig eth0 hw ether 00:10:19:19:81:19 After eth0 down, all fec clocks are gated off. In the .fec_set_mac_address() function, it will set new MAC address to registers, which causes system hang. So it needs to add netif status check to avoid registers access when clocks are gated off. Until eth0 up the new MAC address are wrote into related registers. V2: As Lucas Stach's suggestion, add a comment in the code to explain why it needed. CC: Lucas Stach <l.stach@pengutronix.de> CC: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Fugang Duan <B38611@freescale.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 6cc334035e07..dd4ca39d5d8f 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3031,6 +3031,14 @@ fec_set_mac_address(struct net_device *ndev, void *p)
memcpy(ndev->dev_addr, addr->sa_data, ndev->addr_len);
}
+ /* Add netif status check here to avoid system hang in below case:
+ * ifconfig ethx down; ifconfig ethx hw ether xx:xx:xx:xx:xx:xx;
+ * After ethx down, fec all clocks are gated off and then register
+ * access causes system hang.
+ */
+ if (!netif_running(ndev))
+ return 0;
+
writel(ndev->dev_addr[3] | (ndev->dev_addr[2] << 8) |
(ndev->dev_addr[1] << 16) | (ndev->dev_addr[0] << 24),
fep->hwp + FEC_ADDR_LOW);