diff mbox series

net: sfp: Always call `sfp_sm_mod_remove()` on remove

Message ID 20240605084251.63502-1-csokas.bence@prolan.hu (mailing list archive)
State Accepted
Commit e96b2933152fd87b6a41765b2f58b158fde855b6
Delegated to: Netdev Maintainers
Headers show
Series net: sfp: Always call `sfp_sm_mod_remove()` on remove | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 901 this patch: 901
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 905 this patch: 905
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 No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 905 this patch: 905
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 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
netdev/contest success net-next-2024-06-05--15-00 (tests: 1043)

Commit Message

Csókás Bence June 5, 2024, 8:42 a.m. UTC
If the module is in SFP_MOD_ERROR, `sfp_sm_mod_remove()` will
not be run. As a consequence, `sfp_hwmon_remove()` is not getting
run either, leaving a stale `hwmon` device behind. `sfp_sm_mod_remove()`
itself checks `sfp->sm_mod_state` anyways, so this check was not
really needed in the first place.

Signed-off-by: "Csókás, Bence" <csokas.bence@prolan.hu>
---
 drivers/net/phy/sfp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Andrew Lunn June 6, 2024, 3:21 p.m. UTC | #1
On Wed, Jun 05, 2024 at 10:42:51AM +0200, Csókás, Bence wrote:
> If the module is in SFP_MOD_ERROR, `sfp_sm_mod_remove()` will
> not be run. As a consequence, `sfp_hwmon_remove()` is not getting
> run either, leaving a stale `hwmon` device behind. `sfp_sm_mod_remove()`
> itself checks `sfp->sm_mod_state` anyways, so this check was not
> really needed in the first place.
> 
> Signed-off-by: "Csókás, Bence" <csokas.bence@prolan.hu>

I was expecting Russell to review this. Maybe he missed it.

This looks O.K. to me:

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

    Andrew
Jakub Kicinski June 6, 2024, 3:28 p.m. UTC | #2
On Thu, 6 Jun 2024 17:21:45 +0200 Andrew Lunn wrote:
> I was expecting Russell to review this. Maybe he missed it.

While it's fresh in your mind - does it look like a fix to you?
From a quick look - we're failing to unregister a device?
Russell King (Oracle) June 6, 2024, 3:31 p.m. UTC | #3
On Thu, Jun 06, 2024 at 05:21:45PM +0200, Andrew Lunn wrote:
> On Wed, Jun 05, 2024 at 10:42:51AM +0200, Csókás, Bence wrote:
> > If the module is in SFP_MOD_ERROR, `sfp_sm_mod_remove()` will
> > not be run. As a consequence, `sfp_hwmon_remove()` is not getting
> > run either, leaving a stale `hwmon` device behind. `sfp_sm_mod_remove()`
> > itself checks `sfp->sm_mod_state` anyways, so this check was not
> > really needed in the first place.
> > 
> > Signed-off-by: "Csókás, Bence" <csokas.bence@prolan.hu>
> 
> I was expecting Russell to review this. Maybe he missed it.

I haven't missed it, I just haven't had the time to review and respond.
Work stuff is still very busy. I know this has been going on for well
over a month, but as it's partly coming from my employer and partly due
to medical stuff taking hours out of my working week, there's nothing
much I can do about it. I'm doing the best I can, but I know that I
can't keep up with what people expect of me at the moment.

I've had to tell Kory that I won't be able to review and test his
patch series - it's just totally impossible for me to be near the
hardware I need to test with his series _and_ have the time to do so.
I feel bad about that, because it's addressing the issue I raised a
number of years ago with PTP, yet I don't have the time to be involved
in that right now.

It's frustrating for me that I'm not able to do everything that I'd like
to...
Andrew Lunn June 6, 2024, 4:15 p.m. UTC | #4
On Thu, Jun 06, 2024 at 08:28:30AM -0700, Jakub Kicinski wrote:
> On Thu, 6 Jun 2024 17:21:45 +0200 Andrew Lunn wrote:
> > I was expecting Russell to review this. Maybe he missed it.
> 
> While it's fresh in your mind - does it look like a fix to you?
> From a quick look - we're failing to unregister a device?

Yes. A Fixes of:

commit d2e816c0293fc263b3f168c14992a5f1a50d7593
Author: Russell King <rmk+kernel@armlinux.org.uk>
Date:   Sun Nov 10 14:06:28 2019 +0000

    net: sfp: handle module remove outside state machine
    
    Removing a module resets the module state machine back to its initial
    state.  Rather than explicitly handling this in every state, handle it
    early on outside of the state machine.

is probably best, since that refactored to code.

	Andrew
patchwork-bot+netdevbpf@kernel.org June 7, 2024, 1:10 a.m. UTC | #5
Hello:

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

On Wed, 5 Jun 2024 10:42:51 +0200 you wrote:
> If the module is in SFP_MOD_ERROR, `sfp_sm_mod_remove()` will
> not be run. As a consequence, `sfp_hwmon_remove()` is not getting
> run either, leaving a stale `hwmon` device behind. `sfp_sm_mod_remove()`
> itself checks `sfp->sm_mod_state` anyways, so this check was not
> really needed in the first place.
> 
> Signed-off-by: "Csókás, Bence" <csokas.bence@prolan.hu>
> 
> [...]

Here is the summary with links:
  - net: sfp: Always call `sfp_sm_mod_remove()` on remove
    https://git.kernel.org/netdev/net/c/e96b2933152f

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index f75c9eb3958e..d999d9baadb2 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -2418,8 +2418,7 @@  static void sfp_sm_module(struct sfp *sfp, unsigned int event)
 
 	/* Handle remove event globally, it resets this state machine */
 	if (event == SFP_E_REMOVE) {
-		if (sfp->sm_mod_state > SFP_MOD_PROBE)
-			sfp_sm_mod_remove(sfp);
+		sfp_sm_mod_remove(sfp);
 		sfp_sm_mod_next(sfp, SFP_MOD_EMPTY, 0);
 		return;
 	}