[MTHCA] bugfix: lock was not released in one case of error flow in recv and send...
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sun, 14 May 2006 09:36:53 +0000 (09:36 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sun, 14 May 2006 09:36:53 +0000 (09:36 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@347 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mthca/user/mlnx_uvp_qp.c

index e61e9ed..683d83c 100644 (file)
@@ -159,8 +159,11 @@ int mthca_tavor_post_send(struct ibv_qp *ibqp, struct _ib_send_wr *wr,
 
        ind = qp->sq.next_ind;
 
-       if(ibqp->state == IBV_QPS_RESET)
-               return -EBUSY;
+       if(ibqp->state == IBV_QPS_RESET) {
+               ret = -EBUSY;
+               *bad_wr = wr;
+               goto err_busy;
+       }
        for (nreq = 0; wr; ++nreq, wr = wr->p_next) {
 
                if (mthca_wq_overflow(&qp->sq, nreq, to_mcq(qp->ibv_qp.send_cq))) {
@@ -375,6 +378,7 @@ out:
        qp->sq.next_ind = ind;
        qp->sq.head    += nreq;
 
+err_busy:
        cl_spinlock_release(&qp->sq.lock);
        
        UVP_EXIT(UVP_DBG_QP);
@@ -403,8 +407,12 @@ int mthca_tavor_post_recv(struct ibv_qp *ibqp, struct _ib_recv_wr *wr,
        /* XXX check that state is OK to post receive */
        
        ind = qp->rq.next_ind;
-       if(ibqp->state == IBV_QPS_RESET)
-               return -EBUSY;
+       if(ibqp->state == IBV_QPS_RESET) {
+               ret = -EBUSY;
+               *bad_wr = wr;
+               goto err_busy;
+       }
+       
        for (nreq = 0; wr; ++nreq, wr = wr->p_next) {
                if (unlikely(nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB)) {
                        nreq = 0;
@@ -497,6 +505,7 @@ out:
        qp->rq.next_ind = ind;
        qp->rq.head    += nreq;
 
+err_busy:
        cl_spinlock_release(&qp->rq.lock);
        UVP_EXIT(UVP_DBG_QP);
        return ret;
@@ -526,8 +535,11 @@ int mthca_arbel_post_send(struct ibv_qp *ibqp, struct _ib_send_wr *wr,
        /* XXX check that state is OK to post send */
 
        ind = qp->sq.head & (qp->sq.max - 1);
-       if(ibqp->state == IBV_QPS_RESET)
-               return -EBUSY;
+       if(ibqp->state == IBV_QPS_RESET) {
+               ret = -EBUSY;
+               *bad_wr = wr;
+               goto err_busy;
+       }
        for (nreq = 0; wr; ++nreq, wr = wr->p_next) {
                if (unlikely(nreq == MTHCA_ARBEL_MAX_WQES_PER_SEND_DB)) {
                        nreq = 0;
@@ -769,6 +781,7 @@ out:
                mthca_write64(doorbell, to_mctx(ibqp->pd->context), MTHCA_SEND_DOORBELL);
        }
 
+err_busy:
        cl_spinlock_release(&qp->sq.lock);
 
        UVP_EXIT(UVP_DBG_QP);
@@ -793,8 +806,11 @@ int mthca_arbel_post_recv(struct ibv_qp *ibqp, struct _ib_recv_wr *wr,
        /* XXX check that state is OK to post receive */
 
        ind = qp->rq.head & (qp->rq.max - 1);
-       if(ibqp->state == IBV_QPS_RESET)
-               return -EBUSY;
+       if(ibqp->state == IBV_QPS_RESET) {
+               ret = -EBUSY;
+               *bad_wr = wr;
+               goto err_busy;
+       }
        for (nreq = 0; wr; ++nreq, wr = wr->p_next) {
                if (mthca_wq_overflow(&qp->rq, nreq, to_mcq(qp->ibv_qp.recv_cq))) {//TODO sleybo: check the cq
                        UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_QP ,("RQ %06x full (%u head, %u tail,"
@@ -853,6 +869,7 @@ out:
                *qp->rq.db = cl_hton32(qp->rq.head & 0xffff);
        }
 
+err_busy:
        cl_spinlock_release(&qp->rq.lock);
        
        UVP_EXIT(UVP_DBG_QP);