marvell_config_intr() rewrote the whole interrupt enable register, so the config_intr call from phy_init_hw() on resume silently cleared WOL_EIE on the 88E1318S and 88E1510: m88e1318_get_wol() still reported WAKE_MAGIC, but a matched magic packet was no longer routed to INTn and the board did not wake. Make config_intr update every bit except WOL_EIE with phy_modify(), so the WoL interrupt enable is owned only by set_wol and always matches what it programmed. The read-modify-write runs under the MDIO bus lock, as do the accesses in m88e1318_set_wol(), so the two can no longer overwrite each other's update. Have m88e1318_set_wol() clear WOL_EIE when WoL is fully disabled, since config_intr no longer does. The interrupt register layout is the same across the PHYs this driver handles, so extend the shared handler to also claim a WoL event instead of adding a per-PHY one. Fixes: 3871c3876f80 ("mv643xx_eth with 88E1318S: support Wake on LAN") Assisted-by: LLM Signed-off-by: Rosen Penev --- v3: use phy_modify() v2: resolved review warnings, including wol d. drivers/net/phy/marvell.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index f71cffa88406..56650182bf3e 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -55,6 +55,11 @@ #define MII_M1011_IMASK 0x12 #define MII_M1011_IMASK_INIT 0x6400 #define MII_M1011_IMASK_CLEAR 0x0000 +/* Bits updated by config_intr. The WoL interrupt enable is owned by + * set_wol, so the config_intr call from phy_init_hw() on resume does not + * silently disarm Wake-on-LAN. + */ +#define MII_M1011_IMASK_CONFIG_MASK (U16_MAX & ~MII_88E1318S_PHY_CSIER_WOL_EIE) #define MII_M1011_PHY_SCR 0x10 #define MII_M1011_PHY_SCR_DOWNSHIFT_EN BIT(11) @@ -393,11 +398,13 @@ static int marvell_config_intr(struct phy_device *phydev) if (err) return err; - err = phy_write(phydev, MII_M1011_IMASK, - MII_M1011_IMASK_INIT); + err = phy_modify(phydev, MII_M1011_IMASK, + MII_M1011_IMASK_CONFIG_MASK, + MII_M1011_IMASK_INIT); } else { - err = phy_write(phydev, MII_M1011_IMASK, - MII_M1011_IMASK_CLEAR); + err = phy_modify(phydev, MII_M1011_IMASK, + MII_M1011_IMASK_CONFIG_MASK, + MII_M1011_IMASK_CLEAR); if (err) return err; @@ -417,7 +424,8 @@ static irqreturn_t marvell_handle_interrupt(struct phy_device *phydev) return IRQ_NONE; } - if (!(irq_status & MII_M1011_IMASK_INIT)) + if (!(irq_status & (MII_M1011_IMASK_INIT | + MII_88E1318S_PHY_CSIER_WOL_EIE))) return IRQ_NONE; phy_trigger_machine(phydev); @@ -2074,6 +2082,18 @@ static int m88e1318_set_wol(struct phy_device *phydev, goto error; } + if (!(wol->wolopts & (WAKE_MAGIC | WAKE_PHY))) { + err = marvell_write_page(phydev, MII_MARVELL_COPPER_PAGE); + if (err < 0) + goto error; + + /* Disable the WOL interrupt, config_intr leaves it alone */ + err = __phy_clear_bits(phydev, MII_M1011_IMASK, + MII_88E1318S_PHY_CSIER_WOL_EIE); + if (err < 0) + goto error; + } + error: return phy_restore_page(phydev, oldpage, err); } -- 2.56.0