Skip to contentSkip to conversation

iw_cxgb4: only call CQ completion handlers if they exist

PATCH In review Steve Wise 1 participant 2 messages Jul 29, 2014 – Jul 30, 2014 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Steve Wise

author
#0 lore raw

PATCH 1/1 iw_cxgb4: only call CQ completion handlers if they exist

The iser ULP creates a CQ without a SQ completion handler, which is valid. This will cause iw_cxgb4 to crash the system if the QP is flushed. The fix is to simply not call the handler if the handler ptr is NULL.

---

 drivers/infiniband/hw/cxgb4/qp.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/cxgb4/qp.c +2 -2
index 086f62f..bdbe6b4 100644
@@ -1087,7 +1087,7 @@ static void __flush_qp(struct c4iw_qp *qhp, struct c4iw_cq *rchp,
 	flushed = c4iw_flush_rq(&qhp->wq, &rchp->cq, count);
 	spin_unlock(&qhp->lock);
 	spin_unlock_irqrestore(&rchp->lock, flag);
-	if (flushed) {
+	if (flushed && rchp->ibcq.comp_handler) {
 		spin_lock_irqsave(&rchp->comp_handler_lock, flag);
 		(*rchp->ibcq.comp_handler)(&rchp->ibcq, rchp->ibcq.cq_context);
 		spin_unlock_irqrestore(&rchp->comp_handler_lock, flag);
@@ -1101,7 +1101,7 @@ static void __flush_qp(struct c4iw_qp *qhp, struct c4iw_cq *rchp,
 	flushed = c4iw_flush_sq(qhp);
 	spin_unlock(&qhp->lock);
 	spin_unlock_irqrestore(&schp->lock, flag);
-	if (flushed) {
+	if (flushed && schp->ibcq.comp_handler) {
 		spin_lock_irqsave(&schp->comp_handler_lock, flag);
 		(*schp->ibcq.comp_handler)(&schp->ibcq, schp->ibcq.cq_context);
 		spin_unlock_irqrestore(&schp->comp_handler_lock, flag);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20140729212329.2419.84300.stgit-T4OLL4TyM9aNDNWfRnPdfg@public.gmane.org

author
#2 lore raw

Roland, this patch needs rework. As you pointed out to me, the iSER ULP never arms the SCQ, so iw_cxgb4 should not be trying to notify. Thus even though the patch below resolves the crash, it is not the correct fix.

I'll send a new patch that will key on whether the CQs are armed or not.

Steve.

Quoted 43 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Steve Wise
Sent: Tuesday, July 29, 2014 4:24 PM
To: [email protected]
Cc: [email protected]
Subject: [PATCH] iw_cxgb4: only call CQ completion handlers if they exist

The iser ULP creates a CQ without a SQ completion handler, which is valid. This will cause iw_cxgb4 to crash the system if the QP is flushed. The fix is to simply not call the handler if the handler ptr is NULL.

---

 drivers/infiniband/hw/cxgb4/qp.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/cxgb4/qp.c +2 -3
index 086f62f..bdbe6b4 100644
@@ -1087,7 +1087,7 @@ static void __flush_qp(struct c4iw_qp *qhp, struct c4iw_cq *rchp,
 	flushed = c4iw_flush_rq(&qhp->wq, &rchp->cq, count);
 	spin_unlock(&qhp->lock);
 	spin_unlock_irqrestore(&rchp->lock, flag);
-	if (flushed) {
+	if (flushed && rchp->ibcq.comp_handler) {
 		spin_lock_irqsave(&rchp->comp_handler_lock, flag);
 		(*rchp->ibcq.comp_handler)(&rchp->ibcq, rchp->ibcq.cq_context);
 		spin_unlock_irqrestore(&rchp->comp_handler_lock, flag);
@@ -1101,7 +1101,7 @@ static void __flush_qp(struct c4iw_qp *qhp, struct c4iw_cq *rchp,
 	flushed = c4iw_flush_sq(qhp);
 	spin_unlock(&qhp->lock);
 	spin_unlock_irqrestore(&schp->lock, flag);
-	if (flushed) {
+	if (flushed && schp->ibcq.comp_handler) {
 		spin_lock_irqsave(&schp->comp_handler_lock, flag);
 		(*schp->ibcq.comp_handler)(&schp->ibcq, schp->ibcq.cq_context);
 		spin_unlock_irqrestore(&schp->comp_handler_lock, flag);
 
--
Quoted 3 lines

To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html