* [PATCH net v2 1/1] net: fec: add netif status check before set mac address
@ 2015-09-10 1:35 Fugang Duan
2015-09-10 3:30 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Fugang Duan @ 2015-09-10 1:35 UTC (permalink / raw)
To: davem; +Cc: netdev, bhutchings, l.stach, f.fainelli, b38611
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>
---
drivers/net/ethernet/freescale/fec_main.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 91925e3..d0d83aef 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3029,6 +3029,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);
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net v2 1/1] net: fec: add netif status check before set mac address
2015-09-10 1:35 [PATCH net v2 1/1] net: fec: add netif status check before set mac address Fugang Duan
@ 2015-09-10 3:30 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-09-10 3:30 UTC (permalink / raw)
To: b38611; +Cc: netdev, bhutchings, l.stach, f.fainelli
From: Fugang Duan <b38611@freescale.com>
Date: Thu, 10 Sep 2015 09:35:39 +0800
> 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>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-10 3:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-10 1:35 [PATCH net v2 1/1] net: fec: add netif status check before set mac address Fugang Duan
2015-09-10 3:30 ` David Miller
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).