diff options
author | Bob Pearson <rpearsonhpe@gmail.com> | 2022-02-09 00:16:38 +0300 |
---|---|---|
committer | Jason Gunthorpe <jgg@nvidia.com> | 2022-02-16 19:01:22 +0300 |
commit | 8a99c81f1231786c364963a9f335eab2cca816a4 (patch) | |
tree | 8779d3b6d336f7f762e8d81b3884ad937cedc802 /drivers/infiniband/sw/rxe/rxe_mcast.c | |
parent | 5bc15d1f7e3c9b84b40e020983e2cee19a546e72 (diff) | |
download | linux-8a99c81f1231786c364963a9f335eab2cca816a4.tar.xz |
RDMA/rxe: Replace int num_qp by atomic_t qp_num
Replace int num_qp in struct rxe_mcg by atomic_t qp_num.
Link: https://lore.kernel.org/r/20220208211644.123457-5-rpearsonhpe@gmail.com
Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'drivers/infiniband/sw/rxe/rxe_mcast.c')
-rw-r--r-- | drivers/infiniband/sw/rxe/rxe_mcast.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/infiniband/sw/rxe/rxe_mcast.c b/drivers/infiniband/sw/rxe/rxe_mcast.c index ae8103e819d5..1995d24caa60 100644 --- a/drivers/infiniband/sw/rxe/rxe_mcast.c +++ b/drivers/infiniband/sw/rxe/rxe_mcast.c @@ -111,7 +111,8 @@ static int rxe_attach_mcg(struct rxe_dev *rxe, struct rxe_qp *qp, } /* check limits after checking if already attached */ - if (mcg->num_qp >= rxe->attr.max_mcast_qp_attach) { + if (atomic_inc_return(&mcg->qp_num) > rxe->attr.max_mcast_qp_attach) { + atomic_dec(&mcg->qp_num); kfree(mca); err = -ENOMEM; goto out; @@ -122,7 +123,6 @@ static int rxe_attach_mcg(struct rxe_dev *rxe, struct rxe_qp *qp, mca->qp = qp; atomic_inc(&qp->mcg_num); - mcg->num_qp++; list_add(&mca->qp_list, &mcg->qp_list); err = 0; @@ -182,8 +182,7 @@ static int rxe_detach_mcg(struct rxe_dev *rxe, struct rxe_qp *qp, * object since we are still holding a ref * from the get key above. */ - mcg->num_qp--; - if (mcg->num_qp <= 0) + if (atomic_dec_return(&mcg->qp_num) <= 0) __rxe_destroy_mcg(mcg); atomic_dec(&qp->mcg_num); @@ -222,7 +221,7 @@ int rxe_attach_mcast(struct ib_qp *ibqp, union ib_gid *mgid, u16 mlid) err = rxe_attach_mcg(rxe, qp, mcg); /* if we failed to attach the first qp to mcg tear it down */ - if (mcg->num_qp == 0) + if (atomic_read(&mcg->qp_num) == 0) rxe_destroy_mcg(mcg); rxe_drop_ref(mcg); |