net: stmmac: fix system hang if change mac address after interface ifdown
authorJoakim Zhang <qiangqing.zhang@nxp.com>
Thu, 20 May 2021 12:51:17 +0000 (20:51 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 May 2021 22:49:33 +0000 (15:49 -0700)
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.

Fixes: 5ec55823438e ("net: stmmac: add clocks management for gmac driver")
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index df4ce59..5d956a5 100644 (file)
@@ -5891,12 +5891,21 @@ static int stmmac_set_mac_address(struct net_device *ndev, void *addr)
        struct stmmac_priv *priv = netdev_priv(ndev);
        int ret = 0;
 
+       ret = pm_runtime_get_sync(priv->device);
+       if (ret < 0) {
+               pm_runtime_put_noidle(priv->device);
+               return ret;
+       }
+
        ret = eth_mac_addr(ndev, addr);
        if (ret)
-               return ret;
+               goto set_mac_error;
 
        stmmac_set_umac_addr(priv, priv->hw, ndev->dev_addr, 0);
 
+set_mac_error:
+       pm_runtime_put(priv->device);
+
        return ret;
 }