[PATCH 5.3 041/197] net: stmmac: Do not stop PHY if WoL is enabled

From: Greg Kroah-Hartman
Date: Sun Oct 27 2019 - 17:29:38 EST


From: Jose Abreu <Jose.Abreu@xxxxxxxxxxxx>

[ Upstream commit 3e2bf04fb0447aa4b967b8000125178f55ae7800 ]

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@xxxxxxxxxxxx>
Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index ade85ca9d8c7f..69cc9133336fc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4456,9 +4456,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);
@@ -4473,6 +4471,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 */
@@ -4563,9 +4565,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);

--
2.20.1