net: stmmac: Do not stop PHY if WoL is enabled
authorJose Abreu <Jose.Abreu@synopsys.com>
Mon, 30 Sep 2019 08:19:10 +0000 (10:19 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 1 Oct 2019 17:12:37 +0000 (10:12 -0700)
If WoL is enabled we can't really stop the PHY, otherwise we will not
receive the WoL packet. Fix this by telling phylink that only the MAC is
down and only stop the PHY if WoL is not enabled.

Fixes: 74371272f97f ("net: stmmac: Convert to phylink and remove phylib logic")
Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index 31a237ec73bc3f60f9a8439dbc0dbb4701885291..843d53e084b7f8de51cb521af8fd360d5b1d9e43 100644 (file)
@@ -4718,9 +4718,7 @@ int stmmac_suspend(struct device *dev)
 
        mutex_lock(&priv->lock);
 
-       rtnl_lock();
-       phylink_stop(priv->phylink);
-       rtnl_unlock();
+       phylink_mac_change(priv->phylink, false);
 
        netif_device_detach(ndev);
        stmmac_stop_all_queues(priv);
@@ -4735,6 +4733,10 @@ int stmmac_suspend(struct device *dev)
                stmmac_pmt(priv, priv->hw, priv->wolopts);
                priv->irq_wake = 1;
        } else {
+               rtnl_lock();
+               phylink_stop(priv->phylink);
+               rtnl_unlock();
+
                stmmac_mac_set(priv, priv->ioaddr, false);
                pinctrl_pm_select_sleep_state(priv->device);
                /* Disable clock in case of PWM is off */
@@ -4825,9 +4827,13 @@ int stmmac_resume(struct device *dev)
 
        stmmac_start_all_queues(priv);
 
-       rtnl_lock();
-       phylink_start(priv->phylink);
-       rtnl_unlock();
+       if (!device_may_wakeup(priv->device)) {
+               rtnl_lock();
+               phylink_start(priv->phylink);
+               rtnl_unlock();
+       }
+
+       phylink_mac_change(priv->phylink, true);
 
        mutex_unlock(&priv->lock);