[PATCH V2 06/10] i40iw: Return correct error codes for destroy QP and CQ

Tatyana Nikolova
2016-12-09T17:55:00Z

From: Shiraz Saleem <shiraz.saleem-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Return correct error codes to application if destroy QP or
CQ fails. Make sure to deregister memory only if the
destroy is successful.

Signed-off-by: Shiraz Saleem <shiraz.saleem-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
providers/i40iw/i40iw_uverbs.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/providers/i40iw/i40iw_uverbs.c b/providers/i40iw/i40iw_uverbs.c
index 651a91d..ef381ed 100644
--- a/providers/i40iw/i40iw_uverbs.c
+++ b/providers/i40iw/i40iw_uverbs.c
@@ -305,9 +305,11 @@ int i40iw_udestroy_cq(struct ibv_cq *cq)
struct i40iw_ucq *iwucq = to_i40iw_ucq(cq);
int ret;

+ ret = ibv_cmd_destroy_cq(cq);
+ if (ret)
+ return ret;
+
ibv_cmd_dereg_mr(&iwucq->mr);
- if (ibv_cmd_destroy_cq(cq))
- fprintf(stderr, PFX "%s: failed to destroy CQ\n", __func__);

free(iwucq->cq.cq_base);
ret = pthread_spin_destroy(&iwucq->lock);
@@ -460,16 +462,24 @@ void i40iw_cq_event(struct ibv_cq *cq)
pthread_spin_unlock(&iwucq->lock);
}

-static void i40iw_destroy_vmapped_qp(struct i40iw_uqp *iwuqp,
+static int i40iw_destroy_vmapped_qp(struct i40iw_uqp *iwuqp,
struct i40iw_qp_quanta *sq_base)
{
+ int ret;
+
+ ret = ibv_cmd_destroy_qp(&iwuqp->ibv_qp);
+ if (ret)
+ return ret;
+
if (iwuqp->push_db)
munmap(iwuqp->push_db, I40IW_HW_PAGE_SIZE);
if (iwuqp->push_wqe)
munmap(iwuqp->push_wqe, I40IW_HW_PAGE_SIZE);
- ibv_cmd_destroy_qp(&iwuqp->ibv_qp);
+
ibv_cmd_dereg_mr(&iwuqp->mr);
free((void *)sq_base);
+
+ return 0;
}

/**
@@ -759,7 +769,9 @@ int i40iw_udestroy_qp(struct ibv_qp *qp)
struct i40iw_uqp *iwuqp = to_i40iw_uqp(qp);
int ret;

- i40iw_destroy_vmapped_qp(iwuqp, iwuqp->qp.sq_base);
+ ret = i40iw_destroy_vmapped_qp(iwuqp, iwuqp->qp.sq_base);
+ if (ret)
+ return ret;

if (iwuqp->qp.sq_wrtrk_array)
free(iwuqp->qp.sq_wrtrk_array);
--
1.8.5.2