All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>
Cc: "Marek Behún" <kabel@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	netdev@vger.kernel.org
Subject: [PATCH net-next 3/7] net: sfp: swap order of rtnl and st_mutex locks
Date: Wed, 17 May 2023 11:37:57 +0100	[thread overview]
Message-ID: <E1pzEXd-005jUW-GP@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <ZGSuTY8GqjM+sqta@shell.armlinux.org.uk>

Swap the order of the rtnl and st_mutex locks - st_mutex is now nested
beneath rtnl lock instead of rtnl being beneath st_mutex. This will
allow us to hold st_mutex only while manipulating the module's hardware
or software control state.

Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/sfp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 3fc703e4dd21..ffb6c37dac96 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -2600,8 +2600,8 @@ static void sfp_check_state(struct sfp *sfp)
 {
 	unsigned int state, i, changed;
 
-	mutex_lock(&sfp->st_mutex);
 	rtnl_lock();
+	mutex_lock(&sfp->st_mutex);
 	state = sfp_get_state(sfp);
 	changed = state ^ sfp->state;
 	if (sfp->tx_fault_ignore)
@@ -2628,8 +2628,8 @@ static void sfp_check_state(struct sfp *sfp)
 	if (changed & SFP_F_LOS)
 		sfp_sm_event(sfp, state & SFP_F_LOS ?
 				SFP_E_LOS_HIGH : SFP_E_LOS_LOW);
-	rtnl_unlock();
 	mutex_unlock(&sfp->st_mutex);
+	rtnl_unlock();
 }
 
 static irqreturn_t sfp_irq(int irq, void *data)
-- 
2.30.2


  parent reply	other threads:[~2023-05-17 10:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-17 10:37 [PATCH net-next 0/7] net: sfp: add support for control of rate selection Russell King (Oracle)
2023-05-17 10:37 ` [PATCH net-next 1/7] net: sfp: add helper to modify signal states Russell King (Oracle)
2023-05-17 10:37 ` [PATCH net-next 2/7] net: sfp: move rtnl lock to cover reading state Russell King (Oracle)
2023-05-17 10:37 ` Russell King (Oracle) [this message]
2023-05-17 10:38 ` [PATCH net-next 4/7] net: sfp: move sm_mutex into sfp_check_state() Russell King (Oracle)
2023-05-17 10:38 ` [PATCH net-next 5/7] net: sfp: change st_mutex locking Russell King (Oracle)
2023-05-17 10:38 ` [PATCH net-next 6/7] net: sfp: add support for setting signalling rate Russell King (Oracle)
2023-05-17 10:38 ` [PATCH net-next 7/7] net: sfp: add support for rate selection Russell King (Oracle)
2023-05-17 15:52   ` Andrew Lunn
2023-05-19  3:00 ` [PATCH net-next 0/7] net: sfp: add support for control of " patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1pzEXd-005jUW-GP@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kabel@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.