Skip to content

Commit 3197706

Browse files
rpearsonhpe-designjgunthorpe
authored andcommitted
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: Bob Pearson <rpearsonhpe@gmail.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 3225717 commit 3197706

12 files changed

Lines changed: 94 additions & 96 deletions

File tree

drivers/infiniband/sw/rxe/rxe_av.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,14 @@ struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt, struct rxe_ah **ahp)
127127

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

134134
if (ahp)
135135
*ahp = ah;
136136
else
137-
rxe_drop_ref(ah);
137+
rxe_put(ah);
138138

139139
return &ah->av;
140140
}

drivers/infiniband/sw/rxe/rxe_comp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ static void rxe_drain_resp_pkts(struct rxe_qp *qp, bool notify)
526526
struct rxe_queue *q = qp->sq.queue;
527527

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

550550
kfree_skb(skb);
551-
rxe_drop_ref(qp);
551+
rxe_put(qp);
552552
ib_device_put(dev);
553553
}
554554

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

565-
rxe_add_ref(qp);
565+
rxe_get(qp);
566566

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

766766
return ret;
767767
}

drivers/infiniband/sw/rxe/rxe_mcast.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static int __rxe_init_mca(struct rxe_qp *qp, struct rxe_mcg *mcg,
319319

320320
atomic_inc(&qp->mcg_num);
321321

322-
rxe_add_ref(qp);
322+
rxe_get(qp);
323323
mca->qp = qp;
324324

325325
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)
389389
atomic_dec(&mcg->qp_num);
390390
atomic_dec(&mcg->rxe->mcg_attach);
391391
atomic_dec(&mca->qp->mcg_num);
392-
rxe_drop_ref(mca->qp);
392+
rxe_put(mca->qp);
393393

394394
kfree(mca);
395395
}

drivers/infiniband/sw/rxe/rxe_mr.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ int copy_data(
459459

460460
if (offset >= sge->length) {
461461
if (mr) {
462-
rxe_drop_ref(mr);
462+
rxe_put(mr);
463463
mr = NULL;
464464
}
465465
sge++;
@@ -504,13 +504,13 @@ int copy_data(
504504
dma->resid = resid;
505505

506506
if (mr)
507-
rxe_drop_ref(mr);
507+
rxe_put(mr);
508508

509509
return 0;
510510

511511
err2:
512512
if (mr)
513-
rxe_drop_ref(mr);
513+
rxe_put(mr);
514514
err1:
515515
return err;
516516
}
@@ -569,7 +569,7 @@ struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key,
569569
(type == RXE_LOOKUP_REMOTE && mr->rkey != key) ||
570570
mr_pd(mr) != pd || (access && !(access & mr->access)) ||
571571
mr->state != RXE_MR_STATE_VALID)) {
572-
rxe_drop_ref(mr);
572+
rxe_put(mr);
573573
mr = NULL;
574574
}
575575

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

615615
err_drop_ref:
616-
rxe_drop_ref(mr);
616+
rxe_put(mr);
617617
err:
618618
return ret;
619619
}
@@ -690,8 +690,8 @@ int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
690690
}
691691

692692
mr->state = RXE_MR_STATE_INVALID;
693-
rxe_drop_ref(mr_pd(mr));
694-
rxe_drop_ref(mr);
693+
rxe_put(mr_pd(mr));
694+
rxe_put(mr);
695695

696696
return 0;
697697
}

drivers/infiniband/sw/rxe/rxe_mw.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ int rxe_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata)
1212
struct rxe_dev *rxe = to_rdev(ibmw->device);
1313
int ret;
1414

15-
rxe_add_ref(pd);
15+
rxe_get(pd);
1616

1717
ret = rxe_add_to_pool(&rxe->mw_pool, mw);
1818
if (ret) {
19-
rxe_drop_ref(pd);
19+
rxe_put(pd);
2020
return ret;
2121
}
2222

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

3636
mw->mr = NULL;
3737
atomic_dec(&mr->num_mw);
38-
rxe_drop_ref(mr);
38+
rxe_put(mr);
3939
}
4040

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

4444
mw->qp = NULL;
45-
rxe_drop_ref(qp);
45+
rxe_put(qp);
4646
}
4747

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

63-
rxe_drop_ref(mw);
64-
rxe_drop_ref(pd);
63+
rxe_put(mw);
64+
rxe_put(pd);
6565

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

172172
if (mw->mr) {
173-
rxe_drop_ref(mw->mr);
173+
rxe_put(mw->mr);
174174
atomic_dec(&mw->mr->num_mw);
175175
mw->mr = NULL;
176176
}
177177

178178
if (mw->length) {
179179
mw->mr = mr;
180180
atomic_inc(&mr->num_mw);
181-
rxe_add_ref(mr);
181+
rxe_get(mr);
182182
}
183183

184184
if (mw->ibmw.type == IB_MW_TYPE_2) {
185-
rxe_add_ref(qp);
185+
rxe_get(qp);
186186
mw->qp = qp;
187187
}
188188
}
@@ -233,9 +233,9 @@ int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe)
233233
spin_unlock_bh(&mw->lock);
234234
err_drop_mr:
235235
if (mr)
236-
rxe_drop_ref(mr);
236+
rxe_put(mr);
237237
err_drop_mw:
238-
rxe_drop_ref(mw);
238+
rxe_put(mw);
239239
err:
240240
return ret;
241241
}
@@ -260,13 +260,13 @@ static void rxe_do_invalidate_mw(struct rxe_mw *mw)
260260
/* valid type 2 MW will always have a QP pointer */
261261
qp = mw->qp;
262262
mw->qp = NULL;
263-
rxe_drop_ref(qp);
263+
rxe_put(qp);
264264

265265
/* valid type 2 MW will always have an MR pointer */
266266
mr = mw->mr;
267267
mw->mr = NULL;
268268
atomic_dec(&mr->num_mw);
269-
rxe_drop_ref(mr);
269+
rxe_put(mr);
270270

271271
mw->access = 0;
272272
mw->addr = 0;
@@ -301,7 +301,7 @@ int rxe_invalidate_mw(struct rxe_qp *qp, u32 rkey)
301301
err_unlock:
302302
spin_unlock_bh(&mw->lock);
303303
err_drop_ref:
304-
rxe_drop_ref(mw);
304+
rxe_put(mw);
305305
err:
306306
return ret;
307307
}
@@ -322,7 +322,7 @@ struct rxe_mw *rxe_lookup_mw(struct rxe_qp *qp, int access, u32 rkey)
322322
(mw->length == 0) ||
323323
(access && !(access & mw->access)) ||
324324
mw->state != RXE_MW_STATE_VALID)) {
325-
rxe_drop_ref(mw);
325+
rxe_put(mw);
326326
return NULL;
327327
}
328328

drivers/infiniband/sw/rxe/rxe_net.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static void rxe_skb_tx_dtor(struct sk_buff *skb)
348348
skb_out < RXE_INFLIGHT_SKBS_PER_QP_LOW))
349349
rxe_run_task(&qp->req.task, 1);
350350

351-
rxe_drop_ref(qp);
351+
rxe_put(qp);
352352
}
353353

354354
static int rxe_send(struct sk_buff *skb, struct rxe_pkt_info *pkt)
@@ -358,7 +358,7 @@ static int rxe_send(struct sk_buff *skb, struct rxe_pkt_info *pkt)
358358
skb->destructor = rxe_skb_tx_dtor;
359359
skb->sk = pkt->qp->sk->sk;
360360

361-
rxe_add_ref(pkt->qp);
361+
rxe_get(pkt->qp);
362362
atomic_inc(&pkt->qp->skb_out);
363363

364364
if (skb->protocol == htons(ETH_P_IP)) {
@@ -368,7 +368,7 @@ static int rxe_send(struct sk_buff *skb, struct rxe_pkt_info *pkt)
368368
} else {
369369
pr_err("Unknown layer 3 protocol: %d\n", skb->protocol);
370370
atomic_dec(&pkt->qp->skb_out);
371-
rxe_drop_ref(pkt->qp);
371+
rxe_put(pkt->qp);
372372
kfree_skb(skb);
373373
return -EINVAL;
374374
}

drivers/infiniband/sw/rxe/rxe_pool.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,14 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem);
6969
/* lookup an indexed object from index. takes a reference on object */
7070
void *rxe_pool_get_index(struct rxe_pool *pool, u32 index);
7171

72-
/* take a reference on an object */
7372
int __rxe_get(struct rxe_pool_elem *elem);
7473

75-
#define rxe_add_ref(obj) __rxe_get(&(obj)->elem)
74+
#define rxe_get(obj) __rxe_get(&(obj)->elem)
7675

77-
/* drop a reference on an object */
7876
int __rxe_put(struct rxe_pool_elem *elem);
7977

80-
#define rxe_drop_ref(obj) __rxe_put(&(obj)->elem)
78+
#define rxe_put(obj) __rxe_put(&(obj)->elem)
8179

82-
#define rxe_read_ref(obj) kref_read(&(obj)->elem.ref_cnt)
80+
#define rxe_read(obj) kref_read(&(obj)->elem.ref_cnt)
8381

8482
#endif /* RXE_POOL_H */

drivers/infiniband/sw/rxe/rxe_qp.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,11 @@ int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd,
323323
struct rxe_cq *scq = to_rcq(init->send_cq);
324324
struct rxe_srq *srq = init->srq ? to_rsrq(init->srq) : NULL;
325325

326-
rxe_add_ref(pd);
327-
rxe_add_ref(rcq);
328-
rxe_add_ref(scq);
326+
rxe_get(pd);
327+
rxe_get(rcq);
328+
rxe_get(scq);
329329
if (srq)
330-
rxe_add_ref(srq);
330+
rxe_get(srq);
331331

332332
qp->pd = pd;
333333
qp->rcq = rcq;
@@ -359,10 +359,10 @@ int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd,
359359
qp->srq = NULL;
360360

361361
if (srq)
362-
rxe_drop_ref(srq);
363-
rxe_drop_ref(scq);
364-
rxe_drop_ref(rcq);
365-
rxe_drop_ref(pd);
362+
rxe_put(srq);
363+
rxe_put(scq);
364+
rxe_put(rcq);
365+
rxe_put(pd);
366366

367367
return err;
368368
}
@@ -521,7 +521,7 @@ static void rxe_qp_reset(struct rxe_qp *qp)
521521
qp->resp.sent_psn_nak = 0;
522522

523523
if (qp->resp.mr) {
524-
rxe_drop_ref(qp->resp.mr);
524+
rxe_put(qp->resp.mr);
525525
qp->resp.mr = NULL;
526526
}
527527

@@ -809,20 +809,20 @@ static void rxe_qp_do_cleanup(struct work_struct *work)
809809
rxe_queue_cleanup(qp->sq.queue);
810810

811811
if (qp->srq)
812-
rxe_drop_ref(qp->srq);
812+
rxe_put(qp->srq);
813813

814814
if (qp->rq.queue)
815815
rxe_queue_cleanup(qp->rq.queue);
816816

817817
if (qp->scq)
818-
rxe_drop_ref(qp->scq);
818+
rxe_put(qp->scq);
819819
if (qp->rcq)
820-
rxe_drop_ref(qp->rcq);
820+
rxe_put(qp->rcq);
821821
if (qp->pd)
822-
rxe_drop_ref(qp->pd);
822+
rxe_put(qp->pd);
823823

824824
if (qp->resp.mr)
825-
rxe_drop_ref(qp->resp.mr);
825+
rxe_put(qp->resp.mr);
826826

827827
if (qp_type(qp) == IB_QPT_RC)
828828
sk_dst_reset(qp->sk->sk);

drivers/infiniband/sw/rxe/rxe_recv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static int hdr_check(struct rxe_pkt_info *pkt)
217217
return 0;
218218

219219
err2:
220-
rxe_drop_ref(qp);
220+
rxe_put(qp);
221221
err1:
222222
return -EINVAL;
223223
}
@@ -288,11 +288,11 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)
288288

289289
cpkt = SKB_TO_PKT(cskb);
290290
cpkt->qp = qp;
291-
rxe_add_ref(qp);
291+
rxe_get(qp);
292292
rxe_rcv_pkt(cpkt, cskb);
293293
} else {
294294
pkt->qp = qp;
295-
rxe_add_ref(qp);
295+
rxe_get(qp);
296296
rxe_rcv_pkt(pkt, skb);
297297
skb = NULL; /* mark consumed */
298298
}
@@ -397,7 +397,7 @@ void rxe_rcv(struct sk_buff *skb)
397397

398398
drop:
399399
if (pkt->qp)
400-
rxe_drop_ref(pkt->qp);
400+
rxe_put(pkt->qp);
401401

402402
kfree_skb(skb);
403403
ib_device_put(&rxe->ib_dev);

0 commit comments

Comments
 (0)