All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/1] net: phy: Fix interrupt mask loss on resume from hibernation
@ 2021-01-22 14:35 Laurent Badel
  2021-01-22 14:35 ` [PATCH net 1/1] net: phy: Reconfigure PHY interrupt in mdio_bus_phy_restore() Laurent Badel
  2021-01-22 15:19 ` [PATCH net 0/1] net: phy: Fix interrupt mask loss on resume from hibernation Heiner Kallweit
  0 siblings, 2 replies; 4+ messages in thread
From: Laurent Badel @ 2021-01-22 14:35 UTC (permalink / raw)
  To: netdev, Andrew Lunn, Heiner Kallweit, Russell King,
	David S . Miller, Jakub Kicinski, linux-kernel,
	Rafael J . Wysocki, Pavel Machek, linux-pm
  Cc: Laurent Badel

Some PHYs such as SMSC LAN87xx clear the interrupt mask register on
software reset. Since mdio_bus_phy_restore() calls phy_init_hw() which
does a software reset of the PHY, these PHYs will lose their interrupt 
mask configuration on resuming from hibernation.

I initially reconfigured only the PHY interrupt mask using 
phydev->config_intr(), which worked fine with PM_DEBUG/test_resume, but
there seems to be an issue when resuming from a real hibernation, by which
the interrupt type is not set appropriately (in this case 
IRQ_TYPE_LEVEL_LOW). Calling irq_set_irq_type() directly from sysfs 
restored the PHY functionality immediately suggesting that everything is
otherwise well configured. Therefore this patch suggests freeing and
re-requesting the interrupt, to guarantee proper interrupt configuration.

Laurent Badel (1):
  net: phy: Reconfigure PHY interrupt in mdio_bus_phy_restore()

 drivers/net/phy/phy_device.c | 9 +++++++++
 1 file changed, 9 insertions(+)

-- 
2.17.1



-----------------------------
Eaton Industries Manufacturing GmbH ~ Registered place of business: Route de la Longeraie 7, 1110, Morges, Switzerland 

-----------------------------


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net 1/1] net: phy: Reconfigure PHY interrupt in mdio_bus_phy_restore()
  2021-01-22 14:35 [PATCH net 0/1] net: phy: Fix interrupt mask loss on resume from hibernation Laurent Badel
@ 2021-01-22 14:35 ` Laurent Badel
  2021-01-22 15:19 ` [PATCH net 0/1] net: phy: Fix interrupt mask loss on resume from hibernation Heiner Kallweit
  1 sibling, 0 replies; 4+ messages in thread
From: Laurent Badel @ 2021-01-22 14:35 UTC (permalink / raw)
  To: netdev, Andrew Lunn, Heiner Kallweit, Russell King,
	David S . Miller, Jakub Kicinski, linux-kernel,
	Rafael J . Wysocki, Pavel Machek, linux-pm
  Cc: Laurent Badel

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 --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);
 
-- 
2.17.1



-----------------------------
Eaton Industries Manufacturing GmbH ~ Registered place of business: Route de la Longeraie 7, 1110, Morges, Switzerland 

-----------------------------


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 0/1] net: phy: Fix interrupt mask loss on resume from hibernation
  2021-01-22 14:35 [PATCH net 0/1] net: phy: Fix interrupt mask loss on resume from hibernation Laurent Badel
  2021-01-22 14:35 ` [PATCH net 1/1] net: phy: Reconfigure PHY interrupt in mdio_bus_phy_restore() Laurent Badel
@ 2021-01-22 15:19 ` Heiner Kallweit
  2021-01-22 16:12   ` [EXTERNAL] " Badel, Laurent
  1 sibling, 1 reply; 4+ messages in thread
From: Heiner Kallweit @ 2021-01-22 15:19 UTC (permalink / raw)
  To: Laurent Badel, netdev, Andrew Lunn, Russell King,
	David S . Miller, Jakub Kicinski, linux-kernel,
	Rafael J . Wysocki, Pavel Machek, linux-pm

On 22.01.2021 15:35, Laurent Badel wrote:
> Some PHYs such as SMSC LAN87xx clear the interrupt mask register on
> software reset. Since mdio_bus_phy_restore() calls phy_init_hw() which
> does a software reset of the PHY, these PHYs will lose their interrupt 
> mask configuration on resuming from hibernation.

The (optional) software reset is done via soft_reset callback.
So if the PHY in question needs special treatment after a soft reset,
why not add it to the soft_reset callback?

> 
> I initially reconfigured only the PHY interrupt mask using 
> phydev->config_intr(), which worked fine with PM_DEBUG/test_resume, but
> there seems to be an issue when resuming from a real hibernation, by which
> the interrupt type is not set appropriately (in this case 
> IRQ_TYPE_LEVEL_LOW). Calling irq_set_irq_type() directly from sysfs 

This sounds to me like a lower level driver (e.g. for GPIO / interrupt
controller) not resuming properly from hibernation. Supposedly things
like edge/level high/low/both are stored per interrupt line in a register
of the interrupt controller, and the controller would have to restore
the register value on resume from hibernation. You may want to have
a look at that driver.

> restored the PHY functionality immediately suggesting that everything is
> otherwise well configured. Therefore this patch suggests freeing and
> re-requesting the interrupt, to guarantee proper interrupt configuration.
> 
> Laurent Badel (1):
>   net: phy: Reconfigure PHY interrupt in mdio_bus_phy_restore()
> 
>  drivers/net/phy/phy_device.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [EXTERNAL]  Re: [PATCH net 0/1] net: phy: Fix interrupt mask loss on resume from hibernation
  2021-01-22 15:19 ` [PATCH net 0/1] net: phy: Fix interrupt mask loss on resume from hibernation Heiner Kallweit
@ 2021-01-22 16:12   ` Badel, Laurent
  0 siblings, 0 replies; 4+ messages in thread
From: Badel, Laurent @ 2021-01-22 16:12 UTC (permalink / raw)
  To: Heiner Kallweit, netdev, Andrew Lunn, Russell King,
	David S . Miller, Jakub Kicinski, linux-kernel,
	Rafael J . Wysocki, Pavel Machek, linux-pm

> From: Heiner Kallweit <hkallweit1@gmail.com>
> Sent: Friday, January 22, 2021 4:20 PM

> The (optional) software reset is done via soft_reset callback.
> So if the PHY in question needs special treatment after a soft reset,
> why not add it to the soft_reset callback?

Thank you very much for the fast reply. This makes sense, I will 
modify the patch in this direction. 
 
> This sounds to me like a lower level driver (e.g. for GPIO / interrupt
> controller) not resuming properly from hibernation. Supposedly things
> like edge/level high/low/both are stored per interrupt line in a
> register of the interrupt controller, and the controller would have to
> restore the register value on resume from hibernation. You may want to
> have a look at that driver.

I think you are right, the gpio-mxs driver has no PM operations, so 
if it responsible for restoring the interrupt level, no wonder it 
doesn't. This would require implementing the PM ops, which would 
take some additional work, I'll see if I can get around to doing this.
 
Best regards,

Laurent



-----------------------------
Eaton Industries Manufacturing GmbH ~ Registered place of business: Route de la Longeraie 7, 1110, Morges, Switzerland 

-----------------------------


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-22 16:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 14:35 [PATCH net 0/1] net: phy: Fix interrupt mask loss on resume from hibernation Laurent Badel
2021-01-22 14:35 ` [PATCH net 1/1] net: phy: Reconfigure PHY interrupt in mdio_bus_phy_restore() Laurent Badel
2021-01-22 15:19 ` [PATCH net 0/1] net: phy: Fix interrupt mask loss on resume from hibernation Heiner Kallweit
2021-01-22 16:12   ` [EXTERNAL] " Badel, Laurent

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.