aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/cxgb4/ev.c
diff options
context:
space:
mode:
authorKumar Sanghvi <kumaras@chelsio.com>2011-10-24 11:50:21 -0400
committerRoland Dreier <roland@purestorage.com>2011-10-31 14:34:53 -0400
commit581bbe2cd0694a935e0c3ccd7f011e10094f1df6 (patch)
tree38e536efa0d05d76964b09836def2210a00b41b5 /drivers/infiniband/hw/cxgb4/ev.c
parente14d62c05c0b8eff61c6fd46b4a78fb27c8cf38b (diff)
RDMA/cxgb4: Serialize calls to CQ's comp_handler
Commit 01e7da6ba53c ("RDMA/cxgb4: Make sure flush CQ entries are collected on connection close") introduced a potential problem where a CQ's comp_handler can get called simultaneously from different places in the iw_cxgb4 driver. This does not comply with Documentation/infiniband/core_locking.txt, which states that at a given point of time, there should be only one callback per CQ should be active. This problem was reported by Parav Pandit <Parav.Pandit@Emulex.Com>. Based on discussion between Parav Pandit and Steve Wise, this patch fixes the above problem by serializing the calls to a CQ's comp_handler using a spin_lock. Reported-by: Parav Pandit <Parav.Pandit@Emulex.Com> Signed-off-by: Kumar Sanghvi <kumaras@chelsio.com> Acked-by: Steve Wise <swise@opengridcomputing.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/hw/cxgb4/ev.c')
-rw-r--r--drivers/infiniband/hw/cxgb4/ev.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/infiniband/hw/cxgb4/ev.c b/drivers/infiniband/hw/cxgb4/ev.c
index c13041a0aeba..397cb36cf103 100644
--- a/drivers/infiniband/hw/cxgb4/ev.c
+++ b/drivers/infiniband/hw/cxgb4/ev.c
@@ -42,6 +42,7 @@ static void post_qp_event(struct c4iw_dev *dev, struct c4iw_cq *chp,
42{ 42{
43 struct ib_event event; 43 struct ib_event event;
44 struct c4iw_qp_attributes attrs; 44 struct c4iw_qp_attributes attrs;
45 unsigned long flag;
45 46
46 if ((qhp->attr.state == C4IW_QP_STATE_ERROR) || 47 if ((qhp->attr.state == C4IW_QP_STATE_ERROR) ||
47 (qhp->attr.state == C4IW_QP_STATE_TERMINATE)) { 48 (qhp->attr.state == C4IW_QP_STATE_TERMINATE)) {
@@ -72,7 +73,9 @@ static void post_qp_event(struct c4iw_dev *dev, struct c4iw_cq *chp,
72 if (qhp->ibqp.event_handler) 73 if (qhp->ibqp.event_handler)
73 (*qhp->ibqp.event_handler)(&event, qhp->ibqp.qp_context); 74 (*qhp->ibqp.event_handler)(&event, qhp->ibqp.qp_context);
74 75
76 spin_lock_irqsave(&chp->comp_handler_lock, flag);
75 (*chp->ibcq.comp_handler)(&chp->ibcq, chp->ibcq.cq_context); 77 (*chp->ibcq.comp_handler)(&chp->ibcq, chp->ibcq.cq_context);
78 spin_unlock_irqrestore(&chp->comp_handler_lock, flag);
76} 79}
77 80
78void c4iw_ev_dispatch(struct c4iw_dev *dev, struct t4_cqe *err_cqe) 81void c4iw_ev_dispatch(struct c4iw_dev *dev, struct t4_cqe *err_cqe)
@@ -183,11 +186,14 @@ out:
183int c4iw_ev_handler(struct c4iw_dev *dev, u32 qid) 186int c4iw_ev_handler(struct c4iw_dev *dev, u32 qid)
184{ 187{
185 struct c4iw_cq *chp; 188 struct c4iw_cq *chp;
189 unsigned long flag;
186 190
187 chp = get_chp(dev, qid); 191 chp = get_chp(dev, qid);
188 if (chp) 192 if (chp) {
193 spin_lock_irqsave(&chp->comp_handler_lock, flag);
189 (*chp->ibcq.comp_handler)(&chp->ibcq, chp->ibcq.cq_context); 194 (*chp->ibcq.comp_handler)(&chp->ibcq, chp->ibcq.cq_context);
190 else 195 spin_unlock_irqrestore(&chp->comp_handler_lock, flag);
196 } else
191 PDBG("%s unknown cqid 0x%x\n", __func__, qid); 197 PDBG("%s unknown cqid 0x%x\n", __func__, qid);
192 return 0; 198 return 0;
193} 199}