Skip to content

Commit

Permalink
net: mvneta: speed down the PHY, if WoL used, to save energy
Browse files Browse the repository at this point in the history
Some PHYs connected to this ethernet hardware support the WoL feature.
But when WoL is enabled and the machine is powered off, the PHY remains
waiting for a magic packet at max speed (i.e. 1Gbps), which is a waste of
energy.

Slow down the PHY speed before stopping the ethernet if WoL is enabled,
and save some energy while the machine is powered off or sleeping.

Tested using an Armada 370 based board (LS421DE) equipped with a Marvell
88E1518 PHY.

Signed-off-by: Daniel González Cabanelas <dgcbueu@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Daniel González Cabanelas authored and David S. Miller committed May 13, 2020
1 parent 6545be8 commit 5e3768a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/net/ethernet/marvell/mvneta.c
Original file line number Diff line number Diff line change
Expand Up @@ -3561,13 +3561,20 @@ static void mvneta_start_dev(struct mvneta_port *pp)
MVNETA_CAUSE_LINK_CHANGE);

phylink_start(pp->phylink);

/* We may have called phy_speed_down before */
phy_speed_up(pp->dev->phydev);

netif_tx_start_all_queues(pp->dev);
}

static void mvneta_stop_dev(struct mvneta_port *pp)
{
unsigned int cpu;

if (device_may_wakeup(&pp->dev->dev))
phy_speed_down(pp->dev->phydev, false);

phylink_stop(pp->phylink);

if (!pp->neta_armada3700) {
Expand Down Expand Up @@ -4040,6 +4047,10 @@ static int mvneta_mdio_probe(struct mvneta_port *pp)
phylink_ethtool_get_wol(pp->phylink, &wol);
device_set_wakeup_capable(&pp->dev->dev, !!wol.supported);

/* PHY WoL may be enabled but device wakeup disabled */
if (wol.supported)
device_set_wakeup_enable(&pp->dev->dev, !!wol.wolopts);

return err;
}

Expand Down

0 comments on commit 5e3768a

Please sign in to comment.