qp->s_last = s_last;
                /* see post_send() */
                barrier();
-               rvt_put_swqe(wqe);
+               rvt_put_qp_swqe(qp, wqe);
                rvt_qp_swqe_complete(qp,
                                     wqe,
                                     ib_hfi1_wc_opcode[wqe->wr.opcode],
                u32 s_last;
 
                trdma_clean_swqe(qp, wqe);
-               rvt_put_swqe(wqe);
+               rvt_put_qp_swqe(qp, wqe);
                rvt_qp_wqe_unreserve(qp, wqe);
                s_last = qp->s_last;
                trace_hfi1_qp_send_completion(qp, wqe, s_last);
 
                qp->s_last = s_last;
                /* see post_send() */
                barrier();
-               rvt_put_swqe(wqe);
+               rvt_put_qp_swqe(qp, wqe);
                rvt_qp_swqe_complete(qp,
                                     wqe,
                                     ib_qib_wc_opcode[wqe->wr.opcode],
            qib_cmp24(qp->s_sending_psn, qp->s_sending_hpsn) > 0) {
                u32 s_last;
 
-               rvt_put_swqe(wqe);
+               rvt_put_qp_swqe(qp, wqe);
                s_last = qp->s_last;
                if (++s_last >= qp->s_size)
                        s_last = 0;
 
                while (qp->s_last != qp->s_head) {
                        struct rvt_swqe *wqe = rvt_get_swqe_ptr(qp, qp->s_last);
 
-                       rvt_put_swqe(wqe);
-                       if (qp->allowed_ops == IB_OPCODE_UD)
-                               atomic_dec(&ibah_to_rvtah(
-                                               wqe->ud_wr.ah)->refcount);
+                       rvt_put_qp_swqe(qp, wqe);
                        if (++qp->s_last >= qp->s_size)
                                qp->s_last = 0;
                        smp_wmb(); /* see qp_set_savail */
        qp->s_last = last;
        /* See post_send() */
        barrier();
-       rvt_put_swqe(wqe);
-       if (qp->allowed_ops == IB_OPCODE_UD)
-               atomic_dec(&ibah_to_rvtah(wqe->ud_wr.ah)->refcount);
+       rvt_put_qp_swqe(qp, wqe);
 
        rvt_qp_swqe_complete(qp,
                             wqe,
 
        return rvt_mod_retry_timer_ext(qp, 0);
 }
 
+/**
+ * rvt_put_qp_swqe - drop refs held by swqe
+ * @qp: the send qp
+ * @wqe: the send wqe
+ *
+ * This drops any references held by the swqe
+ */
+static inline void rvt_put_qp_swqe(struct rvt_qp *qp, struct rvt_swqe *wqe)
+{
+       rvt_put_swqe(wqe);
+       if (qp->allowed_ops == IB_OPCODE_UD)
+               atomic_dec(&ibah_to_rvtah(wqe->ud_wr.ah)->refcount);
+}
+
 extern const int  ib_rvt_state_ops[];
 
 struct rvt_dev_info;