Skip to content

Commit

Permalink
net: stmmac: Speed down the PHY if WoL to save energy
Browse files Browse the repository at this point in the history
When WoL is enabled and the machine is powered off, the PHY remains
waiting for wakeup events at max speed, which is a waste of energy.

Slow down the PHY speed before stopping the ethernet if WoL is enabled,

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jisheng Zhang authored and David S. Miller committed Jul 29, 2020
1 parent 1d8e5b0 commit 77b2898
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2823,6 +2823,8 @@ static int stmmac_open(struct net_device *dev)
stmmac_init_coalesce(priv);

phylink_start(priv->phylink);
/* We may have called phylink_speed_down before */
phylink_speed_up(priv->phylink);

/* Request the IRQ lines */
ret = request_irq(dev->irq, stmmac_interrupt,
Expand Down Expand Up @@ -2896,6 +2898,8 @@ static int stmmac_release(struct net_device *dev)
if (priv->eee_enabled)
del_timer_sync(&priv->eee_ctrl_timer);

if (device_may_wakeup(priv->device))
phylink_speed_down(priv->phylink, false);
/* Stop and disconnect the PHY */
phylink_stop(priv->phylink);
phylink_disconnect_phy(priv->phylink);
Expand Down Expand Up @@ -5095,6 +5099,8 @@ int stmmac_suspend(struct device *dev)
} else {
mutex_unlock(&priv->lock);
rtnl_lock();
if (device_may_wakeup(priv->device))
phylink_speed_down(priv->phylink, false);
phylink_stop(priv->phylink);
rtnl_unlock();
mutex_lock(&priv->lock);
Expand Down Expand Up @@ -5207,6 +5213,8 @@ int stmmac_resume(struct device *dev)
if (!device_may_wakeup(priv->device) || !priv->plat->pmt) {
rtnl_lock();
phylink_start(priv->phylink);
/* We may have called phylink_speed_down before */
phylink_speed_up(priv->phylink);
rtnl_unlock();
}

Expand Down

0 comments on commit 77b2898

Please sign in to comment.