Skip to contentSkip to conversation

net: mvneta: speed down the PHY, if WoL used, to save energy

PATCH Applied Daniel González Cabanelas 2 participants 2 messages Jun 26, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: mvneta: speed down the PHY, if WoL used, to save energy

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.

---
Changes in v2:
- Patch reworked with the new phylink_speed_(up|down) functions provided by Russel King. This should avoid the kernel OOPs issue when used with a switch or a PHY on a SFP module.

 drivers/net/ethernet/marvell/mvneta.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/ethernet/marvell/mvneta.c +11 -0
index 197d8c6d1..37b9c75a5 100644
@@ -3611,6 +3611,10 @@ 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 */
+	phylink_speed_up(pp->phylink);
+
 	netif_tx_start_all_queues(pp->dev);
 
 	clear_bit(__MVNETA_DOWN, &pp->state);
@@ -3622,6 +3626,9 @@ static void mvneta_stop_dev(struct mvneta_port *pp)
 
 	set_bit(__MVNETA_DOWN, &pp->state);
 
+	if (device_may_wakeup(&pp->dev->dev))
+		phylink_speed_down(pp->phylink, false);
+
 	phylink_stop(pp->phylink);
 
 	if (!pp->neta_armada3700) {
@@ -4090,6 +4097,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;
 }
 
Signature · 1 line
2.27.0
maintainer Applied
#1 lore raw

From: Daniel González Cabanelas <[email protected]>
Date: Fri, 26 Jun 2020 17:18:19 +0200

Quoted 11 lines

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.

Quoted 6 lines

---
Changes in v2:
- Patch reworked with the new phylink_speed_(up|down) functions provided by Russel King. This should avoid the kernel OOPs issue when used with a switch or a PHY on a SFP module.

Applied to net-next.