Skip to content

Commit d71f4ac

Browse files
selvintxavierjgunthorpe
authored andcommitted
RDMA/bnxt_re: Fix the usage of control path spin locks
Control path completion processing always runs in tasklet context. To synchronize with the posting thread, there is no need to use the irq variant of spin lock. Use spin_lock_bh instead. Fixes: 1ac5a40 ("RDMA/bnxt_re: Add bnxt_re RoCE driver") Link: https://patch.msgid.link/r/[email protected] Signed-off-by: Kalesh AP <[email protected]> Signed-off-by: Selvin Xavier <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 78ed28e commit d71f4ac

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

drivers/infiniband/hw/bnxt_re/qplib_rcfw.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ static int __send_message(struct bnxt_qplib_rcfw *rcfw,
290290
struct bnxt_qplib_hwq *hwq;
291291
u32 sw_prod, cmdq_prod;
292292
struct pci_dev *pdev;
293-
unsigned long flags;
294293
u16 cookie;
295294
u8 *preq;
296295

@@ -301,7 +300,7 @@ static int __send_message(struct bnxt_qplib_rcfw *rcfw,
301300
/* Cmdq are in 16-byte units, each request can consume 1 or more
302301
* cmdqe
303302
*/
304-
spin_lock_irqsave(&hwq->lock, flags);
303+
spin_lock_bh(&hwq->lock);
305304
required_slots = bnxt_qplib_get_cmd_slots(msg->req);
306305
free_slots = HWQ_FREE_SLOTS(hwq);
307306
cookie = cmdq->seq_num & RCFW_MAX_COOKIE_VALUE;
@@ -311,7 +310,7 @@ static int __send_message(struct bnxt_qplib_rcfw *rcfw,
311310
dev_info_ratelimited(&pdev->dev,
312311
"CMDQ is full req/free %d/%d!",
313312
required_slots, free_slots);
314-
spin_unlock_irqrestore(&hwq->lock, flags);
313+
spin_unlock_bh(&hwq->lock);
315314
return -EAGAIN;
316315
}
317316
if (msg->block)
@@ -367,7 +366,7 @@ static int __send_message(struct bnxt_qplib_rcfw *rcfw,
367366
wmb();
368367
writel(cmdq_prod, cmdq->cmdq_mbox.prod);
369368
writel(RCFW_CMDQ_TRIG_VAL, cmdq->cmdq_mbox.db);
370-
spin_unlock_irqrestore(&hwq->lock, flags);
369+
spin_unlock_bh(&hwq->lock);
371370
/* Return the CREQ response pointer */
372371
return 0;
373372
}
@@ -486,7 +485,6 @@ static int __bnxt_qplib_rcfw_send_message(struct bnxt_qplib_rcfw *rcfw,
486485
{
487486
struct creq_qp_event *evnt = (struct creq_qp_event *)msg->resp;
488487
struct bnxt_qplib_crsqe *crsqe;
489-
unsigned long flags;
490488
u16 cookie;
491489
int rc;
492490
u8 opcode;
@@ -512,12 +510,12 @@ static int __bnxt_qplib_rcfw_send_message(struct bnxt_qplib_rcfw *rcfw,
512510
rc = __poll_for_resp(rcfw, cookie);
513511

514512
if (rc) {
515-
spin_lock_irqsave(&rcfw->cmdq.hwq.lock, flags);
513+
spin_lock_bh(&rcfw->cmdq.hwq.lock);
516514
crsqe = &rcfw->crsqe_tbl[cookie];
517515
crsqe->is_waiter_alive = false;
518516
if (rc == -ENODEV)
519517
set_bit(FIRMWARE_STALL_DETECTED, &rcfw->cmdq.flags);
520-
spin_unlock_irqrestore(&rcfw->cmdq.hwq.lock, flags);
518+
spin_unlock_bh(&rcfw->cmdq.hwq.lock);
521519
return -ETIMEDOUT;
522520
}
523521

@@ -628,7 +626,6 @@ static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw,
628626
u16 cookie, blocked = 0;
629627
bool is_waiter_alive;
630628
struct pci_dev *pdev;
631-
unsigned long flags;
632629
u32 wait_cmds = 0;
633630
int rc = 0;
634631

@@ -659,8 +656,7 @@ static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw,
659656
*
660657
*/
661658

662-
spin_lock_irqsave_nested(&hwq->lock, flags,
663-
SINGLE_DEPTH_NESTING);
659+
spin_lock_nested(&hwq->lock, SINGLE_DEPTH_NESTING);
664660
cookie = le16_to_cpu(qp_event->cookie);
665661
blocked = cookie & RCFW_CMD_IS_BLOCKING;
666662
cookie &= RCFW_MAX_COOKIE_VALUE;
@@ -672,7 +668,7 @@ static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw,
672668
dev_info(&pdev->dev,
673669
"rcfw timedout: cookie = %#x, free_slots = %d",
674670
cookie, crsqe->free_slots);
675-
spin_unlock_irqrestore(&hwq->lock, flags);
671+
spin_unlock(&hwq->lock);
676672
return rc;
677673
}
678674

@@ -720,7 +716,7 @@ static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw,
720716
__destroy_timedout_ah(rcfw,
721717
(struct creq_create_ah_resp *)
722718
qp_event);
723-
spin_unlock_irqrestore(&hwq->lock, flags);
719+
spin_unlock(&hwq->lock);
724720
}
725721
*num_wait += wait_cmds;
726722
return rc;
@@ -734,12 +730,11 @@ static void bnxt_qplib_service_creq(struct tasklet_struct *t)
734730
u32 type, budget = CREQ_ENTRY_POLL_BUDGET;
735731
struct bnxt_qplib_hwq *hwq = &creq->hwq;
736732
struct creq_base *creqe;
737-
unsigned long flags;
738733
u32 num_wakeup = 0;
739734
u32 hw_polled = 0;
740735

741736
/* Service the CREQ until budget is over */
742-
spin_lock_irqsave(&hwq->lock, flags);
737+
spin_lock_bh(&hwq->lock);
743738
while (budget > 0) {
744739
creqe = bnxt_qplib_get_qe(hwq, hwq->cons, NULL);
745740
if (!CREQ_CMP_VALID(creqe, creq->creq_db.dbinfo.flags))
@@ -782,7 +777,7 @@ static void bnxt_qplib_service_creq(struct tasklet_struct *t)
782777
if (hw_polled)
783778
bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo,
784779
rcfw->res->cctx, true);
785-
spin_unlock_irqrestore(&hwq->lock, flags);
780+
spin_unlock_bh(&hwq->lock);
786781
if (num_wakeup)
787782
wake_up_nr(&rcfw->cmdq.waitq, num_wakeup);
788783
}

0 commit comments

Comments
 (0)