Skip to content

Commit f2cff7f

Browse files
Lianfa Wengnmorey
authored andcommitted
libhns: Fix CQ clean when CQ record doorbell enabled
[ Upstream commit 61d4e59 ] The update of CQ record doorbell is missing in hns_roce_v2_cq_clean(). Handle both record doorbell and the HW doorbell in update_cq_db() to avoid any omissions. Fixes: 3bb4f04 ("libhns: Support cq record doorbell") Signed-off-by: Lianfa Weng <wenglianfa@huawei.com> Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com> Signed-off-by: Nicolas Morey <nmorey@suse.com>
1 parent e96dbbf commit f2cff7f

1 file changed

Lines changed: 15 additions & 21 deletions

File tree

providers/hns/hns_roce_u_hw_v2.c

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,19 @@ static void hns_roce_write_dwqe(struct hns_roce_qp *qp, void *wqe)
321321

322322
static void update_cq_db(struct hns_roce_context *ctx, struct hns_roce_cq *cq)
323323
{
324-
struct hns_roce_db cq_db = {};
324+
if (cq->flags & HNS_ROCE_CQ_FLAG_RECORD_DB) {
325+
*cq->db = cq->cons_index & RECORD_DB_CI_MASK;
326+
} else {
327+
struct hns_roce_db cq_db = {};
325328

326-
hr_reg_write(&cq_db, DB_TAG, cq->cqn);
327-
hr_reg_write(&cq_db, DB_CMD, HNS_ROCE_V2_CQ_DB_PTR);
328-
hr_reg_write(&cq_db, DB_CQ_CI, cq->cons_index);
329-
hr_reg_write(&cq_db, DB_CQ_CMD_SN, 1);
329+
hr_reg_write(&cq_db, DB_TAG, cq->cqn);
330+
hr_reg_write(&cq_db, DB_CMD, HNS_ROCE_V2_CQ_DB_PTR);
331+
hr_reg_write(&cq_db, DB_CQ_CI, cq->cons_index);
332+
hr_reg_write(&cq_db, DB_CQ_CMD_SN, 1);
330333

331-
hns_roce_write64(ctx->uar + ROCEE_VF_DB_CFG0_OFFSET, (__le32 *)&cq_db);
334+
hns_roce_write64(ctx->uar + ROCEE_VF_DB_CFG0_OFFSET,
335+
(__le32 *)&cq_db);
336+
}
332337
}
333338

334339
static struct hns_roce_qp *hns_roce_v2_find_qp(struct hns_roce_context *ctx,
@@ -839,12 +844,8 @@ static int hns_roce_u_v2_poll_cq(struct ibv_cq *ibvcq, int ne,
839844
break;
840845
}
841846

842-
if (npolled || err == V2_CQ_POLL_ERR) {
843-
if (cq->flags & HNS_ROCE_CQ_FLAG_RECORD_DB)
844-
*cq->db = cq->cons_index & RECORD_DB_CI_MASK;
845-
else
846-
update_cq_db(ctx, cq);
847-
}
847+
if (npolled || err == V2_CQ_POLL_ERR)
848+
update_cq_db(ctx, cq);
848849

849850
hns_roce_spin_unlock(&cq->hr_lock);
850851

@@ -1926,10 +1927,7 @@ static int wc_next_poll_cq(struct ibv_cq_ex *current)
19261927
if (err != V2_CQ_OK)
19271928
return err;
19281929

1929-
if (cq->flags & HNS_ROCE_CQ_FLAG_RECORD_DB)
1930-
*cq->db = cq->cons_index & RECORD_DB_CI_MASK;
1931-
else
1932-
update_cq_db(ctx, cq);
1930+
update_cq_db(ctx, cq);
19331931

19341932
return 0;
19351933
}
@@ -1939,11 +1937,7 @@ static void wc_end_poll_cq(struct ibv_cq_ex *current)
19391937
struct hns_roce_cq *cq = to_hr_cq(ibv_cq_ex_to_cq(current));
19401938
struct hns_roce_context *ctx = to_hr_ctx(current->context);
19411939

1942-
if (cq->flags & HNS_ROCE_CQ_FLAG_RECORD_DB)
1943-
*cq->db = cq->cons_index & RECORD_DB_CI_MASK;
1944-
else
1945-
update_cq_db(ctx, cq);
1946-
1940+
update_cq_db(ctx, cq);
19471941
hns_roce_spin_unlock(&cq->hr_lock);
19481942
}
19491943

0 commit comments

Comments
 (0)