From: Lianfa Weng <wenglianfa@huawei.com> 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: 3bb4f045752e ("libhns: Support cq record doorbell") Signed-off-by: Lianfa Weng <wenglianfa@huawei.com> Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com> --- providers/hns/hns_roce_u_hw_v2.c | 36 +++++++++++++------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c index 932d778e3..cb8942008 100644 --- a/providers/hns/hns_roce_u_hw_v2.c +++ b/providers/hns/hns_roce_u_hw_v2.c @@ -321,14 +321,19 @@ static void hns_roce_write_dwqe(struct hns_roce_qp *qp, void *wqe) static void update_cq_db(struct hns_roce_context *ctx, struct hns_roce_cq *cq) { - struct hns_roce_db cq_db = {}; + if (cq->flags & HNS_ROCE_CQ_FLAG_RECORD_DB) { + *cq->db = cq->cons_index & RECORD_DB_CI_MASK; + } else { + struct hns_roce_db cq_db = {}; - hr_reg_write(&cq_db, DB_TAG, cq->cqn); - hr_reg_write(&cq_db, DB_CMD, HNS_ROCE_V2_CQ_DB_PTR); - hr_reg_write(&cq_db, DB_CQ_CI, cq->cons_index); - hr_reg_write(&cq_db, DB_CQ_CMD_SN, 1); + hr_reg_write(&cq_db, DB_TAG, cq->cqn); + hr_reg_write(&cq_db, DB_CMD, HNS_ROCE_V2_CQ_DB_PTR); + hr_reg_write(&cq_db, DB_CQ_CI, cq->cons_index); + hr_reg_write(&cq_db, DB_CQ_CMD_SN, 1); - hns_roce_write64(ctx->uar + ROCEE_VF_DB_CFG0_OFFSET, (__le32 *)&cq_db); + hns_roce_write64(ctx->uar + ROCEE_VF_DB_CFG0_OFFSET, + (__le32 *)&cq_db); + } } 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, break; } - if (npolled || err == V2_CQ_POLL_ERR) { - if (cq->flags & HNS_ROCE_CQ_FLAG_RECORD_DB) - *cq->db = cq->cons_index & RECORD_DB_CI_MASK; - else - update_cq_db(ctx, cq); - } + if (npolled || err == V2_CQ_POLL_ERR) + update_cq_db(ctx, cq); hns_roce_spin_unlock(&cq->hr_lock); @@ -1926,10 +1927,7 @@ static int wc_next_poll_cq(struct ibv_cq_ex *current) if (err != V2_CQ_OK) return err; - if (cq->flags & HNS_ROCE_CQ_FLAG_RECORD_DB) - *cq->db = cq->cons_index & RECORD_DB_CI_MASK; - else - update_cq_db(ctx, cq); + update_cq_db(ctx, cq); return 0; } @@ -1939,11 +1937,7 @@ static void wc_end_poll_cq(struct ibv_cq_ex *current) struct hns_roce_cq *cq = to_hr_cq(ibv_cq_ex_to_cq(current)); struct hns_roce_context *ctx = to_hr_ctx(current->context); - if (cq->flags & HNS_ROCE_CQ_FLAG_RECORD_DB) - *cq->db = cq->cons_index & RECORD_DB_CI_MASK; - else - update_cq_db(ctx, cq); - + update_cq_db(ctx, cq); hns_roce_spin_unlock(&cq->hr_lock); } -- 2.33.0