From: Mike Marciniszyn Date: Tue, 6 Sep 2016 11:34:21 +0000 (-0700) Subject: IB/rdmavt: Add functions to get and release QP references X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4107b8a029995e4a2c928b395a12ebc67d8e3689;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git IB/rdmavt: Add functions to get and release QP references This centralizes the function and improves code readability. Reviewed-by: Dennis Dalessandro Signed-off-by: Mike Marciniszyn Signed-off-by: Dennis Dalessandro Signed-off-by: Doug Ledford --- diff --git a/include/rdma/rdmavt_qp.h b/include/rdma/rdmavt_qp.h index bd34d0b56bf7..2c5183ef0243 100644 --- a/include/rdma/rdmavt_qp.h +++ b/include/rdma/rdmavt_qp.h @@ -465,6 +465,25 @@ static inline struct rvt_rwqe *rvt_get_rwqe_ptr(struct rvt_rq *rq, unsigned n) rq->max_sge * sizeof(struct ib_sge)) * n); } +/** + * rvt_get_qp - get a QP reference + * @qp - the QP to hold + */ +static inline void rvt_get_qp(struct rvt_qp *qp) +{ + atomic_inc(&qp->refcount); +} + +/** + * rvt_put_qp - release a QP reference + * @qp - the QP to release + */ +static inline void rvt_put_qp(struct rvt_qp *qp) +{ + if (qp && atomic_dec_and_test(&qp->refcount)) + wake_up(&qp->wait); +} + /** * rvt_qp_wqe_reserve - reserve operation * @qp - the rvt qp