From: Ran Zhou zhouran10@h-partners.com
This series of patches focus on some minor bugfix.
Chengchang Tang (3): libhns: Fix possible overflow in cq clean libhns: Fix uninitialized qp attr when flush cqe libhns: Fix unnecessary dca memory detach
Luoyouming (1): libhns: Add input parameter check for hnsdv_query_device()
Ran Zhou (1): libhns: Corrects several issues with output format and variable types.
providers/hns/hns_roce_u.c | 2 +- providers/hns/hns_roce_u_hw_v2.c | 45 ++++++++++++++++---------------- providers/hns/hns_roce_u_verbs.c | 5 ++-- 3 files changed, 27 insertions(+), 25 deletions(-)
-- 2.30.0
From: Ran Zhou zhouran10@partner.com
driver inclusion category: bugfix bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/I8J2S3?from=project-issue
-------------------------------------------------------------------------- 1.Unify the types of two variables to avoid infinite loop.
2.Standardization the output control character.
Signed-off-by: Luoyouming luoyouming@huawei.com --- providers/hns/hns_roce_u.c | 2 +- providers/hns/hns_roce_u_hw_v2.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/providers/hns/hns_roce_u.c b/providers/hns/hns_roce_u.c index 084385b..f30486f 100644 --- a/providers/hns/hns_roce_u.c +++ b/providers/hns/hns_roce_u.c @@ -179,7 +179,7 @@ static void set_dca_pool_param(struct hns_roce_context *ctx, dca_ctx->min_size = HNS_DCA_MAX_MEM_SIZE;
verbs_debug(&ctx->ibv_ctx, - "Support DCA, unit %d, max %ld, min %ld Bytes.\n", + "Support DCA, unit %u, max %lu, min %lu Bytes.\n", dca_ctx->unit_size, dca_ctx->max_size, dca_ctx->min_size); }
diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c index 495fbcb..754f918 100644 --- a/providers/hns/hns_roce_u_hw_v2.c +++ b/providers/hns/hns_roce_u_hw_v2.c @@ -2680,8 +2680,8 @@ static void set_inline_data_list_rc(struct hns_roce_qp *qp, { unsigned int msg_len = qp->sge_info.total_len; void *dseg; + size_t i; int ret; - int i;
hr_reg_enable(wqe, RCWQE_INLINE);
@@ -2741,7 +2741,7 @@ static void wr_set_inline_data_list_rc(struct ibv_qp_ex *ibv_qp, size_t num_buf, { struct hns_roce_qp *qp = to_hr_qp(&ibv_qp->qp_base); struct hns_roce_rc_sq_wqe *wqe = qp->cur_wqe; - int i; + size_t i;
if (!wqe) return; @@ -2872,7 +2872,7 @@ static void wr_set_sge_list_ud(struct ibv_qp_ex *ibv_qp, size_t num_sge, }
hr_reg_write(wqe, UDWQE_MSG_START_SGE_IDX, sge_idx & mask); - for (int i = 0; i < num_sge; i++) { + for (size_t i = 0; i < num_sge; i++) { if (!sg_list[i].length) continue;
@@ -2899,8 +2899,8 @@ static void set_inline_data_list_ud(struct hns_roce_qp *qp, uint8_t data[HNS_ROCE_MAX_UD_INL_INN_SZ] = {}; unsigned int msg_len = qp->sge_info.total_len; void *tmp; + size_t i; int ret; - int i;
if (!check_inl_data_len(qp, msg_len)) { qp->err = EINVAL; @@ -2962,7 +2962,7 @@ static void wr_set_inline_data_list_ud(struct ibv_qp_ex *ibv_qp, size_t num_buf, { struct hns_roce_qp *qp = to_hr_qp(&ibv_qp->qp_base); struct hns_roce_ud_sq_wqe *wqe = qp->cur_wqe; - int i; + size_t i;
if (!wqe) return; -- 2.30.0
From: Luoyouming luoyouming@huawei.com
driver inclusion category: cleanup bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/I8J2W9?from=project-issue
--------------------------------------------------------------------------
Add null pointer check for pointer parameter.
Signed-off-by: Luoyouming luoyouming@huawei.com --- providers/hns/hns_roce_u_verbs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c index c906632..e597e93 100644 --- a/providers/hns/hns_roce_u_verbs.c +++ b/providers/hns/hns_roce_u_verbs.c @@ -126,15 +126,16 @@ int hnsdv_query_device(struct ibv_context *context, struct hnsdv_context *attrs_out) { struct hns_roce_context *ctx = context ? to_hr_ctx(context) : NULL; - struct hns_roce_device *hr_dev = to_hr_dev(context->device); + struct hns_roce_device *hr_dev;
if (!ctx || !attrs_out) return EINVAL;
- if (!hr_dev) { + if (!context->device && !is_hns_dev(context->device)) { verbs_err(verbs_get_ctx(context), "not a HNS RoCE device!\n"); return EOPNOTSUPP; } + hr_dev = to_hr_dev(context->device);
memset(attrs_out, 0, sizeof(*attrs_out));
-- 2.30.0
driver inclusion category: bugfix bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/I8J2XP?from=project-issue
--------------------------------------------------------------------------
The ci/pi of hns roce cq allows data to be flipped. but in __hns_roce_v2_cq_clean(), this flip may lead to an wrong number of loops.
This patch fixes it by extending the data type to avoid data flipping.
Signed-off-by: Chengchang Tang tangchengchang@huawei.com --- providers/hns/hns_roce_u_hw_v2.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c index 754f918..9ac06b5 100644 --- a/providers/hns/hns_roce_u_hw_v2.c +++ b/providers/hns/hns_roce_u_hw_v2.c @@ -1847,20 +1847,21 @@ out: static void __hns_roce_v2_cq_clean(struct hns_roce_cq *cq, uint32_t qpn, struct hns_roce_srq *srq) { - int nfreed = 0; - bool is_recv_cqe; - uint8_t owner_bit; - uint16_t wqe_index; - uint32_t prod_index; - struct hns_roce_v2_cqe *cqe, *dest; - struct hns_roce_context *ctx = to_hr_ctx(cq->verbs_cq.cq.context); - - for (prod_index = cq->cons_index; get_sw_cqe_v2(cq, prod_index); - ++prod_index) - if (prod_index > cq->cons_index + cq->verbs_cq.cq.cqe) + struct hns_roce_context *ctx = to_hr_ctx(cq->verbs_cq.cq.context); + uint64_t cons_index = cq->cons_index; + uint64_t prod_index = cq->cons_index; + struct hns_roce_v2_cqe *cqe, *dest; + uint16_t wqe_index; + uint8_t owner_bit; + bool is_recv_cqe; + int nfreed = 0; + + for (; get_sw_cqe_v2(cq, prod_index); ++prod_index) + if (prod_index > cons_index + cq->verbs_cq.cq.cqe) break;
- while ((int) --prod_index - (int) cq->cons_index >= 0) { + while (prod_index - cons_index > 0) { + prod_index--; cqe = get_cqe_v2(cq, prod_index & cq->verbs_cq.cq.cqe); if (hr_reg_read(cqe, CQE_LCL_QPN) == qpn) { is_recv_cqe = hr_reg_read(cqe, CQE_S_R); -- 2.30.0
driver inclusion category: bugfix bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/I8J2XW?from=project-issue
--------------------------------------------------------------------------
When flushing cqe, the state of qp needs to be modified. The incoming qp attr is not initialized, which may lead to undefined behavior.
Signed-off-by: Chengchang Tang tangchengchang@huawei.com --- providers/hns/hns_roce_u_hw_v2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c index 9ac06b5..fc938de 100644 --- a/providers/hns/hns_roce_u_hw_v2.c +++ b/providers/hns/hns_roce_u_hw_v2.c @@ -405,7 +405,7 @@ static int hns_roce_u_v2_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
static int hns_roce_flush_cqe(struct hns_roce_qp *hr_qp, uint8_t status) { - struct ibv_qp_attr attr; + struct ibv_qp_attr attr = {}; int attr_mask;
if (status != HNS_ROCE_V2_CQE_WR_FLUSH_ERR) { @@ -1614,8 +1614,8 @@ int hns_roce_u_v2_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr, struct hns_roce_qp *qp = to_hr_qp(ibvqp); struct hns_roce_sge_info sge_info = {}; struct hns_roce_rc_sq_wqe *wqe; + struct ibv_qp_attr attr = {}; unsigned int wqe_idx, nreq; - struct ibv_qp_attr attr; int ret;
ret = check_qp_send(qp, ctx); @@ -1788,7 +1788,7 @@ static int hns_roce_u_v2_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr, struct hns_roce_context *ctx = to_hr_ctx(ibvqp->context); struct hns_roce_qp *qp = to_hr_qp(ibvqp); unsigned int wqe_idx, nreq, max_sge; - struct ibv_qp_attr attr; + struct ibv_qp_attr attr = {}; int ret;
ret = check_qp_recv(qp, ctx); @@ -3022,7 +3022,7 @@ static int wr_complete(struct ibv_qp_ex *ibv_qp) struct hns_roce_context *ctx = to_hr_ctx(ibv_qp->qp_base.context); struct hns_roce_qp *qp = to_hr_qp(&ibv_qp->qp_base); unsigned int nreq = qp->sq.head - qp->rb_sq_head; - struct ibv_qp_attr attr; + struct ibv_qp_attr attr = {}; int err = qp->err;
if (err) { -- 2.30.0
driver inclusion category: bugfix bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/I8J2Y5?from=project-issue
--------------------------------------------------------------------------
If sq is not enabled, it should not detach dca mem. Moreover, under the current code logic, if detach dca mem, its sq index will be a random value because it is not initialized.
Signed-off-by: Chengchang Tang tangchengchang@huawei.com --- providers/hns/hns_roce_u_hw_v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c index fc938de..2fb738d 100644 --- a/providers/hns/hns_roce_u_hw_v2.c +++ b/providers/hns/hns_roce_u_hw_v2.c @@ -696,7 +696,7 @@ static void dca_detach_qp_buf(struct hns_roce_context *ctx, hns_roce_spin_unlock(&qp->rq.hr_lock); hns_roce_spin_unlock(&qp->sq.hr_lock);
- if (is_empty) + if (is_empty && qp->sq.wqe_cnt > 0) hns_roce_detach_dca_mem(ctx, qp->verbs_qp.qp.handle, &attr); }
-- 2.30.0