IB/qib: Use standard refcount wrapper for QPs
authorSebastian Sanchez <sebastian.sanchez@intel.com>
Thu, 8 Dec 2016 03:34:00 +0000 (19:34 -0800)
committerDoug Ledford <dledford@redhat.com>
Sun, 11 Dec 2016 20:29:42 +0000 (15:29 -0500)
Use the standard driver wrapper for QP reference counters.
This makes the code more maintainable.

Fixes: Commit 4d6f85c3fa55 ("IB/rdmavt, IB/qib, IB/hfi1: Use new QP put get routines")
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Sebastian Sanchez <sebastian.sanchez@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/qib/qib_driver.c
drivers/infiniband/hw/qib/qib_verbs.c

index 728e0a030d2e39c3b0b52b8135050d6642e3f980..2b5982f743ef0ca9f2f24080f6967ab7344f2b52 100644 (file)
@@ -420,8 +420,7 @@ static u32 qib_rcv_hdrerr(struct qib_ctxtdata *rcd, struct qib_pportdata *ppd,
                                                if (list_empty(&qp->rspwait)) {
                                                        qp->r_flags |=
                                                                RVT_R_RSP_NAK;
-                                                       atomic_inc(
-                                                               &qp->refcount);
+                                                       rvt_get_qp(qp);
                                                        list_add_tail(
                                                         &qp->rspwait,
                                                         &rcd->qp_wait_list);
index 954f15064514e1ba9dbf49f719a8999443bf09ac..2044824689530577d57e0e5d5eafb64695deb5ce 100644 (file)
@@ -464,7 +464,7 @@ static void mem_timer(unsigned long data)
                priv = list_entry(list->next, struct qib_qp_priv, iowait);
                qp = priv->owner;
                list_del_init(&priv->iowait);
-               atomic_inc(&qp->refcount);
+               rvt_get_qp(qp);
                if (!list_empty(list))
                        mod_timer(&dev->mem_timer, jiffies + 1);
        }
@@ -477,8 +477,7 @@ static void mem_timer(unsigned long data)
                        qib_schedule_send(qp);
                }
                spin_unlock_irqrestore(&qp->s_lock, flags);
-               if (atomic_dec_and_test(&qp->refcount))
-                       wake_up(&qp->wait);
+               rvt_put_qp(qp);
        }
 }
 
@@ -762,7 +761,7 @@ void qib_put_txreq(struct qib_verbs_txreq *tx)
                                  iowait);
                qp = priv->owner;
                list_del_init(&priv->iowait);
-               atomic_inc(&qp->refcount);
+               rvt_get_qp(qp);
                spin_unlock_irqrestore(&dev->rdi.pending_lock, flags);
 
                spin_lock_irqsave(&qp->s_lock, flags);
@@ -772,8 +771,7 @@ void qib_put_txreq(struct qib_verbs_txreq *tx)
                }
                spin_unlock_irqrestore(&qp->s_lock, flags);
 
-               if (atomic_dec_and_test(&qp->refcount))
-                       wake_up(&qp->wait);
+               rvt_put_qp(qp);
        } else
                spin_unlock_irqrestore(&dev->rdi.pending_lock, flags);
 }
@@ -808,7 +806,7 @@ void qib_verbs_sdma_desc_avail(struct qib_pportdata *ppd, unsigned avail)
                        break;
                avail -= qpp->s_tx->txreq.sg_count;
                list_del_init(&qpp->iowait);
-               atomic_inc(&qp->refcount);
+               rvt_get_qp(qp);
                qps[n++] = qp;
        }
 
@@ -822,8 +820,7 @@ void qib_verbs_sdma_desc_avail(struct qib_pportdata *ppd, unsigned avail)
                        qib_schedule_send(qp);
                }
                spin_unlock(&qp->s_lock);
-               if (atomic_dec_and_test(&qp->refcount))
-                       wake_up(&qp->wait);
+               rvt_put_qp(qp);
        }
 }
 
@@ -1288,7 +1285,7 @@ void qib_ib_piobufavail(struct qib_devdata *dd)
                priv = list_entry(list->next, struct qib_qp_priv, iowait);
                qp = priv->owner;
                list_del_init(&priv->iowait);
-               atomic_inc(&qp->refcount);
+               rvt_get_qp(qp);
                qps[n++] = qp;
        }
        dd->f_wantpiobuf_intr(dd, 0);
@@ -1306,8 +1303,7 @@ full:
                spin_unlock_irqrestore(&qp->s_lock, flags);
 
                /* Notify qib_destroy_qp() if it is waiting. */
-               if (atomic_dec_and_test(&qp->refcount))
-                       wake_up(&qp->wait);
+               rvt_put_qp(qp);
        }
 }