Skip to content

Commit 4703b4f

Browse files
Bob Pearsonjgunthorpe
authored andcommitted
RDMA/rxe: Enforce IBA C11-17
Add a counter to keep track of the number of WQs connected to a CQ and return an error if destroy_cq() is called while the counter is non zero. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bob Pearson <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent cde3f5d commit 4703b4f

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

drivers/infiniband/sw/rxe/rxe_qp.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd,
322322
qp->scq = scq;
323323
qp->srq = srq;
324324

325+
atomic_inc(&rcq->num_wq);
326+
atomic_inc(&scq->num_wq);
327+
325328
rxe_qp_init_misc(rxe, qp, init);
326329

327330
err = rxe_qp_init_req(rxe, qp, init, udata, uresp);
@@ -341,6 +344,9 @@ int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd,
341344
rxe_queue_cleanup(qp->sq.queue);
342345
qp->sq.queue = NULL;
343346
err1:
347+
atomic_dec(&rcq->num_wq);
348+
atomic_dec(&scq->num_wq);
349+
344350
qp->pd = NULL;
345351
qp->rcq = NULL;
346352
qp->scq = NULL;
@@ -798,10 +804,14 @@ static void rxe_qp_do_cleanup(struct work_struct *work)
798804
if (qp->rq.queue)
799805
rxe_queue_cleanup(qp->rq.queue);
800806

807+
atomic_dec(&qp->scq->num_wq);
801808
if (qp->scq)
802809
rxe_put(qp->scq);
810+
811+
atomic_dec(&qp->rcq->num_wq);
803812
if (qp->rcq)
804813
rxe_put(qp->rcq);
814+
805815
if (qp->pd)
806816
rxe_put(qp->pd);
807817

drivers/infiniband/sw/rxe/rxe_verbs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,12 @@ static int rxe_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
795795
{
796796
struct rxe_cq *cq = to_rcq(ibcq);
797797

798+
/* See IBA C11-17: The CI shall return an error if this Verb is
799+
* invoked while a Work Queue is still associated with the CQ.
800+
*/
801+
if (atomic_read(&cq->num_wq))
802+
return -EINVAL;
803+
798804
rxe_cq_disable(cq);
799805

800806
rxe_put(cq);

drivers/infiniband/sw/rxe/rxe_verbs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct rxe_cq {
6767
bool is_dying;
6868
bool is_user;
6969
struct tasklet_struct comp_task;
70+
atomic_t num_wq;
7071
};
7172

7273
enum wqe_state {

0 commit comments

Comments
 (0)