Netdev List
 help / color / mirror / Atom feed
From: Heiko Carstens <hca@linux.ibm.com>
To: Alexandra Winter <wintera@linux.ibm.com>,
	Aswin Karuvally <aswin@linux.ibm.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: linux-s390@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH net-next 1/2] s390/ctcm: Add __context_unsafe() attribute to various functions
Date: Wed,  5 Aug 2026 16:50:31 +0200	[thread overview]
Message-ID: <20260805145032.1409325-2-hca@linux.ibm.com> (raw)
In-Reply-To: <20260805145032.1409325-1-hca@linux.ibm.com>

Disable context analysis for various functions to get rid of context
analysis compile time warnings using clang caused by conditional
locking like e.g.:

drivers/s390/net/ctcm_fsms.c:1457:8:
  warning: spinlock 'arg->cdev->ccwlock' is not held on every path through here
drivers/s390/net/ctcm_fsms.c:1459:4:
  warning: releasing spinlock 'arg->cdev->ccwlock' that was not held

Use __context_unsafe() to provide a short comment why context analysis is
disabled for each function. Each of those functions already contains a
comment that the (previous) sparse context analysis warnings due to
conditional locking should be ignored.

Remove those comments everywhere and use the __context_unsafe() attribute
instead.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
 drivers/s390/net/ctcm_fsms.c | 20 +++++++-------------
 drivers/s390/net/ctcm_mpc.c  |  6 ++----
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/drivers/s390/net/ctcm_fsms.c b/drivers/s390/net/ctcm_fsms.c
index bf917f426453..84fd394d3525 100644
--- a/drivers/s390/net/ctcm_fsms.c
+++ b/drivers/s390/net/ctcm_fsms.c
@@ -545,6 +545,7 @@ static void chx_rxidle(fsm_instance *fi, int event, void *arg)
  * arg		Generic pointer, casted from channel * upon call.
  */
 static void ctcm_chx_setmode(fsm_instance *fi, int event, void *arg)
+__context_unsafe(/* Conditional locking */)
 {
 	struct channel *ch = arg;
 	int rc;
@@ -563,8 +564,6 @@ static void ctcm_chx_setmode(fsm_instance *fi, int event, void *arg)
 
 	if (event == CTC_EVENT_TIMER)	/* only for timer not yet locked */
 		spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
-			/* Such conditional locking is undeterministic in
-			 * static view. => ignore sparse warnings here. */
 
 	rc = ccw_device_start(ch->cdev, &ch->ccw[6], 0, 0xff, 0);
 	if (event == CTC_EVENT_TIMER)	/* see above comments */
@@ -648,6 +647,7 @@ static void ctcm_chx_start(fsm_instance *fi, int event, void *arg)
  * arg		Generic pointer, casted from channel * upon call.
  */
 static void ctcm_chx_haltio(fsm_instance *fi, int event, void *arg)
+__context_unsafe(/* Conditional locking */)
 {
 	struct channel *ch = arg;
 	unsigned long saveflags = 0;
@@ -662,15 +662,12 @@ static void ctcm_chx_haltio(fsm_instance *fi, int event, void *arg)
 
 	if (event == CTC_EVENT_STOP)	/* only for STOP not yet locked */
 		spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
-			/* Such conditional locking is undeterministic in
-			 * static view. => ignore sparse warnings here. */
 	oldstate = fsm_getstate(fi);
 	fsm_newstate(fi, CTC_STATE_TERM);
 	rc = ccw_device_halt(ch->cdev, 0);
 
 	if (event == CTC_EVENT_STOP)
 		spin_unlock_irqrestore(get_ccwdev_lock(ch->cdev), saveflags);
-			/* see remark above about conditional locking */
 
 	if (rc != 0 && rc != -EBUSY) {
 		fsm_deltimer(&ch->timer);
@@ -824,6 +821,7 @@ static void ctcm_chx_setuperr(fsm_instance *fi, int event, void *arg)
  * arg		Generic pointer, casted from channel * upon call.
  */
 static void ctcm_chx_restart(fsm_instance *fi, int event, void *arg)
+__context_unsafe(/* Conditional locking */)
 {
 	struct channel *ch = arg;
 	struct net_device *dev = ch->netdev;
@@ -842,9 +840,6 @@ static void ctcm_chx_restart(fsm_instance *fi, int event, void *arg)
 	fsm_newstate(fi, CTC_STATE_STARTWAIT);
 	if (event == CTC_EVENT_TIMER)	/* only for timer not yet locked */
 		spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
-			/* Such conditional locking is a known problem for
-			 * sparse because its undeterministic in static view.
-			 * Warnings should be ignored here. */
 	rc = ccw_device_halt(ch->cdev, 0);
 	if (event == CTC_EVENT_TIMER)
 		spin_unlock_irqrestore(get_ccwdev_lock(ch->cdev), saveflags);
@@ -999,6 +994,7 @@ static void ctcm_chx_txiniterr(fsm_instance *fi, int event, void *arg)
  * arg		Generic pointer, casted from channel * upon call.
  */
 static void ctcm_chx_txretry(fsm_instance *fi, int event, void *arg)
+__context_unsafe(/* Conditional locking */)
 {
 	struct channel *ch = arg;
 	struct net_device *dev = ch->netdev;
@@ -1042,9 +1038,6 @@ static void ctcm_chx_txretry(fsm_instance *fi, int event, void *arg)
 		fsm_addtimer(&ch->timer, 1000, CTC_EVENT_TIMER, ch);
 		if (event == CTC_EVENT_TIMER) /* for TIMER not yet locked */
 			spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
-			/* Such conditional locking is a known problem for
-			 * sparse because its undeterministic in static view.
-			 * Warnings should be ignored here. */
 		if (do_debug_ccw)
 			ctcmpc_dumpit((char *)&ch->ccw[3],
 					sizeof(struct ccw1) * 3);
@@ -1383,6 +1376,7 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg)
  * arg		Generic pointer, casted from channel * upon call.
  */
 static void ctcmpc_chx_rx(fsm_instance *fi, int event, void *arg)
+__context_unsafe(/* Conditional locking */)
 {
 	struct channel		*ch = arg;
 	struct net_device	*dev = ch->netdev;
@@ -1462,7 +1456,7 @@ static void ctcmpc_chx_rx(fsm_instance *fi, int event, void *arg)
 			spin_lock_irqsave(
 				get_ccwdev_lock(ch->cdev), saveflags);
 		rc = ccw_device_start(ch->cdev, &ch->ccw[0], 0, 0xff, 0);
-		if (dolock) /* see remark about conditional locking */
+		if (dolock)
 			spin_unlock_irqrestore(
 				get_ccwdev_lock(ch->cdev), saveflags);
 		if (rc != 0)
@@ -1539,6 +1533,7 @@ static void ctcmpc_chx_firstio(fsm_instance *fi, int event, void *arg)
  * arg		Generic pointer, casted from channel * upon call.
  */
 void ctcmpc_chx_rxidle(fsm_instance *fi, int event, void *arg)
+__context_unsafe(/* Conditional locking */)
 {
 	struct channel *ch = arg;
 	struct net_device *dev = ch->netdev;
@@ -1566,7 +1561,6 @@ void ctcmpc_chx_rxidle(fsm_instance *fi, int event, void *arg)
 		ch->ccw[1].count = ch->max_bufsize;
 		CTCM_CCW_DUMP((char *)&ch->ccw[0], sizeof(struct ccw1) * 3);
 		if (event == CTC_EVENT_START)
-			/* see remark about conditional locking */
 			spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
 		rc = ccw_device_start(ch->cdev, &ch->ccw[0], 0, 0xff, 0);
 		if (event == CTC_EVENT_START)
diff --git a/drivers/s390/net/ctcm_mpc.c b/drivers/s390/net/ctcm_mpc.c
index aeb102537e7f..08e36685e578 100644
--- a/drivers/s390/net/ctcm_mpc.c
+++ b/drivers/s390/net/ctcm_mpc.c
@@ -1647,6 +1647,7 @@ static int mpc_validate_xid(struct mpcg_info *mpcginfo)
  * CTCM_PROTO_MPC only
  */
 static void mpc_action_side_xid(fsm_instance *fsm, void *arg, int side)
+__context_unsafe(/* Conditional locking */)
 {
 	struct channel *ch = arg;
 	int rc = 0;
@@ -1774,9 +1775,6 @@ static void mpc_action_side_xid(fsm_instance *fsm, void *arg, int side)
 	CTCM_D3_DUMP((char *)ch->xid_id, 4);
 
 	if (!in_hardirq()) {
-			 /* Such conditional locking is a known problem for
-			  * sparse because its static undeterministic.
-			  * Warnings should be ignored here. */
 		spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
 		gotlock = 1;
 	}
@@ -1784,7 +1782,7 @@ static void mpc_action_side_xid(fsm_instance *fsm, void *arg, int side)
 	fsm_addtimer(&ch->timer, 5000 , CTC_EVENT_TIMER, ch);
 	rc = ccw_device_start(ch->cdev, &ch->ccw[8], 0, 0xff, 0);
 
-	if (gotlock)	/* see remark above about conditional locking */
+	if (gotlock)
 		spin_unlock_irqrestore(get_ccwdev_lock(ch->cdev), saveflags);
 
 	if (rc != 0) {
-- 
2.53.0


  reply	other threads:[~2026-08-05 14:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05 14:50 [PATCH net-next 0/2] drivers/s390/net: Enable CONTEXT_ANALYSIS Heiko Carstens
2026-08-05 14:50 ` Heiko Carstens [this message]
2026-08-05 14:50 ` [PATCH net-next 2/2] " Heiko Carstens
2026-08-05 15:50 ` [PATCH net-next 0/2] " Alexandra Winter
2026-08-07 12:57 ` Simon Horman

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=20260805145032.1409325-2-hca@linux.ibm.com \
    --to=hca@linux.ibm.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=aswin@linux.ibm.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=wintera@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox