Commit 3197706a authored by Bob Pearson's avatar Bob Pearson Committed by Jason Gunthorpe
Browse files

RDMA/rxe: Use standard names for ref counting

Rename rxe_add_ref() to rxe_get() and rxe_drop_ref() to rxe_put().
Significantly improves readability for new readers.

Link: https://lore.kernel.org/r/20220304000808.225811-10-rpearsonhpe@gmail.com


Signed-off-by: default avatarBob Pearson <rpearsonhpe@gmail.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 3225717f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -127,14 +127,14 @@ struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt, struct rxe_ah **ahp)

		if (rxe_ah_pd(ah) != pkt->qp->pd) {
			pr_warn("PDs don't match for AH and QP\n");
			rxe_drop_ref(ah);
			rxe_put(ah);
			return NULL;
		}

		if (ahp)
			*ahp = ah;
		else
			rxe_drop_ref(ah);
			rxe_put(ah);

		return &ah->av;
	}
+4 −4
Original line number Diff line number Diff line
@@ -526,7 +526,7 @@ static void rxe_drain_resp_pkts(struct rxe_qp *qp, bool notify)
	struct rxe_queue *q = qp->sq.queue;

	while ((skb = skb_dequeue(&qp->resp_pkts))) {
		rxe_drop_ref(qp);
		rxe_put(qp);
		kfree_skb(skb);
		ib_device_put(qp->ibqp.device);
	}
@@ -548,7 +548,7 @@ static void free_pkt(struct rxe_pkt_info *pkt)
	struct ib_device *dev = qp->ibqp.device;

	kfree_skb(skb);
	rxe_drop_ref(qp);
	rxe_put(qp);
	ib_device_put(dev);
}

@@ -562,7 +562,7 @@ int rxe_completer(void *arg)
	enum comp_state state;
	int ret = 0;

	rxe_add_ref(qp);
	rxe_get(qp);

	if (!qp->valid || qp->req.state == QP_STATE_ERROR ||
	    qp->req.state == QP_STATE_RESET) {
@@ -761,7 +761,7 @@ int rxe_completer(void *arg)
done:
	if (pkt)
		free_pkt(pkt);
	rxe_drop_ref(qp);
	rxe_put(qp);

	return ret;
}
+2 −2
Original line number Diff line number Diff line
@@ -319,7 +319,7 @@ static int __rxe_init_mca(struct rxe_qp *qp, struct rxe_mcg *mcg,

	atomic_inc(&qp->mcg_num);

	rxe_add_ref(qp);
	rxe_get(qp);
	mca->qp = qp;

	list_add_tail(&mca->qp_list, &mcg->qp_list);
@@ -389,7 +389,7 @@ static void __rxe_cleanup_mca(struct rxe_mca *mca, struct rxe_mcg *mcg)
	atomic_dec(&mcg->qp_num);
	atomic_dec(&mcg->rxe->mcg_attach);
	atomic_dec(&mca->qp->mcg_num);
	rxe_drop_ref(mca->qp);
	rxe_put(mca->qp);

	kfree(mca);
}
+7 −7
Original line number Diff line number Diff line
@@ -459,7 +459,7 @@ int copy_data(

		if (offset >= sge->length) {
			if (mr) {
				rxe_drop_ref(mr);
				rxe_put(mr);
				mr = NULL;
			}
			sge++;
@@ -504,13 +504,13 @@ int copy_data(
	dma->resid	= resid;

	if (mr)
		rxe_drop_ref(mr);
		rxe_put(mr);

	return 0;

err2:
	if (mr)
		rxe_drop_ref(mr);
		rxe_put(mr);
err1:
	return err;
}
@@ -569,7 +569,7 @@ struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key,
		     (type == RXE_LOOKUP_REMOTE && mr->rkey != key) ||
		     mr_pd(mr) != pd || (access && !(access & mr->access)) ||
		     mr->state != RXE_MR_STATE_VALID)) {
		rxe_drop_ref(mr);
		rxe_put(mr);
		mr = NULL;
	}

@@ -613,7 +613,7 @@ int rxe_invalidate_mr(struct rxe_qp *qp, u32 rkey)
	ret = 0;

err_drop_ref:
	rxe_drop_ref(mr);
	rxe_put(mr);
err:
	return ret;
}
@@ -690,8 +690,8 @@ int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
	}

	mr->state = RXE_MR_STATE_INVALID;
	rxe_drop_ref(mr_pd(mr));
	rxe_drop_ref(mr);
	rxe_put(mr_pd(mr));
	rxe_put(mr);

	return 0;
}
+15 −15
Original line number Diff line number Diff line
@@ -12,11 +12,11 @@ int rxe_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata)
	struct rxe_dev *rxe = to_rdev(ibmw->device);
	int ret;

	rxe_add_ref(pd);
	rxe_get(pd);

	ret = rxe_add_to_pool(&rxe->mw_pool, mw);
	if (ret) {
		rxe_drop_ref(pd);
		rxe_put(pd);
		return ret;
	}

@@ -35,14 +35,14 @@ static void rxe_do_dealloc_mw(struct rxe_mw *mw)

		mw->mr = NULL;
		atomic_dec(&mr->num_mw);
		rxe_drop_ref(mr);
		rxe_put(mr);
	}

	if (mw->qp) {
		struct rxe_qp *qp = mw->qp;

		mw->qp = NULL;
		rxe_drop_ref(qp);
		rxe_put(qp);
	}

	mw->access = 0;
@@ -60,8 +60,8 @@ int rxe_dealloc_mw(struct ib_mw *ibmw)
	rxe_do_dealloc_mw(mw);
	spin_unlock_bh(&mw->lock);

	rxe_drop_ref(mw);
	rxe_drop_ref(pd);
	rxe_put(mw);
	rxe_put(pd);

	return 0;
}
@@ -170,7 +170,7 @@ static void rxe_do_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
	mw->length = wqe->wr.wr.mw.length;

	if (mw->mr) {
		rxe_drop_ref(mw->mr);
		rxe_put(mw->mr);
		atomic_dec(&mw->mr->num_mw);
		mw->mr = NULL;
	}
@@ -178,11 +178,11 @@ static void rxe_do_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
	if (mw->length) {
		mw->mr = mr;
		atomic_inc(&mr->num_mw);
		rxe_add_ref(mr);
		rxe_get(mr);
	}

	if (mw->ibmw.type == IB_MW_TYPE_2) {
		rxe_add_ref(qp);
		rxe_get(qp);
		mw->qp = qp;
	}
}
@@ -233,9 +233,9 @@ int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe)
	spin_unlock_bh(&mw->lock);
err_drop_mr:
	if (mr)
		rxe_drop_ref(mr);
		rxe_put(mr);
err_drop_mw:
	rxe_drop_ref(mw);
	rxe_put(mw);
err:
	return ret;
}
@@ -260,13 +260,13 @@ static void rxe_do_invalidate_mw(struct rxe_mw *mw)
	/* valid type 2 MW will always have a QP pointer */
	qp = mw->qp;
	mw->qp = NULL;
	rxe_drop_ref(qp);
	rxe_put(qp);

	/* valid type 2 MW will always have an MR pointer */
	mr = mw->mr;
	mw->mr = NULL;
	atomic_dec(&mr->num_mw);
	rxe_drop_ref(mr);
	rxe_put(mr);

	mw->access = 0;
	mw->addr = 0;
@@ -301,7 +301,7 @@ int rxe_invalidate_mw(struct rxe_qp *qp, u32 rkey)
err_unlock:
	spin_unlock_bh(&mw->lock);
err_drop_ref:
	rxe_drop_ref(mw);
	rxe_put(mw);
err:
	return ret;
}
@@ -322,7 +322,7 @@ struct rxe_mw *rxe_lookup_mw(struct rxe_qp *qp, int access, u32 rkey)
		     (mw->length == 0) ||
		     (access && !(access & mw->access)) ||
		     mw->state != RXE_MW_STATE_VALID)) {
		rxe_drop_ref(mw);
		rxe_put(mw);
		return NULL;
	}

Loading