i40iw: Fix incorrect assignment of SQ head
authorHenry Orosco <henry.orosco@intel.com>
Tue, 22 Nov 2016 15:44:20 +0000 (09:44 -0600)
committerDoug Ledford <dledford@redhat.com>
Mon, 5 Dec 2016 21:09:39 +0000 (16:09 -0500)
The SQ head is incorrectly incremented when the number
of WQEs required is greater than the number available.
The fix is to use the I40IW_RING_MOV_HEAD_BY_COUNT
macro. This checks for the SQ full condition first and
only if SQ has room for the request, then we move the
head appropriately.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/i40iw/i40iw_uk.c

index 5d9c3bfb73103bf534b393c5d758b5e39e8c9a25..4376cd628774248dbc18e7bf1ea731dcede4945c 100644 (file)
@@ -175,12 +175,10 @@ u64 *i40iw_qp_get_next_send_wqe(struct i40iw_qp_uk *qp,
                if (!*wqe_idx)
                        qp->swqe_polarity = !qp->swqe_polarity;
        }
-
-       for (i = 0; i < wqe_size / I40IW_QP_WQE_MIN_SIZE; i++) {
-               I40IW_RING_MOVE_HEAD(qp->sq_ring, ret_code);
-               if (ret_code)
-                       return NULL;
-       }
+       I40IW_RING_MOVE_HEAD_BY_COUNT(qp->sq_ring,
+                                     wqe_size / I40IW_QP_WQE_MIN_SIZE, ret_code);
+       if (ret_code)
+               return NULL;
 
        wqe = qp->sq_base[*wqe_idx].elem;