linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rdma_rxe: call comp_handler without holding cq->cq_lock
@ 2025-08-06 12:39 Philipp Reisner
  2025-08-07  1:09 ` Zhu Yanjun
  2025-08-19  2:37 ` Zhu Yanjun
  0 siblings, 2 replies; 13+ messages in thread
From: Philipp Reisner @ 2025-08-06 12:39 UTC (permalink / raw)
  To: Zhu Yanjun
  Cc: Jason Gunthorpe, Leon Romanovsky, linux-rdma, linux-kernel,
	Philipp Reisner

Allow the comp_handler callback implementation to call ib_poll_cq().
A call to ib_poll_cq() calls rxe_poll_cq() with the rdma_rxe driver.
And rxe_poll_cq() locks cq->cq_lock. That leads to a spinlock deadlock.

The Mellanox and Intel drivers allow a comp_handler callback
implementation to call ib_poll_cq().

Avoid the deadlock by calling the comp_handler callback without
holding cq->cw_lock.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
---
 drivers/infiniband/sw/rxe/rxe_cq.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_cq.c b/drivers/infiniband/sw/rxe/rxe_cq.c
index fffd144d509e..1195e109f89b 100644
--- a/drivers/infiniband/sw/rxe/rxe_cq.c
+++ b/drivers/infiniband/sw/rxe/rxe_cq.c
@@ -88,6 +88,7 @@ int rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited)
 	int full;
 	void *addr;
 	unsigned long flags;
+	u8 notify;
 
 	spin_lock_irqsave(&cq->cq_lock, flags);
 
@@ -110,14 +111,15 @@ int rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited)
 
 	queue_advance_producer(cq->queue, QUEUE_TYPE_TO_CLIENT);
 
-	if ((cq->notify & IB_CQ_NEXT_COMP) ||
-	    (cq->notify & IB_CQ_SOLICITED && solicited)) {
-		cq->notify = 0;
-		cq->ibcq.comp_handler(&cq->ibcq, cq->ibcq.cq_context);
-	}
+	notify = cq->notify;
+	cq->notify = 0;
 
 	spin_unlock_irqrestore(&cq->cq_lock, flags);
 
+	if ((notify & IB_CQ_NEXT_COMP) ||
+	    (notify & IB_CQ_SOLICITED && solicited))
+		cq->ibcq.comp_handler(&cq->ibcq, cq->ibcq.cq_context);
+
 	return 0;
 }
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-08-22  2:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-06 12:39 [PATCH] rdma_rxe: call comp_handler without holding cq->cq_lock Philipp Reisner
2025-08-07  1:09 ` Zhu Yanjun
2025-08-11  5:26   ` Philipp Reisner
2025-08-11 13:48     ` Zhu Yanjun
2025-08-12 15:54       ` Daisuke Matsuda
2025-08-14  5:33         ` Zhu Yanjun
2025-08-14 14:07           ` Daisuke Matsuda
     [not found]             ` <3cb43241-20d7-4ac9-b055-373fd058b3a3@linux.dev>
     [not found]               ` <2e645d1c-f853-4cee-9590-6f01820d027b@linux.dev>
2025-08-15  4:25                 ` Zhu Yanjun
2025-08-15 18:29             ` Yanjun.Zhu
2025-08-16 15:57               ` Daisuke Matsuda
2025-08-19  2:37 ` Zhu Yanjun
2025-08-19 17:24   ` Philipp Reisner
2025-08-22  2:54     ` Zhu Yanjun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).