public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] RDMA/irdma: Fix data race in irdma_sc_ccq_arm
@ 2025-11-17 21:07 Tatyana Nikolova
  2025-11-17 21:07 ` [PATCH] RDMA/irdma: Fix data race in irdma_free_pble Tatyana Nikolova
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Tatyana Nikolova @ 2025-11-17 21:07 UTC (permalink / raw)
  To: jgg, leon; +Cc: linux-rdma, tatyana.e.nikolova, krzysztof.czurylo

From: Krzysztof Czurylo <krzysztof.czurylo@intel.com>

- Adds a lock around irdma_sc_ccq_arm body to prevent inter-thread
  data race.

- Fixes data race in irdma_sc_ccq_arm() reported by KCSAN:

BUG: KCSAN: data-race in irdma_sc_ccq_arm [irdma] / irdma_sc_ccq_arm [irdma]

read to 0xffff9d51b4034220 of 8 bytes by task 255 on cpu 11:
 irdma_sc_ccq_arm+0x36/0xd0 [irdma]
 irdma_cqp_ce_handler+0x300/0x310 [irdma]
 cqp_compl_worker+0x2a/0x40 [irdma]
 process_one_work+0x402/0x7e0
 worker_thread+0xb3/0x6d0
 kthread+0x178/0x1a0
 ret_from_fork+0x2c/0x50

write to 0xffff9d51b4034220 of 8 bytes by task 89 on cpu 3:
 irdma_sc_ccq_arm+0x7e/0xd0 [irdma]
 irdma_cqp_ce_handler+0x300/0x310 [irdma]
 irdma_wait_event+0xd4/0x3e0 [irdma]
 irdma_handle_cqp_op+0xa5/0x220 [irdma]
 irdma_hw_flush_wqes+0xb1/0x300 [irdma]
 irdma_flush_wqes+0x22e/0x3a0 [irdma]
 irdma_cm_disconn_true+0x4c7/0x5d0 [irdma]
 irdma_disconnect_worker+0x35/0x50 [irdma]
 process_one_work+0x402/0x7e0
 worker_thread+0xb3/0x6d0
 kthread+0x178/0x1a0
 ret_from_fork+0x2c/0x50

value changed: 0x0000000000024000 -> 0x0000000000034000

Signed-off-by: Krzysztof Czurylo <krzysztof.czurylo@intel.com>
Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
---
 drivers/infiniband/hw/irdma/ctrl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/infiniband/hw/irdma/ctrl.c b/drivers/infiniband/hw/irdma/ctrl.c
index 57bf6815e71e..c17b1c14dfe2 100644
--- a/drivers/infiniband/hw/irdma/ctrl.c
+++ b/drivers/infiniband/hw/irdma/ctrl.c
@@ -3868,11 +3868,13 @@ int irdma_sc_cqp_destroy(struct irdma_sc_cqp *cqp)
  */
 void irdma_sc_ccq_arm(struct irdma_sc_cq *ccq)
 {
+	unsigned long flags;
 	u64 temp_val;
 	u16 sw_cq_sel;
 	u8 arm_next_se;
 	u8 arm_seq_num;
 
+	spin_lock_irqsave(&ccq->dev->cqp_lock, flags);
 	get_64bit_val(ccq->cq_uk.shadow_area, 32, &temp_val);
 	sw_cq_sel = (u16)FIELD_GET(IRDMA_CQ_DBSA_SW_CQ_SELECT, temp_val);
 	arm_next_se = (u8)FIELD_GET(IRDMA_CQ_DBSA_ARM_NEXT_SE, temp_val);
@@ -3883,6 +3885,7 @@ void irdma_sc_ccq_arm(struct irdma_sc_cq *ccq)
 		   FIELD_PREP(IRDMA_CQ_DBSA_ARM_NEXT_SE, arm_next_se) |
 		   FIELD_PREP(IRDMA_CQ_DBSA_ARM_NEXT, 1);
 	set_64bit_val(ccq->cq_uk.shadow_area, 32, temp_val);
+	spin_unlock_irqrestore(&ccq->dev->cqp_lock, flags);
 
 	dma_wmb(); /* make sure shadow area is updated before arming */
 
-- 
2.31.1


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

end of thread, other threads:[~2025-11-25  0:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-17 21:07 [PATCH] RDMA/irdma: Fix data race in irdma_sc_ccq_arm Tatyana Nikolova
2025-11-17 21:07 ` [PATCH] RDMA/irdma: Fix data race in irdma_free_pble Tatyana Nikolova
2025-11-17 21:07 ` [PATCH] RDMA/irdma: Add a missing kfree of struct irdma_pci_f for GEN2 Tatyana Nikolova
2025-11-17 21:07 ` [PATCH] RDMA/irdma: Fix SIGBUS in AEQ destroy Tatyana Nikolova
2025-11-17 21:07 ` [PATCH] RDMA/irdma: Add missing mutex destroy Tatyana Nikolova
2025-11-17 21:07 ` [PATCH 1/2] RDMA/irdma: Do not directly rely on IB_PD_UNSAFE_GLOBAL_RKEY Tatyana Nikolova
2025-11-17 21:07 ` [PATCH 2/2] RDMA/irdma: Do not set IBK_LOCAL_DMA_LKEY for GEN3+ Tatyana Nikolova
2025-11-17 21:07 ` [PATCH] RDMA/irdma: Remove doorbell elision logic Tatyana Nikolova
2025-11-23  8:41 ` [PATCH] RDMA/irdma: Fix data race in irdma_sc_ccq_arm Leon Romanovsky
2025-11-25  0:01   ` Nikolova, Tatyana E

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox