libhns: Fix CQ clean when CQ record doorbell enabled
[ Upstream commit 61d4e59f58de0ee75a335b0be7175a56c620c83d ]
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>
Signed-off-by: Nicolas Morey <nmorey@suse.com>
diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c
index 208327c..2d8d631 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 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,
@@ -748,12 +753,8 @@
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);
@@ -1848,10 +1849,7 @@
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;
}
@@ -1861,11 +1859,7 @@
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);
}