netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] net: micrel: Fix lan8841_config_intr after getting out of sleep mode
@ 2024-05-24  8:53 Horatiu Vultur
  2024-05-24  9:28 ` [EXTERNAL] " Suman Ghosh
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Horatiu Vultur @ 2024-05-24  8:53 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, sumang
  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>
---
v1->v2:
- do the same also in case the interrupts are disabled.
---
 drivers/net/phy/micrel.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 13e30ea7eec5d..c0773d74d5104 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
@@ -4045,6 +4045,14 @@ static int lan8841_config_intr(struct phy_device *phydev)
 			return err;
 
 		err = phy_read(phydev, LAN8814_INTS);
+		if (err < 0)
+			return err;
+
+		/* Getting a positive value doesn't mean that is an error, it
+		 * just indicates what was the status. Therefore make sure to
+		 * clear the value and say that there is no error.
+		 */
+		err = 0;
 	}
 
 	return err;
-- 
2.34.1


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

* RE: [EXTERNAL] [PATCH net v2] net: micrel: Fix lan8841_config_intr after getting out of sleep mode
  2024-05-24  8:53 [PATCH net v2] net: micrel: Fix lan8841_config_intr after getting out of sleep mode Horatiu Vultur
@ 2024-05-24  9:28 ` Suman Ghosh
  2024-05-24 15:55 ` Andrew Lunn
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Suman Ghosh @ 2024-05-24  9:28 UTC (permalink / raw)
  To: Horatiu Vultur, andrew@lunn.ch, hkallweit1@gmail.com,
	linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com
  Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org

>diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index
>13e30ea7eec5d..c0773d74d5104 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 @@ -4045,6 +4045,14 @@ static int lan8841_config_intr(struct
>phy_device *phydev)
> 			return err;
>
> 		err = phy_read(phydev, LAN8814_INTS);
>+		if (err < 0)
>+			return err;
>+
>+		/* Getting a positive value doesn't mean that is an error, it
>+		 * just indicates what was the status. Therefore make sure to
>+		 * clear the value and say that there is no error.
>+		 */
>+		err = 0;
[Suman] Looks good to me.
Reviewed-by: Suman Ghosh <sumang@marvell.com>

> 	}
>
> 	return err;
>--
>2.34.1


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

* Re: [PATCH net v2] net: micrel: Fix lan8841_config_intr after getting out of sleep mode
  2024-05-24  8:53 [PATCH net v2] net: micrel: Fix lan8841_config_intr after getting out of sleep mode Horatiu Vultur
  2024-05-24  9:28 ` [EXTERNAL] " Suman Ghosh
@ 2024-05-24 15:55 ` Andrew Lunn
  2024-05-24 15:57 ` Russell King (Oracle)
  2024-05-28  0:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2024-05-24 15:55 UTC (permalink / raw)
  To: Horatiu Vultur
  Cc: hkallweit1, linux, davem, edumazet, kuba, pabeni, sumang, netdev,
	linux-kernel

On Fri, May 24, 2024 at 10:53:50AM +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.
> 
> Fixes: a8f1a19d27ef ("net: micrel: Add support for lan8841 PHY")
> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net v2] net: micrel: Fix lan8841_config_intr after getting out of sleep mode
  2024-05-24  8:53 [PATCH net v2] net: micrel: Fix lan8841_config_intr after getting out of sleep mode Horatiu Vultur
  2024-05-24  9:28 ` [EXTERNAL] " Suman Ghosh
  2024-05-24 15:55 ` Andrew Lunn
@ 2024-05-24 15:57 ` Russell King (Oracle)
  2024-05-28  0:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Russell King (Oracle) @ 2024-05-24 15:57 UTC (permalink / raw)
  To: Horatiu Vultur
  Cc: andrew, hkallweit1, davem, edumazet, kuba, pabeni, sumang, netdev,
	linux-kernel

On Fri, May 24, 2024 at 10:53:50AM +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.
> 
> Fixes: a8f1a19d27ef ("net: micrel: Add support for lan8841 PHY")
> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>

LGTM.

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Thanks!

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH net v2] net: micrel: Fix lan8841_config_intr after getting out of sleep mode
  2024-05-24  8:53 [PATCH net v2] net: micrel: Fix lan8841_config_intr after getting out of sleep mode Horatiu Vultur
                   ` (2 preceding siblings ...)
  2024-05-24 15:57 ` Russell King (Oracle)
@ 2024-05-28  0:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-05-28  0:10 UTC (permalink / raw)
  To: Horatiu Vultur
  Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, sumang,
	netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 24 May 2024 10:53:50 +0200 you 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.
> 
> [...]

Here is the summary with links:
  - [net,v2] net: micrel: Fix lan8841_config_intr after getting out of sleep mode
    https://git.kernel.org/netdev/net/c/4fb679040d9f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-05-28  0:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-24  8:53 [PATCH net v2] net: micrel: Fix lan8841_config_intr after getting out of sleep mode Horatiu Vultur
2024-05-24  9:28 ` [EXTERNAL] " Suman Ghosh
2024-05-24 15:55 ` Andrew Lunn
2024-05-24 15:57 ` Russell King (Oracle)
2024-05-28  0:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).