Skip to content

Commit b2a4167

Browse files
rpearsonhpe-designjgunthorpe
authored andcommitted
RDMA/rxe: Add rxe_srq_cleanup()
Move cleanup code from rxe_destroy_srq() to rxe_srq_cleanup() which is called after all references are dropped to allow code depending on the srq object to complete. Link: https://lore.kernel.org/r/20220421014042.26985-3-rpearsonhpe@gmail.com Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 0b1fbfb commit b2a4167

4 files changed

Lines changed: 25 additions & 22 deletions

File tree

drivers/infiniband/sw/rxe/rxe_loc.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited);
3737

3838
void rxe_cq_disable(struct rxe_cq *cq);
3939

40-
void rxe_cq_cleanup(struct rxe_pool_elem *arg);
40+
void rxe_cq_cleanup(struct rxe_pool_elem *elem);
4141

4242
/* rxe_mcast.c */
4343
struct rxe_mcg *rxe_lookup_mcg(struct rxe_dev *rxe, union ib_gid *mgid);
@@ -81,15 +81,15 @@ int rxe_invalidate_mr(struct rxe_qp *qp, u32 rkey);
8181
int rxe_reg_fast_mr(struct rxe_qp *qp, struct rxe_send_wqe *wqe);
8282
int rxe_mr_set_page(struct ib_mr *ibmr, u64 addr);
8383
int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
84-
void rxe_mr_cleanup(struct rxe_pool_elem *arg);
84+
void rxe_mr_cleanup(struct rxe_pool_elem *elem);
8585

8686
/* rxe_mw.c */
8787
int rxe_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata);
8888
int rxe_dealloc_mw(struct ib_mw *ibmw);
8989
int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe);
9090
int rxe_invalidate_mw(struct rxe_qp *qp, u32 rkey);
9191
struct rxe_mw *rxe_lookup_mw(struct rxe_qp *qp, int access, u32 rkey);
92-
void rxe_mw_cleanup(struct rxe_pool_elem *arg);
92+
void rxe_mw_cleanup(struct rxe_pool_elem *elem);
9393

9494
/* rxe_net.c */
9595
struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av,
@@ -168,6 +168,7 @@ int rxe_srq_chk_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
168168
int rxe_srq_from_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
169169
struct ib_srq_attr *attr, enum ib_srq_attr_mask mask,
170170
struct rxe_modify_srq_cmd *ucmd, struct ib_udata *udata);
171+
void rxe_srq_cleanup(struct rxe_pool_elem *elem);
171172

172173
void rxe_dealloc(struct ib_device *ib_dev);
173174

drivers/infiniband/sw/rxe/rxe_pool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static const struct rxe_type_info {
4545
.name = "srq",
4646
.size = sizeof(struct rxe_srq),
4747
.elem_offset = offsetof(struct rxe_srq, elem),
48+
.cleanup = rxe_srq_cleanup,
4849
.min_index = RXE_MIN_SRQ_INDEX,
4950
.max_index = RXE_MAX_SRQ_INDEX,
5051
.max_elem = RXE_MAX_SRQ_INDEX - RXE_MIN_SRQ_INDEX + 1,

drivers/infiniband/sw/rxe/rxe_srq.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,14 @@ int rxe_srq_from_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
174174
srq->rq.queue = NULL;
175175
return err;
176176
}
177+
178+
void rxe_srq_cleanup(struct rxe_pool_elem *elem)
179+
{
180+
struct rxe_srq *srq = container_of(elem, typeof(*srq), elem);
181+
182+
if (srq->pd)
183+
rxe_put(srq->pd);
184+
185+
if (srq->rq.queue)
186+
rxe_queue_cleanup(srq->rq.queue);
187+
}

drivers/infiniband/sw/rxe/rxe_verbs.c

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -286,36 +286,34 @@ static int rxe_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *init,
286286
struct rxe_srq *srq = to_rsrq(ibsrq);
287287
struct rxe_create_srq_resp __user *uresp = NULL;
288288

289-
if (init->srq_type != IB_SRQT_BASIC)
290-
return -EOPNOTSUPP;
291-
292289
if (udata) {
293290
if (udata->outlen < sizeof(*uresp))
294291
return -EINVAL;
295292
uresp = udata->outbuf;
296293
}
297294

295+
if (init->srq_type != IB_SRQT_BASIC)
296+
return -EOPNOTSUPP;
297+
298298
err = rxe_srq_chk_init(rxe, init);
299299
if (err)
300-
goto err1;
300+
return err;
301301

302302
err = rxe_add_to_pool(&rxe->srq_pool, srq);
303303
if (err)
304-
goto err1;
304+
return err;
305305

306306
rxe_get(pd);
307307
srq->pd = pd;
308308

309309
err = rxe_srq_from_init(rxe, srq, init, udata, uresp);
310310
if (err)
311-
goto err2;
311+
goto err_put;
312312

313313
return 0;
314314

315-
err2:
316-
rxe_put(pd);
315+
err_put:
317316
rxe_put(srq);
318-
err1:
319317
return err;
320318
}
321319

@@ -339,16 +337,12 @@ static int rxe_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
339337

340338
err = rxe_srq_chk_attr(rxe, srq, attr, mask);
341339
if (err)
342-
goto err1;
340+
return err;
343341

344342
err = rxe_srq_from_attr(rxe, srq, attr, mask, &ucmd, udata);
345343
if (err)
346-
goto err1;
347-
344+
return err;
348345
return 0;
349-
350-
err1:
351-
return err;
352346
}
353347

354348
static int rxe_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr)
@@ -368,10 +362,6 @@ static int rxe_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
368362
{
369363
struct rxe_srq *srq = to_rsrq(ibsrq);
370364

371-
if (srq->rq.queue)
372-
rxe_queue_cleanup(srq->rq.queue);
373-
374-
rxe_put(srq->pd);
375365
rxe_put(srq);
376366
return 0;
377367
}

0 commit comments

Comments
 (0)