When flush cqe, it needs to allocate sq db buffer for storing sq pi pointer and using when modifying qp to error state. It needs to free sq db buffer when destroying qp. These operations will be triggered, depending on whether or not there is sq. However, when sq sge number is zero, the sq maybe exist. Fixes: e1726e934574("libhns: Support flush cqe for hip08 in user space") Signed-off-by: Lijun Ou <oulijun@xxxxxxxxxx> --- providers/hns/hns_roce_u_hw_v2.c | 2 +- providers/hns/hns_roce_u_verbs.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c index d00bd42..7938b96 100644 --- a/providers/hns/hns_roce_u_hw_v2.c +++ b/providers/hns/hns_roce_u_hw_v2.c @@ -1141,7 +1141,7 @@ static int hns_roce_u_v2_destroy_qp(struct ibv_qp *ibqp) if (qp->rq.max_gs) hns_roce_free_db(to_hr_ctx(ibqp->context), qp->rdb, HNS_ROCE_QP_TYPE_DB); - if (qp->sq.max_gs) + if (qp->sq.wqe_cnt) hns_roce_free_db(to_hr_ctx(ibqp->context), qp->sdb, HNS_ROCE_QP_TYPE_DB); diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c index aa791e0..05c2a8e 100644 --- a/providers/hns/hns_roce_u_verbs.c +++ b/providers/hns/hns_roce_u_verbs.c @@ -845,7 +845,7 @@ struct ibv_qp *hns_roce_u_create_qp(struct ibv_pd *pd, } if ((to_hr_dev(pd->context->device)->hw_version != HNS_ROCE_HW_VER1) && - attr->cap.max_send_sge) { + attr->cap.max_send_wr) { qp->sdb = hns_roce_alloc_db(context, HNS_ROCE_QP_TYPE_DB); if (!qp->sdb) goto err_free; @@ -916,7 +916,7 @@ err_rq_db: err_sq_db: if ((to_hr_dev(pd->context->device)->hw_version != HNS_ROCE_HW_VER1) && - attr->cap.max_send_sge) + attr->cap.max_send_wr) hns_roce_free_db(context, qp->sdb, HNS_ROCE_QP_TYPE_DB); err_free: -- 2.8.1