From: Guofeng Yue yueguofeng@h-partners.com
A set of bugfixes for openeuler 22.03 SP4
Chengchang Tang (4): RDMA/hns: Fix cpu stuck by printings during reset RDMA/hns: Fix missing default values of scc parameters RDMA/hns: directly read the scc parameters in the driver instead of the firmware RDMA/hns: Fix deadlock when using DCA debugfs.
Junxian Huang (2): RDMA/hns: Fix missing validation check of DCA mem size RDMA/hns: Set NULL after mtr_node is freed
wenglianfa (3): RDMA/hns: Fix CPU stuck due to read polling during reset RDMA/hns: Fix fmt output error RDMA/hns: Fix missing list_del in hns_roce_hem
drivers/infiniband/hw/hns/hns_roce_cq.c | 7 ++- drivers/infiniband/hw/hns/hns_roce_dca.c | 5 ++ drivers/infiniband/hw/hns/hns_roce_debugfs.c | 12 ++-- drivers/infiniband/hw/hns/hns_roce_hem.c | 6 +- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 66 ++++++++++---------- drivers/infiniband/hw/hns/hns_roce_mr.c | 4 +- drivers/infiniband/hw/hns/hns_roce_qp.c | 3 + drivers/infiniband/hw/hns/hns_roce_srq.c | 9 ++- drivers/infiniband/hw/hns/hns_roce_sysfs.c | 33 +++++----- 9 files changed, 86 insertions(+), 59 deletions(-)
From: wenglianfa wenglianfa@huawei.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9SI44
---------------------------------------------------------------------- This read polling mostly ensures that resources such as qp are not destroyed during hw resetting. But if the polling times out, it doesn't work. To instead it, a mechanism for delaying resource destruction has been introduced to fully ensure that.
Read polling wastes too much CPU time and resources causing the cpu stuck. And the role of polling has been replaced, remove read_poll_timeout_atomic() to fix it.
Fixes: 306b8c76257b ("RDMA/hns: Do not destroy QP resources in the hw resetting phase") Fixes: 33050ea1ae49 ("RDMA/hns: fix simultaneous reset and resource deregistration") Signed-off-by: wenglianfa wenglianfa@huawei.com Signed-off-by: Guofeng Yue yueguofeng@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 570675a3b541..11800d07e11c 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -33,7 +33,6 @@ #include <linux/acpi.h> #include <linux/etherdevice.h> #include <linux/interrupt.h> -#include <linux/iopoll.h> #include <linux/kernel.h> #include <linux/types.h> #include <net/addrconf.h> @@ -1146,14 +1145,9 @@ static u32 hns_roce_v2_cmd_hw_resetting(struct hns_roce_dev *hr_dev, unsigned long instance_stage, unsigned long reset_stage) { -#define HW_RESET_TIMEOUT_US 1000000 -#define HW_RESET_DELAY_US 1 - struct hns_roce_v2_priv *priv = hr_dev->priv; struct hnae3_handle *handle = priv->handle; const struct hnae3_ae_ops *ops = handle->ae_algo->ops; - unsigned long val; - int ret;
/* When hardware reset is detected, we should stop sending mailbox&cmq& * doorbell to hardware. If now in .init_instance() function, we should @@ -1166,10 +1160,7 @@ static u32 hns_roce_v2_cmd_hw_resetting(struct hns_roce_dev *hr_dev, */ hr_dev->dis_db = true;
- ret = read_poll_timeout_atomic(ops->ae_dev_reset_cnt, val, - val > hr_dev->reset_cnt, HW_RESET_DELAY_US, - HW_RESET_TIMEOUT_US, false, handle); - if (!ret) + if (!ops->get_hw_reset_stat(handle)) hr_dev->is_reset = true;
if (!hr_dev->is_reset || reset_stage == HNS_ROCE_STATE_RST_INIT ||
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9SI44
---------------------------------------------------------------------- During the reset, issuing the cmdq command to destroy resources such as qp, cq, and mr may fail, and the destruction failure information is printed. When a large number of resources fail to be destroyed, printk() causes multiple threads to compete for a global log buffer spinlock. As a result, the CPU performance deteriorates and the CPU is stuck. To fix it, use a function like printk_limit_rate() to limit the print frequency of printk().
Fixes: 9a4435375cd1 ("IB/hns: Add driver files for hns RoCE driver") Fixes: c7bcb13442e1 ("RDMA/hns: Add SRQ support for hip08 kernel mode") Fixes: 626903e9355b ("RDMA/hns: Add support for reporting wc as software mode") Fixes: 6eef524201de ("RDMA/hns: Replace not intuitive function/macro names") Fixes: 6f5f556d3795 ("RDMA/hns: Use the reserved loopback QPs to free MR before destroying MPT") Fixes: 357f34294686 ("RDMA/hns: Simplify the state judgment code of qp") Fixes: 926a01dc000d ("RDMA/hns: Add QP operations support for hip08 SoC") Fixes: 0273952c5e6e ("RDMA/hns: Add method to detach WQE buffer") Fixes: 9c9edf689a60 ("RDMA/hns: Remove redundant DFX file and DFX ops structure") Signed-off-by: Chengchang Tang tangchengchang@huawei.com Signed-off-by: Guofeng Yue yueguofeng@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_cq.c | 5 ++- drivers/infiniband/hw/hns/hns_roce_hem.c | 5 ++- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 50 +++++++++++++--------- drivers/infiniband/hw/hns/hns_roce_mr.c | 2 +- drivers/infiniband/hw/hns/hns_roce_srq.c | 5 ++- 5 files changed, 39 insertions(+), 28 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_cq.c b/drivers/infiniband/hw/hns/hns_roce_cq.c index 48c25b30a395..695be916c91d 100644 --- a/drivers/infiniband/hw/hns/hns_roce_cq.c +++ b/drivers/infiniband/hw/hns/hns_roce_cq.c @@ -179,8 +179,9 @@ static void free_cqc(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq) ret = hns_roce_destroy_hw_ctx(hr_dev, HNS_ROCE_CMD_DESTROY_CQC, hr_cq->cqn); if (ret) - dev_err(dev, "DESTROY_CQ failed (%d) for CQN %06lx\n", ret, - hr_cq->cqn); + dev_err_ratelimited(dev, + "DESTROY_CQ failed (%d) for CQN %06lx\n", + ret, hr_cq->cqn); if (ret == -EBUSY) hr_cq->delayed_destroy_flag = true;
diff --git a/drivers/infiniband/hw/hns/hns_roce_hem.c b/drivers/infiniband/hw/hns/hns_roce_hem.c index 709a446465a4..ac8aaddee248 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hem.c +++ b/drivers/infiniband/hw/hns/hns_roce_hem.c @@ -712,8 +712,9 @@ void hns_roce_table_put(struct hns_roce_dev *hr_dev,
ret = hr_dev->hw->clear_hem(hr_dev, table, obj, HEM_HOP_STEP_DIRECT); if (ret) - dev_warn(dev, "failed to clear HEM base address, ret = %d.\n", - ret); + dev_warn_ratelimited(dev, + "failed to clear HEM base address, ret = %d.\n", + ret);
hns_roce_free_hem(hr_dev, table->hem[i]); table->hem[i] = NULL; diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 11800d07e11c..44c20f0e6c10 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -451,19 +451,21 @@ static int check_send_valid(struct hns_roce_dev *hr_dev, if (unlikely(hr_qp->state == IB_QPS_RESET || hr_qp->state == IB_QPS_INIT || hr_qp->state == IB_QPS_RTR)) { - ibdev_err(ibdev, "failed to post WQE, QP state %u!\n", - hr_qp->state); + ibdev_err_ratelimited(ibdev, + "failed to post WQE, QP state %u!\n", + hr_qp->state); return -EINVAL; } else if (unlikely(hr_dev->state >= HNS_ROCE_DEVICE_STATE_RST_DOWN)) { - ibdev_err(ibdev, "failed to post WQE, dev state %d!\n", - hr_dev->state); + ibdev_err_ratelimited(ibdev, + "failed to post WQE, dev state %d!\n", + hr_dev->state); return -EIO; }
if (check_dca_attach_enable(hr_qp)) { ret = dca_attach_qp_buf(hr_dev, hr_qp); if (unlikely(ret)) { - ibdev_err(ibdev, + ibdev_err_ratelimited(ibdev, "failed to attach DCA for QP-%ld send!\n", hr_qp->qpn); return ret; @@ -3813,8 +3815,9 @@ static int free_mr_post_send_lp_wqe(struct hns_roce_qp *hr_qp)
ret = hns_roce_v2_post_send(&hr_qp->ibqp, send_wr, &bad_wr); if (ret) { - ibdev_err(ibdev, "failed to post wqe for free mr, ret = %d.\n", - ret); + ibdev_err_ratelimited(ibdev, + "failed to post wqe for free mr, ret = %d.\n", + ret); return ret; }
@@ -3853,7 +3856,7 @@ static void free_mr_send_cmd_to_hw(struct hns_roce_dev *hr_dev)
ret = free_mr_post_send_lp_wqe(hr_qp); if (ret) { - ibdev_err(ibdev, + ibdev_err_ratelimited(ibdev, "failed to send wqe (qp:0x%lx) for free mr, ret = %d.\n", hr_qp->qpn, ret); break; @@ -3866,14 +3869,14 @@ static void free_mr_send_cmd_to_hw(struct hns_roce_dev *hr_dev) while (cqe_cnt) { npolled = hns_roce_v2_poll_cq(&free_mr->rsv_cq->ib_cq, cqe_cnt, wc); if (npolled < 0) { - ibdev_err(ibdev, + ibdev_err_ratelimited(ibdev, "failed to poll cqe for free mr, remain %d cqe.\n", cqe_cnt); goto out; }
if (time_after(jiffies, end)) { - ibdev_err(ibdev, + ibdev_err_ratelimited(ibdev, "failed to poll cqe for free mr and timeout, remain %d cqe.\n", cqe_cnt); goto out; @@ -5535,7 +5538,8 @@ static int hns_roce_v2_set_abs_fields(struct ib_qp *ibqp, int ret = 0;
if (!check_qp_state(cur_state, new_state)) { - ibdev_err(&hr_dev->ib_dev, "Illegal state for QP!\n"); + ibdev_err_ratelimited(&hr_dev->ib_dev, + "Illegal state for QP!\n"); return -EINVAL; }
@@ -5795,7 +5799,7 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp, /* SW pass context to HW */ ret = hns_roce_v2_qp_modify(hr_dev, context, qpc_mask, hr_qp); if (ret) { - ibdev_err(ibdev, "failed to modify QP, ret = %d.\n", ret); + ibdev_err_ratelimited(ibdev, "failed to modify QP, ret = %d.\n", ret); goto out; }
@@ -5980,7 +5984,9 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
ret = hns_roce_v2_query_qpc(hr_dev, hr_qp->qpn, &context); if (ret) { - ibdev_err(ibdev, "failed to query QPC, ret = %d.\n", ret); + ibdev_err_ratelimited(ibdev, + "failed to query QPC, ret = %d.\n", + ret); ret = -EINVAL; goto out; } @@ -5988,7 +5994,7 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, state = hr_reg_read(&context, QPC_QP_ST); tmp_qp_state = to_ib_qp_st((enum hns_roce_v2_qp_state)state); if (tmp_qp_state == -1) { - ibdev_err(ibdev, "Illegal ib_qp_state\n"); + ibdev_err_ratelimited(ibdev, "Illegal ib_qp_state\n"); ret = -EINVAL; goto out; } @@ -6070,7 +6076,9 @@ static bool hns_roce_v2_chk_dca_buf_inactive(struct hns_roce_dev *hr_dev,
ret = hns_roce_v2_query_qpc(hr_dev, hr_qp->qpn, &context); if (ret) { - ibdev_err(ibdev, "failed to query DCA QPC, ret = %d.\n", ret); + ibdev_err_ratelimited(ibdev, + "failed to query DCA QPC, ret = %d.\n", + ret); return false; }
@@ -6114,7 +6122,7 @@ int hns_roce_v2_destroy_qp_common(struct hns_roce_dev *hr_dev, ret = hns_roce_v2_modify_qp(&hr_qp->ibqp, NULL, 0, hr_qp->state, IB_QPS_RESET, udata); if (ret) - ibdev_err(ibdev, + ibdev_err_ratelimited(ibdev, "failed to modify QP to RST, ret = %d.\n", ret); } @@ -6152,7 +6160,7 @@ int hns_roce_v2_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
ret = hns_roce_v2_destroy_qp_common(hr_dev, hr_qp, udata); if (ret) - ibdev_err(&hr_dev->ib_dev, + ibdev_err_ratelimited(&hr_dev->ib_dev, "failed to destroy QP, QPN = 0x%06lx, ret = %d.\n", hr_qp->qpn, ret);
@@ -6451,7 +6459,7 @@ static int hns_roce_v2_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period) HNS_ROCE_CMD_MODIFY_CQC, hr_cq->cqn); hns_roce_free_cmd_mailbox(hr_dev, mailbox); if (ret) - ibdev_err(&hr_dev->ib_dev, + ibdev_err_ratelimited(&hr_dev->ib_dev, "failed to process cmd when modifying CQ, ret = %d.\n", ret);
@@ -6477,9 +6485,9 @@ static int hns_roce_v2_query_cqc(struct hns_roce_dev *hr_dev, u32 cqn, ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_CQC, cqn); if (ret) { - ibdev_err(&hr_dev->ib_dev, - "failed to process cmd when querying CQ, ret = %d.\n", - ret); + ibdev_err_ratelimited(&hr_dev->ib_dev, + "failed to process cmd when querying CQ, ret = %d.\n", + ret); goto err_mailbox; }
diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c index 68049467a721..5af4e365afa5 100644 --- a/drivers/infiniband/hw/hns/hns_roce_mr.c +++ b/drivers/infiniband/hw/hns/hns_roce_mr.c @@ -151,7 +151,7 @@ static void hns_roce_mr_free(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr key_to_hw_index(mr->key) & (hr_dev->caps.num_mtpts - 1)); if (ret) - ibdev_warn(ibdev, "failed to destroy mpt, ret = %d.\n", + ibdev_warn_ratelimited(ibdev, "failed to destroy mpt, ret = %d.\n", ret); if (ret == -EBUSY) mr->delayed_destroy_flag = true; diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c index 4779232ee318..1e57395f1148 100644 --- a/drivers/infiniband/hw/hns/hns_roce_srq.c +++ b/drivers/infiniband/hw/hns/hns_roce_srq.c @@ -162,8 +162,9 @@ static void free_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) ret = hns_roce_destroy_hw_ctx(hr_dev, HNS_ROCE_CMD_DESTROY_SRQ, srq->srqn); if (ret) - dev_err(hr_dev->dev, "DESTROY_SRQ failed (%d) for SRQN %06lx\n", - ret, srq->srqn); + dev_err_ratelimited(hr_dev->dev, + "DESTROY_SRQ failed (%d) for SRQN %06lx\n", + ret, srq->srqn); if (ret == -EBUSY) srq->delayed_destroy_flag = true;
From: wenglianfa wenglianfa@huawei.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9SI44
---------------------------------------------------------------------- The fmt is incorrect. As a result, the unsigned long type is converted to the int type. this patch fix it.
Fixes: 12aa71f83089 ("RDMA/hns: Add DCA support for kernel space") Signed-off-by: wenglianfa wenglianfa@huawei.com Signed-off-by: Guofeng Yue yueguofeng@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 44c20f0e6c10..00a13b36ce2d 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -466,7 +466,7 @@ static int check_send_valid(struct hns_roce_dev *hr_dev, ret = dca_attach_qp_buf(hr_dev, hr_qp); if (unlikely(ret)) { ibdev_err_ratelimited(ibdev, - "failed to attach DCA for QP-%ld send!\n", + "failed to attach DCA for QP-%lu send!\n", hr_qp->qpn); return ret; }
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9SI44
---------------------------------------------------------------------- Currently, the driver does not actively read the default parameters of scc, that is, the default parameters are all 0. Therefore, if the user directly modifies any parameter value without actively reading the scc default parameters, other parameters will become 0.
This patch will read and save the default value of scc immediately after the driver registers sysfs to avoid the above problems.
Fixes: 523f34d81ea7 ("RDMA/hns: Support congestion control algorithm parameter configuration") Signed-off-by: Chengchang Tang tangchengchang@huawei.com Signed-off-by: Guofeng Yue yueguofeng@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 +++ drivers/infiniband/hw/hns/hns_roce_sysfs.c | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 00a13b36ce2d..5df6a07cc8f7 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -7382,6 +7382,9 @@ static int hns_roce_v2_query_scc_param(struct hns_roce_dev *hr_dev, struct hns_roce_port *pdata; int ret;
+ if (hr_dev->pci_dev->revision <= PCI_REVISION_ID_HIP08) + return -EOPNOTSUPP; + if (port_num > hr_dev->caps.num_ports) { ibdev_err_ratelimited(&hr_dev->ib_dev, "invalid port num %u.\n", port_num); diff --git a/drivers/infiniband/hw/hns/hns_roce_sysfs.c b/drivers/infiniband/hw/hns/hns_roce_sysfs.c index a51423b94dc1..f92e5c13ab92 100644 --- a/drivers/infiniband/hw/hns/hns_roce_sysfs.c +++ b/drivers/infiniband/hw/hns/hns_roce_sysfs.c @@ -26,6 +26,22 @@ static void scc_param_config_work(struct work_struct *work) scc_param->algo_type); }
+static void get_default_scc_param(struct hns_roce_dev *hr_dev, + struct hns_roce_port *pdata) +{ + int ret; + int i; + + for (i = 0; i < HNS_ROCE_SCC_ALGO_TOTAL; i++) { + pdata->scc_param[i].timestamp = jiffies; + ret = hr_dev->hw->query_scc_param(hr_dev, pdata->port_num, i); + if (ret && ret != -EOPNOTSUPP) + ibdev_warn_ratelimited(&hr_dev->ib_dev, + "failed to get default parameters of scc algo %d, ret = %d.\n", + i, ret); + } +} + static int alloc_scc_param(struct hns_roce_dev *hr_dev, struct hns_roce_port *pdata) { @@ -39,7 +55,6 @@ static int alloc_scc_param(struct hns_roce_dev *hr_dev,
for (i = 0; i < HNS_ROCE_SCC_ALGO_TOTAL; i++) { scc_param[i].algo_type = i; - scc_param[i].timestamp = jiffies; scc_param[i].hr_dev = hr_dev; scc_param[i].port_num = pdata->port_num; INIT_DELAYED_WORK(&scc_param[i].scc_cfg_dwork, @@ -47,6 +62,9 @@ static int alloc_scc_param(struct hns_roce_dev *hr_dev, }
pdata->scc_param = scc_param; + + get_default_scc_param(hr_dev, pdata); + return 0; }
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9SI44
---------------------------------------------------------------------- The driver will now read the SCC parameters from the firmware during initialization. Subsequent SCC parameters are configured by the driver, so there is no need to read parameters from firmware again.
Fixes: 523f34d81ea7 ("RDMA/hns: Support congestion control algorithm parameter configuration") Signed-off-by: Chengchang Tang tangchengchang@huawei.com Signed-off-by: Guofeng Yue yueguofeng@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +- drivers/infiniband/hw/hns/hns_roce_sysfs.c | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 5df6a07cc8f7..045fe899d953 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -7382,7 +7382,7 @@ static int hns_roce_v2_query_scc_param(struct hns_roce_dev *hr_dev, struct hns_roce_port *pdata; int ret;
- if (hr_dev->pci_dev->revision <= PCI_REVISION_ID_HIP08) + if (hr_dev->pci_dev->revision <= PCI_REVISION_ID_HIP08 || hr_dev->is_vf) return -EOPNOTSUPP;
if (port_num > hr_dev->caps.num_ports) { diff --git a/drivers/infiniband/hw/hns/hns_roce_sysfs.c b/drivers/infiniband/hw/hns/hns_roce_sysfs.c index f92e5c13ab92..0262ec6716f1 100644 --- a/drivers/infiniband/hw/hns/hns_roce_sysfs.c +++ b/drivers/infiniband/hw/hns/hns_roce_sysfs.c @@ -93,7 +93,6 @@ static ssize_t scc_attr_show(struct hns_roce_port *pdata, struct hns_port_cc_attr *scc_attr = container_of(attr, struct hns_port_cc_attr, port_attr); struct hns_roce_scc_param *scc_param; - unsigned long exp_time; __le32 val = 0; int ret;
@@ -103,18 +102,6 @@ static ssize_t scc_attr_show(struct hns_roce_port *pdata,
scc_param = &pdata->scc_param[scc_attr->algo_type];
- /* Only HW param need be queried */ - if (scc_attr->offset < offsetof(typeof(*scc_param), lifespan)) { - exp_time = scc_param->timestamp + - msecs_to_jiffies(scc_param->lifespan); - - if (time_is_before_eq_jiffies(exp_time)) { - scc_param->timestamp = jiffies; - pdata->hr_dev->hw->query_scc_param(pdata->hr_dev, - pdata->port_num, scc_attr->algo_type); - } - } - memcpy(&val, (void *)scc_param + scc_attr->offset, scc_attr->size);
return sysfs_emit(buf, "%u\n", le32_to_cpu(val));
From: Junxian Huang huangjunxian6@hisilicon.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9SI44
---------------------------------------------------------------------- DCA mem size from userspace should be aligned to HNS_HW_PAGE_SIZE as the DCA buffer is managed in the form of pages. Otherwise it may lead to a mis-calculation of pages, which is basically dividing the size by HNS_HW_PAGE_SIZE. Besides, zero size is invalid since it will lead to the failure of page allocation in ib_umem_get().
Fixes: f44a2f97d82a ("RDMA/hns: Introduce DCA for RC QP") Signed-off-by: Junxian Huang huangjunxian6@hisilicon.com Signed-off-by: Guofeng Yue yueguofeng@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_dca.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/infiniband/hw/hns/hns_roce_dca.c b/drivers/infiniband/hw/hns/hns_roce_dca.c index e88603c96ae4..ddc21f10b923 100644 --- a/drivers/infiniband/hw/hns/hns_roce_dca.c +++ b/drivers/infiniband/hw/hns/hns_roce_dca.c @@ -1529,6 +1529,11 @@ static int UVERBS_HANDLER(HNS_IB_METHOD_DCA_MEM_REG)( if (ret) return ret;
+ if (!init_attr.size) + return -EINVAL; + + init_attr.size = hr_hw_page_align(init_attr.size); + mem = alloc_dca_mem(to_hr_dca_ctx(hr_dev, uctx)); if (!mem) return -ENOMEM;
From: Junxian Huang huangjunxian6@hisilicon.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9SI44
---------------------------------------------------------------------- Set NULL after mtr_node is freed.
This patch should be merged with the fixed one.
Fixes: 431c875e4b02 ("RDMA/hns: Fix simultaneous reset and resource deregistration") Signed-off-by: Junxian Huang huangjunxian6@hisilicon.com Signed-off-by: Guofeng Yue yueguofeng@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_cq.c | 2 ++ drivers/infiniband/hw/hns/hns_roce_mr.c | 2 ++ drivers/infiniband/hw/hns/hns_roce_qp.c | 3 +++ drivers/infiniband/hw/hns/hns_roce_srq.c | 4 ++++ 4 files changed, 11 insertions(+)
diff --git a/drivers/infiniband/hw/hns/hns_roce_cq.c b/drivers/infiniband/hw/hns/hns_roce_cq.c index 695be916c91d..e26926622f23 100644 --- a/drivers/infiniband/hw/hns/hns_roce_cq.c +++ b/drivers/infiniband/hw/hns/hns_roce_cq.c @@ -224,6 +224,7 @@ static int alloc_cq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq, if (ret) { ibdev_err(ibdev, "Failed to alloc CQ mtr, ret = %d\n", ret); kvfree(hr_cq->mtr_node); + hr_cq->mtr_node = NULL; }
return ret; @@ -236,6 +237,7 @@ static void free_cq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq) } else { hns_roce_mtr_destroy(hr_dev, &hr_cq->mtr); kvfree(hr_cq->mtr_node); + hr_cq->mtr_node = NULL; } }
diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c index 5af4e365afa5..3c36836dcf49 100644 --- a/drivers/infiniband/hw/hns/hns_roce_mr.c +++ b/drivers/infiniband/hw/hns/hns_roce_mr.c @@ -122,6 +122,7 @@ static int alloc_mr_pbl(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr, if (err) { ibdev_err(ibdev, "failed to alloc pbl mtr, ret = %d.\n", err); kvfree(mr->mtr_node); + mr->mtr_node = NULL; return err; }
@@ -138,6 +139,7 @@ static void free_mr_pbl(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr) } else { hns_roce_mtr_destroy(hr_dev, &mr->pbl_mtr); kvfree(mr->mtr_node); + mr->mtr_node = NULL; } }
diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c index 4989828b5bad..bb0460e7db95 100644 --- a/drivers/infiniband/hw/hns/hns_roce_qp.c +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c @@ -798,6 +798,7 @@ static int alloc_wqe_buf(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp, ibdev_err(ibdev, "failed to enable DCA, ret = %d.\n", ret); kvfree(hr_qp->mtr_node); + hr_qp->mtr_node = NULL; return ret; }
@@ -822,6 +823,7 @@ static int alloc_wqe_buf(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp, if (dca_en) hns_roce_disable_dca(hr_dev, hr_qp, udata); kvfree(hr_qp->mtr_node); + hr_qp->mtr_node = NULL; }
return ret; @@ -835,6 +837,7 @@ static void free_wqe_buf(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp, } else { hns_roce_mtr_destroy(hr_dev, &hr_qp->mtr); kvfree(hr_qp->mtr_node); + hr_qp->mtr_node = NULL; }
if (hr_qp->en_flags & HNS_ROCE_QP_CAP_DYNAMIC_CTX_ATTACH) diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c index 1e57395f1148..cf7b0d51683a 100644 --- a/drivers/infiniband/hw/hns/hns_roce_srq.c +++ b/drivers/infiniband/hw/hns/hns_roce_srq.c @@ -222,6 +222,7 @@ static int alloc_srq_idx(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq, hns_roce_mtr_destroy(hr_dev, &idx_que->mtr); err_kvmalloc: kvfree(idx_que->mtr_node); + idx_que->mtr_node = NULL;
return ret; } @@ -237,6 +238,7 @@ static void free_srq_idx(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) } else { hns_roce_mtr_destroy(hr_dev, &idx_que->mtr); kvfree(idx_que->mtr_node); + idx_que->mtr_node = NULL; } }
@@ -269,6 +271,7 @@ static int alloc_srq_wqe_buf(struct hns_roce_dev *hr_dev, ibdev_err(ibdev, "failed to alloc SRQ buf mtr, ret = %d.\n", ret); kvfree(srq->mtr_node); + srq->mtr_node = NULL; }
return ret; @@ -282,6 +285,7 @@ static void free_srq_wqe_buf(struct hns_roce_dev *hr_dev, } else { hns_roce_mtr_destroy(hr_dev, &srq->buf_mtr); kvfree(srq->mtr_node); + srq->mtr_node = NULL; } }
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9SI44
---------------------------------------------------------------------- xa_lock of qp_table_xa may be acquired in interrupt context. Replace xa_lock()/xa_unlock() with xa_lock_irq()/xa_unlock_irq() to avoid deadlock.
Fixes: a21781182f77 ("RDMA/hns: Add debugfs support for DCA") Signed-off-by: Chengchang Tang tangchengchang@huawei.com Signed-off-by: Guofeng Yue yueguofeng@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_debugfs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_debugfs.c b/drivers/infiniband/hw/hns/hns_roce_debugfs.c index c8294a836ee3..85fa88e8a657 100644 --- a/drivers/infiniband/hw/hns/hns_roce_debugfs.c +++ b/drivers/infiniband/hw/hns/hns_roce_debugfs.c @@ -353,19 +353,19 @@ static void dca_stats_dev_qp_in_seqfile(struct hns_roce_dev *hr_dev, seq_printf(file, "%-10s %-10s %-10s %s\n", "QPN", "Size(kB)", "PID", "State");
- xa_lock(&hr_dev->qp_table_xa); + xa_lock_irq(&hr_dev->qp_table_xa); xa_for_each(&hr_dev->qp_table_xa, id, hr_qp) { stats.total_size = 0; dca_setup_qp_stats(hr_qp, &stats); if (!stats.total_size) continue;
- xa_unlock(&hr_dev->qp_table_xa); + xa_unlock_irq(&hr_dev->qp_table_xa); seq_printf(file, "%-10u %-10u %-10s %-s\n", stats.qpn, stats.total_size / KB, stats.name, stats.state); - xa_lock(&hr_dev->qp_table_xa); + xa_lock_irq(&hr_dev->qp_table_xa); } - xa_unlock(&hr_dev->qp_table_xa); + xa_unlock_irq(&hr_dev->qp_table_xa); }
static void dca_stats_ctx_qp_in_seqfile(struct hns_roce_dev *hr_dev, @@ -391,11 +391,11 @@ static void dca_stats_ctx_qp_in_seqfile(struct hns_roce_dev *hr_dev, dca_ctx_stats_qp(ctx, bitmap, nbits); for_each_set_bit(qpn, bitmap, nbits) { stats.total_size = 0; - xa_lock(&hr_dev->qp_table_xa); + xa_lock_irq(&hr_dev->qp_table_xa); hr_qp = __hns_roce_qp_lookup(hr_dev, qpn); if (hr_qp) dca_setup_qp_stats(hr_qp, &stats); - xa_unlock(&hr_dev->qp_table_xa); + xa_unlock_irq(&hr_dev->qp_table_xa); if (!stats.total_size) continue;
From: wenglianfa wenglianfa@huawei.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9SI44
---------------------------------------------------------------------- Add list_del() to delete trunk list in hns_roce_hem().
Fixes: 9a4435375cd1 ("IB/hns: Add driver files for hns RoCE driver") Signed-off-by: wenglianfa wenglianfa@huawei.com Signed-off-by: Guofeng Yue yueguofeng@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_hem.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hem.c b/drivers/infiniband/hw/hns/hns_roce_hem.c index ac8aaddee248..f6e4ecbcb1d3 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hem.c +++ b/drivers/infiniband/hw/hns/hns_roce_hem.c @@ -321,6 +321,7 @@ void hns_roce_free_hem(struct hns_roce_dev *hr_dev, struct hns_roce_hem *hem) return;
list_for_each_entry_safe(chunk, tmp, &hem->chunk_list, list) { + list_del(&chunk->list); for (i = 0; i < chunk->npages; ++i) dma_free_coherent(hr_dev->dev, sg_dma_len(&chunk->mem[i]),
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/8242 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/B...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/8242 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/B...