From: wanglin wanglin137@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
----------------------------------
This patch modify roce dfx code by review advice
Reviewed-by: taojihua taojihua4@huawei.com Reviewed-by: huchunzhi huchunzhi@huawei.com Signed-off-by: wanglin wanglin137@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../hw/hns/roce-customer/rdfx_hw_v2.c | 49 ---------- .../hw/hns/roce-customer/rdfx_main.c | 2 + .../hw/hns/roce-customer/rdfx_sysfs.c | 96 +------------------ 3 files changed, 4 insertions(+), 143 deletions(-)
diff --git a/drivers/infiniband/hw/hns/roce-customer/rdfx_hw_v2.c b/drivers/infiniband/hw/hns/roce-customer/rdfx_hw_v2.c index c0ab3d2ba636..aed4a1337edb 100644 --- a/drivers/infiniband/hw/hns/roce-customer/rdfx_hw_v2.c +++ b/drivers/infiniband/hw/hns/roce-customer/rdfx_hw_v2.c @@ -50,51 +50,6 @@ static void *rdfx_v2_get_dfx(struct ib_device *ib_dev) return hr_dev->dfx_priv; }
-static int rdfx_rdreg(const char *p_buf, struct rdfx_info *rdfx) -{ - struct hns_roce_dev *hr_dev = (struct hns_roce_dev *)rdfx->priv; - unsigned long long a_val[SYSFS_MAX_PARA] = {0}; - char *buf = (char *)p_buf; - u32 offset; - int ret; - u32 param_num; - - ret = check_input(buf, a_val, 2, 1, ¶m_num); - if (ret) - return ret; - - offset = a_val[0]; - - pr_info("Reg(0x%08x): 0x%08x\n", - offset, roce_read(hr_dev, offset)); - - return 0; -} - -static int rdfx_wrreg(const char *p_buf, struct rdfx_info *rdfx) -{ - struct hns_roce_dev *hr_dev = (struct hns_roce_dev *)rdfx->priv; - unsigned long long a_val[SYSFS_MAX_PARA] = {0}; - char *buf = (char *)p_buf; - u32 offset; - u32 value; - int ret; - u32 param_num; - - ret = check_input(buf, a_val, 3, 2, ¶m_num); - if (ret) - return ret; - - offset = a_val[0]; - value = a_val[1]; - - pr_info("Write reg: offset - 0x%08x, value - 0x%08x\n", - offset, value); - roce_write(hr_dev, offset, value); - - return 0; -} - static int rdfx_v2_ooo_show(struct rdfx_info *rdfx) { pr_info("************** OOO INFO ***************\n"); @@ -922,8 +877,6 @@ rdfx_hw_file_attr_def(aeqc, NULL, rdfx_v2_aeqc_store); rdfx_hw_file_attr_def(qpc, NULL, rdfx_v2_qpc_store); rdfx_hw_file_attr_def(cqc, NULL, rdfx_v2_cqc_store); rdfx_hw_file_attr_def(mpt, NULL, rdfx_v2_mpt_store); -rdfx_hw_file_attr_def(rdreg, NULL, rdfx_rdreg); -rdfx_hw_file_attr_def(wrreg, NULL, rdfx_wrreg); rdfx_hw_file_attr_def(srqc, NULL, rdfx_v2_srqc_store);
static struct attribute *rdfx_hw_v2_attrs_list[] = { @@ -936,8 +889,6 @@ static struct attribute *rdfx_hw_v2_attrs_list[] = { HW_ATTRS_LIST_MEMBER(qpc), HW_ATTRS_LIST_MEMBER(cqc), HW_ATTRS_LIST_MEMBER(mpt), - HW_ATTRS_LIST_MEMBER(rdreg), - HW_ATTRS_LIST_MEMBER(wrreg), HW_ATTRS_LIST_MEMBER(srqc), NULL }; diff --git a/drivers/infiniband/hw/hns/roce-customer/rdfx_main.c b/drivers/infiniband/hw/hns/roce-customer/rdfx_main.c index 445ac25e9920..a28bc0fb0bf0 100644 --- a/drivers/infiniband/hw/hns/roce-customer/rdfx_main.c +++ b/drivers/infiniband/hw/hns/roce-customer/rdfx_main.c @@ -76,6 +76,8 @@ int parg_getopt(char *input, char *optstring, char *parg) p++; cnt++; } + if (cnt >= DEF_OPT_STR_LEN) + return -EINVAL; *p = '\0'; p -= cnt; strcpy(parg, p); diff --git a/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c b/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c index 2a6a51a8c2fb..768e4f2c2e21 100644 --- a/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c +++ b/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c @@ -127,14 +127,6 @@ static int show_qp_detail(struct rdfx_qp_info *rdfx_qp) atomic_read(&rdfx_qp->sq.db_cnt), atomic_read(&rdfx_qp->sq.inline_cnt)); pr_info("\n"); - pr_info("SQ_head SQ_head_addr\n"); - pr_info(" 0x%x 0x%llx\n", - atomic_read(&rdfx_qp->sq.head), rdfx_qp->sq.head_addr); - pr_info("\n"); - pr_info("SQ_tail SQ_tail_addr\n"); - pr_info("0x%x 0x%llx\n", - atomic_read(&rdfx_qp->sq.tail), rdfx_qp->sq.tail_addr); - pr_info("\n"); pr_info("***************** RQ INFO *****************\n"); pr_info("rq_wqe_cnt bd_cnt inline_cnt\n"); pr_info(" 0x%x 0x%x 0x%x\n", @@ -142,14 +134,6 @@ static int show_qp_detail(struct rdfx_qp_info *rdfx_qp) atomic_read(&rdfx_qp->rq.db_cnt), atomic_read(&rdfx_qp->rq.inline_cnt)); pr_info("\n"); - pr_info("RQ_head RQ_head_addr\n"); - pr_info(" 0x%x 0x%llx\n", - atomic_read(&rdfx_qp->rq.head), rdfx_qp->rq.head_addr); - pr_info("\n"); - pr_info("RQ_tail RQ_tail_addr\n"); - pr_info(" 0x%x 0x%llx\n", - atomic_read(&rdfx_qp->rq.head), rdfx_qp->rq.tail_addr); - pr_info("\n"); pr_info("***************** QP ATTR *****************\n"); pr_info("state : 0x%x\n", atomic_read(&rdfx_qp->attr.state)); @@ -215,7 +199,7 @@ static int show_cqe(struct rdfx_cq_info *rdfx_cq, int cqe_index) u32 *cqe;
rdfx_cq->cqe_size = CQE_SIZE; - cqe_index = cqe_index & (rdfx_cq->cq_depth); + cqe_index = cqe_index & (rdfx_cq->cq_depth - 1); cqe = rdfx_buf_offset(rdfx_cq->buf, (cqe_index * rdfx_cq->cqe_size)); if (cqe) pr_info("%08x %08x %08x %08x %08x %08x %08x %08x\n", @@ -227,37 +211,6 @@ static int show_cqe(struct rdfx_cq_info *rdfx_cq, int cqe_index) return 0; }
-#ifdef CONFIG_INFINIBAND_HNS_DFX_ENHANCE -static int rdfx_enhance_qp_delete(u32 qpn, struct rdfx_info *rdfx) -{ - struct rdfx_qp_info *rdfx_qp; - struct list_head *pos; - struct list_head *q; - unsigned long flags; - u32 is_existed = 0; - - spin_lock_irqsave(&rdfx->qp.qp_lock, flags); - list_for_each_safe(pos, q, &(rdfx->qp.list)) { - rdfx_qp = list_entry(pos, struct rdfx_qp_info, list); - if (qpn == rdfx_qp->qpn) { - is_existed = 1; - list_del(pos); - break; - } - } - if (!is_existed) { - spin_unlock_irqrestore(&rdfx->qp.qp_lock, flags); - pr_err("QPN %u is not in dfx list!\n", qpn); - return -EINVAL; - } - spin_unlock_irqrestore(&rdfx->qp.qp_lock, flags); - kref_put(&(rdfx_qp->cnt), qp_release); - pr_info("delete qpn:0x%lx\n", rdfx_qp->qpn); - - return 0; -} -#endif - static inline int rdfx_convert_str(char *str, u32 *val) { long long convert_val; @@ -329,13 +282,7 @@ static int rdfx_qp_store(const char *p_buf) show_valid_qpn(&(rdfx->qp.list)); return 0; } -#ifdef CONFIG_INFINIBAND_HNS_DFX_ENHANCE - if (!parg_getopt(buf, "r:", str)) { - if (rdfx_convert_str(str, &qpn)) - return -EINVAL; - return rdfx_enhance_qp_delete(qpn, rdfx); - } -#endif + parg_getopt(buf, "v:", str); if (rdfx_convert_str(str, &qpn)) return -EINVAL; @@ -450,37 +397,6 @@ static void show_valid_cqn(struct list_head *head) pr_info("\n"); }
-#ifdef CONFIG_INFINIBAND_HNS_DFX_ENHANCE -static int rdfx_enhance_cq_delete(u32 cqn, struct rdfx_info *rdfx) -{ - struct rdfx_cq_info *rdfx_cq = NULL; - struct list_head *pos; - struct list_head *q; - unsigned long flags; - u32 is_existed = 0; - - spin_lock_irqsave(&rdfx->cq.cq_lock, flags); - list_for_each_safe(pos, q, &(rdfx->cq.list)) { - rdfx_cq = list_entry(pos, struct rdfx_cq_info, list); - if (cqn == rdfx_cq->cqn) { - is_existed = 1; - list_del(pos); - break; - } - } - if (!is_existed) { - pr_err("CQN %u is not in dfx list!\n", cqn); - spin_unlock_irqrestore(&rdfx->cq.cq_lock, flags); - return -EINVAL; - } - spin_unlock_irqrestore(&rdfx->cq.cq_lock, flags); - kref_put(&(rdfx_cq->cnt), cq_release); - pr_err("delete cqn:0x%lx\n", rdfx_cq->cqn); - - return 0; -} -#endif - static inline int rdfx_show_cq_detail(u32 cqn, struct rdfx_info *rdfx) { struct rdfx_cq_info *rdfx_cq = NULL; @@ -524,14 +440,6 @@ static int rdfx_cq_store(const char *p_buf) return 0; }
-#ifdef CONFIG_INFINIBAND_HNS_DFX_ENHANCE - if (!parg_getopt(buf, "r:", str)) { - if (rdfx_convert_str(str, &cqn)) - return -EINVAL; - - return rdfx_enhance_cq_delete(cqn, rdfx); - } -#endif parg_getopt(buf, "v:", str); if (rdfx_convert_str(str, &cqn)) return -EINVAL;