Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Timothy Day <timday@thelustrecollective.com>
To: Michael Margolin <mrgolin@amazon.com>,
	Jason Gunthorpe <jgg@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	linux-rdma@vger.kernel.org
Cc: Gal Pressman <gal.pressman@linux.dev>,
	Yossi Leybovich <sleybo@amazon.com>,
	Marco Elver <elver@google.com>,
	Timothy Day <timday@thelustrecollective.com>
Subject: [PATCH v1 2/5] RDMA/efa: mark comp_ctx_pool* as guarded by comp_ctx_lock
Date: Thu, 16 Jul 2026 23:16:55 -0400	[thread overview]
Message-ID: <20260717031658.477397-3-timday@thelustrecollective.com> (raw)
In-Reply-To: <20260717031658.477397-1-timday@thelustrecollective.com>

comp_ctx_pool and comp_ctx_pool_next are only ever accessed
while holding comp_ctx_lock (in efa_com_alloc_ctx_id() and
efa_com_dealloc_ctx_id()), so annotate comp_ctx_pool_next
with __guarded_by() and comp_ctx_pool with __pt_guarded_by()
for Clang's context analysis.

The comp_ctx_lock initialisation in efa_com_init_comp_ctxt()
is marked with guard(spinlock_init). It is moved earlier in the
function to cover both comp_ctx_pool and comp_ctx_pool_next
initialisation - that are both done before concurrent access
is possible.

Signed-off-by: Timothy Day <timday@thelustrecollective.com>
---
 drivers/infiniband/hw/efa/efa_com.c | 4 ++--
 drivers/infiniband/hw/efa/efa_com.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/efa/efa_com.c b/drivers/infiniband/hw/efa/efa_com.c
index c48971595d5ef..4ef5ac363800d 100644
--- a/drivers/infiniband/hw/efa/efa_com.c
+++ b/drivers/infiniband/hw/efa/efa_com.c
@@ -386,6 +386,8 @@ static inline int efa_com_init_comp_ctxt(struct efa_com_admin_queue *aq)
 		return -ENOMEM;
 	}
 
+	guard(spinlock_init)(&aq->comp_ctx_lock);
+
 	for (i = 0; i < aq->depth; i++) {
 		comp_ctx = &aq->comp_ctx[i];
 		comp_ctx->status = EFA_CMD_UNUSED;
@@ -394,8 +396,6 @@ static inline int efa_com_init_comp_ctxt(struct efa_com_admin_queue *aq)
 		aq->comp_ctx_pool[i] = i;
 	}
 
-	spin_lock_init(&aq->comp_ctx_lock);
-
 	aq->comp_ctx_pool_next = 0;
 
 	return 0;
diff --git a/drivers/infiniband/hw/efa/efa_com.h b/drivers/infiniband/hw/efa/efa_com.h
index cd1c68cdc5c43..bf2c0a0f0d9e1 100644
--- a/drivers/infiniband/hw/efa/efa_com.h
+++ b/drivers/infiniband/hw/efa/efa_com.h
@@ -77,8 +77,8 @@ struct efa_com_admin_queue {
 	struct efa_com_stats_admin stats;
 
 	spinlock_t comp_ctx_lock; /* Protects completion context pool */
-	u32 *comp_ctx_pool;
-	u16 comp_ctx_pool_next;
+	u32 *comp_ctx_pool __pt_guarded_by(&comp_ctx_lock);
+	u16 comp_ctx_pool_next __guarded_by(&comp_ctx_lock);
 };
 
 struct efa_aenq_handlers;
-- 
2.39.5


  parent reply	other threads:[~2026-07-17  3:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17  3:16 [PATCH v1 0/5] Support Clang context analysis for RDMA/efa Timothy Day
2026-07-17  3:16 ` [PATCH v1 1/5] RDMA/efa: mark mmio_read seq_num as guarded by mmio_read lock Timothy Day
2026-07-17  3:16 ` Timothy Day [this message]
2026-07-17  3:16 ` [PATCH v1 3/5] RDMA/efa: mark admin CQ consumer state as guarded by the ACQ lock Timothy Day
2026-07-17  3:16 ` [PATCH v1 4/5] RDMA/efa: mark admin SQ producer state as guarded by the ASQ lock Timothy Day
2026-07-17  3:16 ` [PATCH v1 5/5] RDMA/efa: enable context analysis support for efa driver Timothy Day
2026-07-21 11:10 ` [PATCH v1 0/5] Support Clang context analysis for RDMA/efa Leon Romanovsky
2026-07-21 20:27   ` Timothy Day
2026-07-22  7:21     ` Leon Romanovsky

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=20260717031658.477397-3-timday@thelustrecollective.com \
    --to=timday@thelustrecollective.com \
    --cc=elver@google.com \
    --cc=gal.pressman@linux.dev \
    --cc=jgg@nvidia.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mrgolin@amazon.com \
    --cc=sleybo@amazon.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