diff mbox series

[RFC,net-next,2/7] net: sfp: move rtnl lock to cover reading state

Message ID E1pwhuj-001XoA-Oe@rmk-PC.armlinux.org.uk (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: sfp: add support for control of rate selection | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
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: 8 this patch: 8
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
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: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 14 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Russell King (Oracle) May 10, 2023, 11:23 a.m. UTC
As preparation to moving st_mutex inside rtnl_lock, we need to first
move the rtnl lock to cover reading the state.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/sfp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman May 11, 2023, 10:12 a.m. UTC | #1
On Wed, May 10, 2023 at 12:23:21PM +0100, Russell King (Oracle) wrote:
> As preparation to moving st_mutex inside rtnl_lock, we need to first
> move the rtnl lock to cover reading the state.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Simon Horman <simon.horman@corigine.com>
diff mbox series

Patch

diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index c97a87393fdb..3fc703e4dd21 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -2601,6 +2601,7 @@  static void sfp_check_state(struct sfp *sfp)
 	unsigned int state, i, changed;
 
 	mutex_lock(&sfp->st_mutex);
+	rtnl_lock();
 	state = sfp_get_state(sfp);
 	changed = state ^ sfp->state;
 	if (sfp->tx_fault_ignore)
@@ -2616,7 +2617,6 @@  static void sfp_check_state(struct sfp *sfp)
 	state |= sfp->state & (SFP_F_TX_DISABLE | SFP_F_RATE_SELECT);
 	sfp->state = state;
 
-	rtnl_lock();
 	if (changed & SFP_F_PRESENT)
 		sfp_sm_event(sfp, state & SFP_F_PRESENT ?
 				SFP_E_INSERT : SFP_E_REMOVE);