qedr: return error if destroy CQ failed
[linux-2.6-block.git] / drivers / infiniband / hw / qedr / verbs.c
index a61514296767dacf531b6a964ee25c272b861eb6..cbccd7d3ae1e922e9d43293513fb493d1a6ecfd5 100644 (file)
@@ -511,8 +511,10 @@ int qedr_dealloc_pd(struct ib_pd *ibpd)
        struct qedr_dev *dev = get_qedr_dev(ibpd->device);
        struct qedr_pd *pd = get_qedr_pd(ibpd);
 
-       if (!pd)
+       if (!pd) {
                pr_err("Invalid PD received in dealloc_pd\n");
+               return -EINVAL;
+       }
 
        DP_DEBUG(dev, QEDR_MSG_INIT, "Deallocating PD %d\n", pd->pd_id);
        dev->ops->rdma_dealloc_pd(dev->rdma_ctx, pd->pd_id);
@@ -888,6 +890,8 @@ struct ib_cq *qedr_create_cq(struct ib_device *ibdev,
 
                pbl_ptr = cq->q.pbl_tbl->pa;
                page_cnt = cq->q.pbl_info.num_pbes;
+
+               cq->ibcq.cqe = chain_entries;
        } else {
                cq->cq_type = QEDR_CQ_TYPE_KERNEL;
 
@@ -903,6 +907,7 @@ struct ib_cq *qedr_create_cq(struct ib_device *ibdev,
 
                page_cnt = qed_chain_get_page_cnt(&cq->pbl);
                pbl_ptr = qed_chain_get_pbl_phys(&cq->pbl);
+               cq->ibcq.cqe = cq->pbl.capacity;
        }
 
        qedr_init_cq_params(cq, ctx, dev, vector, chain_entries, page_cnt,
@@ -980,8 +985,13 @@ int qedr_destroy_cq(struct ib_cq *ibcq)
 
        /* GSIs CQs are handled by driver, so they don't exist in the FW */
        if (cq->cq_type != QEDR_CQ_TYPE_GSI) {
+               int rc;
+
                iparams.icid = cq->icid;
-               dev->ops->rdma_destroy_cq(dev->rdma_ctx, &iparams, &oparams);
+               rc = dev->ops->rdma_destroy_cq(dev->rdma_ctx, &iparams,
+                                              &oparams);
+               if (rc)
+                       return rc;
                dev->ops->common->chain_free(dev->cdev, &cq->pbl);
        }
 
@@ -1477,6 +1487,7 @@ struct ib_qp *qedr_create_qp(struct ib_pd *ibpd,
        struct qedr_ucontext *ctx = NULL;
        struct qedr_create_qp_ureq ureq;
        struct qedr_qp *qp;
+       struct ib_qp *ibqp;
        int rc = 0;
 
        DP_DEBUG(dev, QEDR_MSG_QP, "create qp: called from %s, pd=%p\n",
@@ -1486,13 +1497,13 @@ struct ib_qp *qedr_create_qp(struct ib_pd *ibpd,
        if (rc)
                return ERR_PTR(rc);
 
+       if (attrs->srq)
+               return ERR_PTR(-EINVAL);
+
        qp = kzalloc(sizeof(*qp), GFP_KERNEL);
        if (!qp)
                return ERR_PTR(-ENOMEM);
 
-       if (attrs->srq)
-               return ERR_PTR(-EINVAL);
-
        DP_DEBUG(dev, QEDR_MSG_QP,
                 "create qp: sq_cq=%p, sq_icid=%d, rq_cq=%p, rq_icid=%d\n",
                 get_qedr_cq(attrs->send_cq),
@@ -1508,7 +1519,10 @@ struct ib_qp *qedr_create_qp(struct ib_pd *ibpd,
                               "create qp: unexpected udata when creating GSI QP\n");
                        goto err0;
                }
-               return qedr_create_gsi_qp(dev, attrs, qp);
+               ibqp = qedr_create_gsi_qp(dev, attrs, qp);
+               if (IS_ERR(ibqp))
+                       kfree(qp);
+               return ibqp;
        }
 
        memset(&in_params, 0, sizeof(in_params));
@@ -2094,7 +2108,8 @@ int qedr_destroy_qp(struct ib_qp *ibqp)
        return rc;
 }
 
-struct ib_ah *qedr_create_ah(struct ib_pd *ibpd, struct ib_ah_attr *attr)
+struct ib_ah *qedr_create_ah(struct ib_pd *ibpd, struct ib_ah_attr *attr,
+                            struct ib_udata *udata)
 {
        struct qedr_ah *ah;
 
@@ -2413,8 +2428,7 @@ static void handle_completed_mrs(struct qedr_dev *dev, struct mr_info *info)
                 */
                pbl = list_first_entry(&info->inuse_pbl_list,
                                       struct qedr_pbl, list_entry);
-               list_del(&pbl->list_entry);
-               list_add_tail(&pbl->list_entry, &info->free_pbl_list);
+               list_move_tail(&pbl->list_entry, &info->free_pbl_list);
                info->completed_handled++;
        }
 }
@@ -2981,11 +2995,6 @@ int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
                return -EINVAL;
        }
 
-       if (!wr) {
-               DP_ERR(dev, "Got an empty post send.\n");
-               return -EINVAL;
-       }
-
        while (wr) {
                rc = __qedr_post_send(ibqp, wr, bad_wr);
                if (rc)