Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IB/{rdmavt, qib, hfi1}: Use new routine to release reference counts

The reference count adjustments on reference count completion
are open coded throughout.

Add a routine to do all reference count adjustments and use.

Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

authored by

Mike Marciniszyn and committed by
Jason Gunthorpe
d40f69c9 52cdbcc2

+20 -11
+2 -2
drivers/infiniband/hw/hfi1/rc.c
··· 1834 1834 qp->s_last = s_last; 1835 1835 /* see post_send() */ 1836 1836 barrier(); 1837 - rvt_put_swqe(wqe); 1837 + rvt_put_qp_swqe(qp, wqe); 1838 1838 rvt_qp_swqe_complete(qp, 1839 1839 wqe, 1840 1840 ib_hfi1_wc_opcode[wqe->wr.opcode], ··· 1882 1882 u32 s_last; 1883 1883 1884 1884 trdma_clean_swqe(qp, wqe); 1885 - rvt_put_swqe(wqe); 1885 + rvt_put_qp_swqe(qp, wqe); 1886 1886 rvt_qp_wqe_unreserve(qp, wqe); 1887 1887 s_last = qp->s_last; 1888 1888 trace_hfi1_qp_send_completion(qp, wqe, s_last);
+2 -2
drivers/infiniband/hw/qib/qib_rc.c
··· 933 933 qp->s_last = s_last; 934 934 /* see post_send() */ 935 935 barrier(); 936 - rvt_put_swqe(wqe); 936 + rvt_put_qp_swqe(qp, wqe); 937 937 rvt_qp_swqe_complete(qp, 938 938 wqe, 939 939 ib_qib_wc_opcode[wqe->wr.opcode], ··· 975 975 qib_cmp24(qp->s_sending_psn, qp->s_sending_hpsn) > 0) { 976 976 u32 s_last; 977 977 978 - rvt_put_swqe(wqe); 978 + rvt_put_qp_swqe(qp, wqe); 979 979 s_last = qp->s_last; 980 980 if (++s_last >= qp->s_size) 981 981 s_last = 0;
+2 -7
drivers/infiniband/sw/rdmavt/qp.c
··· 623 623 while (qp->s_last != qp->s_head) { 624 624 struct rvt_swqe *wqe = rvt_get_swqe_ptr(qp, qp->s_last); 625 625 626 - rvt_put_swqe(wqe); 627 - if (qp->allowed_ops == IB_OPCODE_UD) 628 - atomic_dec(&ibah_to_rvtah( 629 - wqe->ud_wr.ah)->refcount); 626 + rvt_put_qp_swqe(qp, wqe); 630 627 if (++qp->s_last >= qp->s_size) 631 628 qp->s_last = 0; 632 629 smp_wmb(); /* see qp_set_savail */ ··· 2680 2683 qp->s_last = last; 2681 2684 /* See post_send() */ 2682 2685 barrier(); 2683 - rvt_put_swqe(wqe); 2684 - if (qp->allowed_ops == IB_OPCODE_UD) 2685 - atomic_dec(&ibah_to_rvtah(wqe->ud_wr.ah)->refcount); 2686 + rvt_put_qp_swqe(qp, wqe); 2686 2687 2687 2688 rvt_qp_swqe_complete(qp, 2688 2689 wqe,
+14
include/rdma/rdmavt_qp.h
··· 723 723 return rvt_mod_retry_timer_ext(qp, 0); 724 724 } 725 725 726 + /** 727 + * rvt_put_qp_swqe - drop refs held by swqe 728 + * @qp: the send qp 729 + * @wqe: the send wqe 730 + * 731 + * This drops any references held by the swqe 732 + */ 733 + static inline void rvt_put_qp_swqe(struct rvt_qp *qp, struct rvt_swqe *wqe) 734 + { 735 + rvt_put_swqe(wqe); 736 + if (qp->allowed_ops == IB_OPCODE_UD) 737 + atomic_dec(&ibah_to_rvtah(wqe->ud_wr.ah)->refcount); 738 + } 739 + 726 740 extern const int ib_rvt_state_ops[]; 727 741 728 742 struct rvt_dev_info;