diff mbox series

[net,v2] net: micrel: Fix lan8841_config_intr after getting out of sleep mode

Message ID 20240524085350.359812-1-horatiu.vultur@microchip.com (mailing list archive)
State Accepted
Commit 4fb679040d9f758eeb3b4d01bbde6405bf20e64e
Delegated to: Netdev Maintainers
Headers show
Series [net,v2] net: micrel: Fix lan8841_config_intr after getting out of sleep mode | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 45 this patch: 45
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang fail Errors and warnings before: 36 this patch: 36
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn fail Errors and warnings before: 45 this patch: 45
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Horatiu Vultur May 24, 2024, 8:53 a.m. UTC
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(-)

Comments

Suman Ghosh May 24, 2024, 9:28 a.m. UTC | #1
>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
Andrew Lunn May 24, 2024, 3:55 p.m. UTC | #2
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
Russell King (Oracle) May 24, 2024, 3:57 p.m. UTC | #3
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!
patchwork-bot+netdevbpf@kernel.org May 28, 2024, 12:10 a.m. UTC | #4
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!
diff mbox series

Patch

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;