mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] net: micrel: Fix lan8841_config_intr after getting out of sleep mode
@ 2024-05-23  7:42 Horatiu Vultur
  2024-05-23 14:32 ` Andrew Lunn
  2024-05-23 16:35 ` [EXTERNAL] " Suman Ghosh
  0 siblings, 2 replies; 5+ messages in thread
From: Horatiu Vultur @ 2024-05-23  7:42 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Horatiu Vultur

When the interrupt is enabled, the function lan8841_config_intr tries to
clear any pending interrupts by reading the interrupt status, then
checks the return value for errors and then continue to enable the
interrupt. It has been seen that once the system gets out of sleep mode,
the interrupt status has the value 0x400 meaning that the PHY detected
that the link was in low power. That is correct value but the problem is
that the check is wrong.  We try to check for errors but we return an
error also in this case which is not an error. Therefore fix this by
returning only when there is an error.

Fixes: a8f1a19d27ef ("net: micrel: Add support for lan8841 PHY")
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
---
 drivers/net/phy/micrel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 13e30ea7eec5d..79477f0c90d82 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -4029,7 +4029,7 @@ static int lan8841_config_intr(struct phy_device *phydev)
 
 	if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
 		err = phy_read(phydev, LAN8814_INTS);
-		if (err)
+		if (err < 0)
 			return err;
 
 		/* Enable / disable interrupts. It is OK to enable PTP interrupt
-- 
2.34.1


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

* Re: [PATCH net] net: micrel: Fix lan8841_config_intr after getting out of sleep mode
  2024-05-23  7:42 [PATCH net] net: micrel: Fix lan8841_config_intr after getting out of sleep mode Horatiu Vultur
@ 2024-05-23 14:32 ` Andrew Lunn
  2024-05-23 18:28   ` Horatiu Vultur
  2024-05-23 16:35 ` [EXTERNAL] " Suman Ghosh
  1 sibling, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2024-05-23 14:32 UTC (permalink / raw)
  To: Horatiu Vultur
  Cc: hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev, linux-kernel

On Thu, May 23, 2024 at 09:42:26AM +0200, Horatiu Vultur wrote:
> When the interrupt is enabled, the function lan8841_config_intr tries to
> clear any pending interrupts by reading the interrupt status, then
> checks the return value for errors and then continue to enable the
> interrupt. It has been seen that once the system gets out of sleep mode,
> the interrupt status has the value 0x400 meaning that the PHY detected
> that the link was in low power. That is correct value but the problem is
> that the check is wrong.  We try to check for errors but we return an
> error also in this case which is not an error. Therefore fix this by
> returning only when there is an error.

Is the second case also broken in the same way?

	} else {
		err = phy_write(phydev, LAN8814_INTC, 0);
		if (err)
			return err;

		err = phy_read(phydev, LAN8814_INTS);
	}

	return err;

e.g. there was an outstanding interrupt as interrupts are
disabled. This will cause the return value of the function to be not
0?

	Andrew

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

* RE: [EXTERNAL] [PATCH net] net: micrel: Fix lan8841_config_intr after getting out of sleep mode
  2024-05-23  7:42 [PATCH net] net: micrel: Fix lan8841_config_intr after getting out of sleep mode Horatiu Vultur
  2024-05-23 14:32 ` Andrew Lunn
@ 2024-05-23 16:35 ` Suman Ghosh
  2024-05-24  6:45   ` Horatiu Vultur
  1 sibling, 1 reply; 5+ messages in thread
From: Suman Ghosh @ 2024-05-23 16:35 UTC (permalink / raw)
  To: Horatiu Vultur, andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel

> 	if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
> 		err = phy_read(phydev, LAN8814_INTS);
>-		if (err)
>+		if (err < 0)
[Suman] Hi Horatiu,
Should we modify this check for phy_write() as well?
> 			return err;
>
> 		/* Enable / disable interrupts. It is OK to enable PTP
>interrupt
>--
>2.34.1
>


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

* Re: [PATCH net] net: micrel: Fix lan8841_config_intr after getting out of sleep mode
  2024-05-23 14:32 ` Andrew Lunn
@ 2024-05-23 18:28   ` Horatiu Vultur
  0 siblings, 0 replies; 5+ messages in thread
From: Horatiu Vultur @ 2024-05-23 18:28 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev, linux-kernel

The 05/23/2024 16:32, Andrew Lunn wrote:

Hi Andrew,

> 
> On Thu, May 23, 2024 at 09:42:26AM +0200, Horatiu Vultur wrote:
> > When the interrupt is enabled, the function lan8841_config_intr tries to
> > clear any pending interrupts by reading the interrupt status, then
> > checks the return value for errors and then continue to enable the
> > interrupt. It has been seen that once the system gets out of sleep mode,
> > the interrupt status has the value 0x400 meaning that the PHY detected
> > that the link was in low power. That is correct value but the problem is
> > that the check is wrong.  We try to check for errors but we return an
> > error also in this case which is not an error. Therefore fix this by
> > returning only when there is an error.
> 
> Is the second case also broken in the same way?
> 
>         } else {
>                 err = phy_write(phydev, LAN8814_INTC, 0);
>                 if (err)
>                         return err;
> 
>                 err = phy_read(phydev, LAN8814_INTS);
>         }
> 
>         return err;
> 
> e.g. there was an outstanding interrupt as interrupts are
> disabled. This will cause the return value of the function to be not
> 0?

Yes, that is correct. In that case, it would return some positive number
which is the status, which is incorrect.
I will fix this in the new version.

> 
>         Andrew

-- 
/Horatiu

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

* Re: [PATCH net] net: micrel: Fix lan8841_config_intr after getting out of sleep mode
  2024-05-23 16:35 ` [EXTERNAL] " Suman Ghosh
@ 2024-05-24  6:45   ` Horatiu Vultur
  0 siblings, 0 replies; 5+ messages in thread
From: Horatiu Vultur @ 2024-05-24  6:45 UTC (permalink / raw)
  To: Suman Ghosh
  Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

The 05/23/2024 16:35, Suman Ghosh wrote:

Hi Suman,

> 
> >       if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
> >               err = phy_read(phydev, LAN8814_INTS);
> >-              if (err)
> >+              if (err < 0)
> [Suman] Hi Horatiu,
> Should we modify this check for phy_write() as well?

I don't think we should modify this check for phy_write.
Because phy_write always return the error code. Which is negative or 0.

> >                       return err;
> >
> >               /* Enable / disable interrupts. It is OK to enable PTP
> >interrupt
> >--
> >2.34.1
> >
> 

-- 
/Horatiu

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

end of thread, other threads:[~2024-05-24  6:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-23  7:42 [PATCH net] net: micrel: Fix lan8841_config_intr after getting out of sleep mode Horatiu Vultur
2024-05-23 14:32 ` Andrew Lunn
2024-05-23 18:28   ` Horatiu Vultur
2024-05-23 16:35 ` [EXTERNAL] " Suman Ghosh
2024-05-24  6:45   ` Horatiu Vultur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®