Skip to contentSkip to conversation

net: phy: dp83867: fix Wake-on-LAN without a PHY IRQ

RFC PATCH In review Willie Wiholm 2 participants 4 messages Nov 27

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

cover net: phy: dp83867: fix Wake-on-LAN without a PHY IRQ

On an Intel Elkhart Lake board (congatec conga-SA7, dwmac-intel with a DP83867 over RGMII) Wake-on-LAN from S3 does not work on the first suspend after boot or after a link down/up.

Patch 1 sets CFG3.INT_OE when WoL is enabled. Without a PHY IRQ the driver never sets it, so the pin stays a power-down input. The firmware sets it, but the soft reset on attach clears it, so the first suspend after boot does not wake up.

Patch 2 reads ISR before suspend. Nothing reads it when the PHY is polled, so a magic packet received while the system is running leaves the WoL interrupt latched, and the next suspend does not wake up.

Tested on the board with net (28a371228d4e): the first suspend after boot, after link down/up and after a magic packet received while running all wake up on a unicast magic packet.

Questions:
1. Patch 1 makes the pin an output when WoL is enabled. Would you rather preserve the firmware setting across the soft reset, as 043777e94880 does for the LED registers?
2. Patch 2 uses PHY_ALWAYS_CALL_SUSPEND to get a hook before suspend, like bcm54xx. Is that acceptable?

I used an AI coding assistant (Claude) for parts of the analysis, the test automation and for drafting the cover letter. I have reviewed the changes and tested them on the hardware.

---
Willie Wiholm (2):
net: phy: dp83867: set INT_OE when enabling Wake-on-LAN
net: phy: dp83867: clear latched WoL interrupt before suspend

 drivers/net/phy/dp83867.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

---
base-commit: 28a371228d4eb4857cc31eeb1a0d7d01e9c3ea2f
change-id: 20261127-wol-net-10fed393954a

Best regards,

Signature · 1 line
Willie Wiholm <[email protected]>
#1 lore raw

RFC PATCH 1/2 net: phy: dp83867: set INT_OE when enabling Wake-on-LAN

dp83867_set_wol() enables the WoL interrupt in MICR, so a detected magic packet is signalled on the INT/PWDN_N pin. That pin is only an interrupt output when CFG3.INT_OE is set, and dp83867_config_init() sets INT_OE only when the PHY has a valid IRQ. Otherwise the pin stays a power-down input and the WoL event never leaves the PHY.

This happens on Intel Elkhart Lake boards with dwmac-intel, where the PHY is polled (no PHY IRQ in Linux) and INT/PWDN_N is wired to the MAC, which raises PME to wake the system.

The firmware on such a board (congatec conga-SA7) sets INT_OE, but the global soft reset in dp83867_phy_reset() clears it on every attach. As a result the first suspend after boot or after a link down/up never wakes up. Later suspends do wake, because the firmware sets INT_OE again on S3 resume, which makes the bug look intermittent.

Set INT_OE when WoL is enabled. When WoL is disabled, clear it again if the PHY has no IRQ, restoring the reset default. PHYs with a valid IRQ already have INT_OE set, so nothing changes for them.

Fixes caabee5b53f5 ("net: phy: dp83867: support Wake on LAN")
---
 drivers/net/phy/dp83867.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/phy/dp83867.c +4 -0
index b4b4931c6f8c..e3617f01b5d9 100644
@@ -233,6 +233,8 @@ static int dp83867_set_wol(struct phy_device *phydev,
 			    WAKE_BCAST)) {
 		val_rxcfg |= DP83867_WOL_ENH_MAC;
 		val_micr |= MII_DP83867_MICR_WOL_INT_EN;
+		/* WoL is signalled on INT/PWDN_N which must be an output */
+		phy_set_bits(phydev, DP83867_CFG3, DP83867_CFG3_INT_OE);
 
 		if (wol->wolopts & WAKE_MAGIC) {
 			mac = (const u8 *)ndev->dev_addr;
@@ -277,6 +279,8 @@ static int dp83867_set_wol(struct phy_device *phydev,
 	} else {
 		val_rxcfg &= ~DP83867_WOL_ENH_MAC;
 		val_micr &= ~MII_DP83867_MICR_WOL_INT_EN;
+		if (!phy_interrupt_is_valid(phydev))
+			phy_clear_bits(phydev, DP83867_CFG3, DP83867_CFG3_INT_OE);
 	}
 
 	phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RXFCFG, val_rxcfg);
Signature · 1 line
2.43.0
maintainer
#2 lore raw

Re: [PATCH RFC net 1/2] net: phy: dp83867: set INT_OE when enabling Wake-on-LAN

Quoted 11 lines · On Fri, Nov 27, 2026 at 07:44:56PM +0100, Willie Wiholm via B4 Relay wrote:

From: Willie Wiholm <[email protected]>

dp83867_set_wol() enables the WoL interrupt in MICR, so a detected magic packet is signalled on the INT/PWDN_N pin. That pin is only an interrupt output when CFG3.INT_OE is set, and dp83867_config_init() sets INT_OE only when the PHY has a valid IRQ. Otherwise the pin stays a power-down input and the WoL event never leaves the PHY.

This happens on Intel Elkhart Lake boards with dwmac-intel, where the PHY is polled (no PHY IRQ in Linux) and INT/PWDN_N is wired to the MAC, which raises PME to wake the system.

Can this pin on the MAC actually generate interrupts? It would be better to turn it into an interrupt controller, so all the usual mechanisms just work, like PHY interrupts, not just WoL wake up.

Andrew

#3 lore raw

RFC PATCH 2/2 net: phy: dp83867: clear latched WoL interrupt before suspend

In reply to Willie Wiholm

WOL_INT in ISR is latched until ISR is read. When the PHY has no IRQ, nothing reads ISR, so a magic packet received while the system is running leaves the WoL interrupt pending and INT/PWDN_N asserted. The next suspend then does not wake up on a magic packet, as the pin is already active.

With WoL enabled, phy_suspend() does not call the driver's suspend callback, so the driver has no chance to clear the interrupt. Set PHY_ALWAYS_CALL_SUSPEND and, when WoL is enabled, only read ISR in dp83867_suspend(). ISR is only read when the PHY has no IRQ, so that pending interrupts are not lost when it has one. Without WoL the behaviour is unchanged.

bcm54xx_suspend() acknowledges the WoL interrupt before suspend in the same way.

Fixes caabee5b53f5 ("net: phy: dp83867: support Wake on LAN")
---
 drivers/net/phy/dp83867.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/net/phy/dp83867.c +17 -0
index e3617f01b5d9..d997e10cd5ef 100644
@@ -712,6 +712,22 @@ static int dp83867_of_init(struct phy_device *phydev)
 
 static int dp83867_suspend(struct phy_device *phydev)
 {
+	int ret;
+
+	/* The PHY must stay powered up for WoL. Without a PHY IRQ nothing
+	 * reads ISR, so a WoL event latched while the system was running
+	 * keeps INT/PWDN_N asserted and the next magic packet does not
+	 * wake the system. Clear it before suspend.
+	 */
+	if (phydev->wol_enabled) {
+		if (!phy_interrupt_is_valid(phydev)) {
+			ret = phy_read(phydev, MII_DP83867_ISR);
+			if (ret < 0)
+				return ret;
+		}
+		return 0;
+	}
+
 	/* Disable PHY Interrupts */
 	if (phy_interrupt_is_valid(phydev)) {
 		phydev->interrupts = PHY_INTERRUPT_DISABLED;
@@ -1274,6 +1290,7 @@ static struct phy_driver dp83867_driver[] = {
 		.phy_id_mask	= 0xfffffff0,
 		.name		= "TI DP83867",
 		/* PHY_GBIT_FEATURES */
+		.flags		= PHY_ALWAYS_CALL_SUSPEND,
 
 		.probe          = dp83867_probe,
 		.config_init	= dp83867_config_init,
Signature · 1 line
2.43.0