Skip to content

Commit cde3f5d

Browse files
rpearsonhpe-designjgunthorpe
authored andcommitted
RDMA/rxe: Move mw cleanup code to rxe_mw_cleanup()
Move code from rxe_dealloc_mw() to rxe_mw_cleanup() to allow flows which hold a reference to mw to complete. Link: https://lore.kernel.org/r/20220421014042.26985-7-rpearsonhpe@gmail.com Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent cf40367 commit cde3f5d

2 files changed

Lines changed: 29 additions & 29 deletions

File tree

drivers/infiniband/sw/rxe/rxe_mw.c

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -36,40 +36,11 @@ int rxe_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata)
3636
return 0;
3737
}
3838

39-
static void rxe_do_dealloc_mw(struct rxe_mw *mw)
40-
{
41-
if (mw->mr) {
42-
struct rxe_mr *mr = mw->mr;
43-
44-
mw->mr = NULL;
45-
atomic_dec(&mr->num_mw);
46-
rxe_put(mr);
47-
}
48-
49-
if (mw->qp) {
50-
struct rxe_qp *qp = mw->qp;
51-
52-
mw->qp = NULL;
53-
rxe_put(qp);
54-
}
55-
56-
mw->access = 0;
57-
mw->addr = 0;
58-
mw->length = 0;
59-
mw->state = RXE_MW_STATE_INVALID;
60-
}
61-
6239
int rxe_dealloc_mw(struct ib_mw *ibmw)
6340
{
6441
struct rxe_mw *mw = to_rmw(ibmw);
65-
struct rxe_pd *pd = to_rpd(ibmw->pd);
66-
67-
spin_lock_bh(&mw->lock);
68-
rxe_do_dealloc_mw(mw);
69-
spin_unlock_bh(&mw->lock);
7042

7143
rxe_put(mw);
72-
rxe_put(pd);
7344

7445
return 0;
7546
}
@@ -336,3 +307,31 @@ struct rxe_mw *rxe_lookup_mw(struct rxe_qp *qp, int access, u32 rkey)
336307

337308
return mw;
338309
}
310+
311+
void rxe_mw_cleanup(struct rxe_pool_elem *elem)
312+
{
313+
struct rxe_mw *mw = container_of(elem, typeof(*mw), elem);
314+
struct rxe_pd *pd = to_rpd(mw->ibmw.pd);
315+
316+
rxe_put(pd);
317+
318+
if (mw->mr) {
319+
struct rxe_mr *mr = mw->mr;
320+
321+
mw->mr = NULL;
322+
atomic_dec(&mr->num_mw);
323+
rxe_put(mr);
324+
}
325+
326+
if (mw->qp) {
327+
struct rxe_qp *qp = mw->qp;
328+
329+
mw->qp = NULL;
330+
rxe_put(qp);
331+
}
332+
333+
mw->access = 0;
334+
mw->addr = 0;
335+
mw->length = 0;
336+
mw->state = RXE_MW_STATE_INVALID;
337+
}

drivers/infiniband/sw/rxe/rxe_pool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ static const struct rxe_type_info {
8181
.name = "mw",
8282
.size = sizeof(struct rxe_mw),
8383
.elem_offset = offsetof(struct rxe_mw, elem),
84+
.cleanup = rxe_mw_cleanup,
8485
.min_index = RXE_MIN_MW_INDEX,
8586
.max_index = RXE_MAX_MW_INDEX,
8687
.max_elem = RXE_MAX_MW_INDEX - RXE_MIN_MW_INDEX + 1,

0 commit comments

Comments
 (0)