Skip to content

Commit 3f02277

Browse files
committed
efa: Fix CQ poll after QP destroy
After a QP has been destroyed there might still be pending CQEs. As an optimization for some cases, poll functions ignore CQs that are not in use by any QP, preventing completions from being read after destruction of the last QP that uses this CQ. Remove this optimization. Reviewed-by: Firas Jahjah <[email protected]> Signed-off-by: Michael Margolin <[email protected]>
1 parent 6697a72 commit 3f02277

File tree

1 file changed

+0
-29
lines changed

1 file changed

+0
-29
lines changed

providers/efa/verbs.c

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -769,9 +769,6 @@ static inline int efa_poll_sub_cqs(struct efa_cq *cq, struct ibv_wc *wc,
769769
sub_cq = &cq->sub_cq_arr[cq->next_poll_idx++];
770770
cq->next_poll_idx %= num_sub_cqs;
771771

772-
if (!sub_cq->ref_cnt)
773-
continue;
774-
775772
err = efa_poll_sub_cq(cq, sub_cq, &qp, wc, extended);
776773
if (err != ENOENT) {
777774
cq->cc++;
@@ -896,7 +893,6 @@ static void efa_sub_cq_initialize(struct efa_sub_cq *sub_cq, uint8_t *buf,
896893
sub_cq->buf = buf;
897894
sub_cq->qmask = sub_cq_size - 1;
898895
sub_cq->cqe_size = cqe_size;
899-
sub_cq->ref_cnt = 0;
900896
}
901897

902898
static struct ibv_cq_ex *create_cq(struct ibv_context *ibvctx,
@@ -1084,16 +1080,6 @@ int efa_destroy_cq(struct ibv_cq *ibvcq)
10841080
return 0;
10851081
}
10861082

1087-
static void efa_cq_inc_ref_cnt(struct efa_cq *cq, uint8_t sub_cq_idx)
1088-
{
1089-
cq->sub_cq_arr[sub_cq_idx].ref_cnt++;
1090-
}
1091-
1092-
static void efa_cq_dec_ref_cnt(struct efa_cq *cq, uint8_t sub_cq_idx)
1093-
{
1094-
cq->sub_cq_arr[sub_cq_idx].ref_cnt--;
1095-
}
1096-
10971083
static void efa_wq_terminate(struct efa_wq *wq, int pgsz)
10981084
{
10991085
void *db_aligned;
@@ -1476,8 +1462,6 @@ static struct ibv_qp *create_qp(struct ibv_context *ibvctx,
14761462
struct efa_dev *dev = to_efa_dev(ibvctx->device);
14771463
struct efa_create_qp_resp resp = {};
14781464
struct efa_create_qp req = {};
1479-
struct efa_cq *send_cq;
1480-
struct efa_cq *recv_cq;
14811465
struct ibv_qp *ibvqp;
14821466
struct efa_qp *qp;
14831467
int err;
@@ -1535,16 +1519,6 @@ static struct ibv_qp *create_qp(struct ibv_context *ibvctx,
15351519
ctx->qp_table[ibvqp->qp_num & ctx->qp_table_sz_m1] = qp;
15361520
pthread_spin_unlock(&ctx->qp_table_lock);
15371521

1538-
send_cq = to_efa_cq(attr->send_cq);
1539-
pthread_spin_lock(&send_cq->lock);
1540-
efa_cq_inc_ref_cnt(send_cq, resp.send_sub_cq_idx);
1541-
pthread_spin_unlock(&send_cq->lock);
1542-
1543-
recv_cq = to_efa_cq(attr->recv_cq);
1544-
pthread_spin_lock(&recv_cq->lock);
1545-
efa_cq_inc_ref_cnt(recv_cq, resp.recv_sub_cq_idx);
1546-
pthread_spin_unlock(&recv_cq->lock);
1547-
15481522
if (attr->comp_mask & IBV_QP_INIT_ATTR_SEND_OPS_FLAGS) {
15491523
efa_qp_fill_wr_pfns(&qp->verbs_qp.qp_ex, attr);
15501524
qp->verbs_qp.comp_mask |= VERBS_QP_EX;
@@ -1725,9 +1699,6 @@ int efa_destroy_qp(struct ibv_qp *ibvqp)
17251699
pthread_spin_lock(&ctx->qp_table_lock);
17261700
efa_lock_cqs(ibvqp);
17271701

1728-
efa_cq_dec_ref_cnt(to_efa_cq(ibvqp->send_cq), qp->sq.wq.sub_cq_idx);
1729-
efa_cq_dec_ref_cnt(to_efa_cq(ibvqp->recv_cq), qp->rq.wq.sub_cq_idx);
1730-
17311702
ctx->qp_table[ibvqp->qp_num & ctx->qp_table_sz_m1] = NULL;
17321703

17331704
efa_unlock_cqs(ibvqp);

0 commit comments

Comments
 (0)