LF-3831 net: stmmac: fix system hang if change mac address after interface ifdown
authorJoakim Zhang <qiangqing.zhang@nxp.com>
Thu, 20 May 2021 10:25:30 +0000 (18:25 +0800)
committerJason Liu <jason.hui.liu@nxp.com>
Thu, 27 May 2021 04:52:25 +0000 (12:52 +0800)
Fix system hang with below sequences:
~# ifconfig ethx down
~# ifconfig ethx hw ether xx:xx:xx:xx:xx:xx

After ethx down, stmmac all clocks gated off and then register access
causes system hang.

Reviewed-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index 5be941e..62fff9d 100644 (file)
@@ -4429,12 +4429,18 @@ static int stmmac_set_mac_address(struct net_device *ndev, void *addr)
        struct stmmac_priv *priv = netdev_priv(ndev);
        int ret = 0;
 
-       ret = eth_mac_addr(ndev, addr);
+       ret = stmmac_bus_clks_enable(priv, true);
        if (ret)
                return ret;
 
+       ret = eth_mac_addr(ndev, addr);
+       if (ret)
+               goto error_set_mac;
+
        stmmac_set_umac_addr(priv, priv->hw, ndev->dev_addr, 0);
 
+error_set_mac:
+       stmmac_bus_clks_enable(priv, false);
        return ret;
 }