diff mbox series

[net,1/1] net: phy: Reconfigure PHY interrupt in mdio_bus_phy_restore()

Message ID 20210122143524.14516-2-laurentbadel@eaton.com
State New
Headers show
Series net: phy: Fix interrupt mask loss on resume from hibernation | expand

Commit Message

Badel, Laurent Jan. 22, 2021, 2:35 p.m. UTC
Some PHY (e.g. SMSC LAN87xx) clear their interrupt mask on software
reset. This breaks the ethernet interface on resuming from hibernation,
if the PHY is running in interrupt mode, so reconfigure interrupts
after the software reset in mdio_bus_phy_restore().

Signed-off-by: Laurent Badel <laurentbadel@eaton.com>
---
 drivers/net/phy/phy_device.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 80c2e646c093..5070eed55447 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -324,6 +324,15 @@  static int mdio_bus_phy_restore(struct device *dev)
 	if (ret < 0)
 		return ret;
 
+	if (phydev->drv->config_intr && phy_interrupt_is_valid(phydev))
+	{
+		/* Some PHYs (e.g. SMSC LAN8720) clear their
+		 * interrupt mask on software reset.
+		 */
+		phy_free_interrupt(phydev);
+		phy_request_interrupt(phydev);
+	}
+
 	if (phydev->attached_dev && phydev->adjust_link)
 		phy_start_machine(phydev);