Unverified Commit 5de0187d authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!8396 RDMA/hns: A set of bugfixes for openeuler 22.03 SP4

Merge Pull Request from: @ygf_123 
 
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

https://gitee.com/openeuler/kernel/issues/I9SI44 
 
Link:https://gitee.com/openeuler/kernel/pulls/8396

 

Reviewed-by: default avatarChengchang Tang <tangchengchang@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 16e09ea7 f5e0033c
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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;

@@ -223,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;
@@ -235,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;
	}
}

+5 −0
Original line number Diff line number Diff line
@@ -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;
+6 −6
Original line number Diff line number Diff line
@@ -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;

+4 −2
Original line number Diff line number Diff line
@@ -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]),
@@ -712,7 +713,8 @@ 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",
		dev_warn_ratelimited(dev,
			"failed to clear HEM base address, ret = %d.\n",
			ret);

	hns_roce_free_hem(hr_dev, table->hem[i]);
+34 −32
Original line number Diff line number Diff line
@@ -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>
@@ -452,11 +451,13 @@ 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",
		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",
		ibdev_err_ratelimited(ibdev,
				      "failed to post WQE, dev state %d!\n",
				      hr_dev->state);
		return -EIO;
	}
@@ -464,8 +465,8 @@ static int check_send_valid(struct hns_roce_dev *hr_dev,
	if (check_dca_attach_enable(hr_qp)) {
		ret = dca_attach_qp_buf(hr_dev, hr_qp);
		if (unlikely(ret)) {
			ibdev_err(ibdev,
				  "failed to attach DCA for QP-%ld send!\n",
			ibdev_err_ratelimited(ibdev,
				  "failed to attach DCA for QP-%lu send!\n",
				  hr_qp->qpn);
			return ret;
		}
@@ -1146,14 +1147,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 +1162,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 ||
@@ -3827,7 +3820,8 @@ 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",
		ibdev_err_ratelimited(ibdev,
			"failed to post wqe for free mr, ret = %d.\n",
			ret);
		return ret;
	}
@@ -3867,7 +3861,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;
@@ -3880,14 +3874,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;
@@ -5550,7 +5544,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;
	}

@@ -5810,7 +5805,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;
	}

@@ -5995,7 +5990,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;
	}
@@ -6003,7 +6000,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;
	}
@@ -6085,7 +6082,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;
	}

@@ -6129,7 +6128,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);
	}
@@ -6167,7 +6166,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);

@@ -6466,7 +6465,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);

@@ -6492,7 +6491,7 @@ 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,
		ibdev_err_ratelimited(&hr_dev->ib_dev,
			"failed to process cmd when querying CQ, ret = %d.\n",
			ret);
		goto err_mailbox;
@@ -7389,6 +7388,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 || hr_dev->is_vf)
		return -EOPNOTSUPP;

	if (port_num > hr_dev->caps.num_ports) {
		ibdev_err_ratelimited(&hr_dev->ib_dev,
				      "invalid port num %u.\n", port_num);
Loading