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

!13281 【OLK 5.10】RDMA/hns backport some bugfix from mainline linux

Merge Pull Request from: @huwentao0417 
 
|commitID|commit message|conflict|
|--|--|--|
|d81fb6511abf|RDMA/hns: Use dev_* printings in hem code instead of ibdev_*|N|
|370a9351bf84|RDMA/hns: Modify debugfs name|N|
|5dbcb1c1900f|RDMA/hns: Fix out-of-order issue of requester when setting FENCE|N|
|6b526d17eed8|RDMA/hns: Fix NULL pointer derefernce in hns_roce_map_mr_sg()|N| 
 
Link:https://gitee.com/openeuler/kernel/pulls/13281

 

Reviewed-by: default avatarLi Nan <linan122@huawei.com>
Reviewed-by: default avatarChengchang Tang <tangchengchang@huawei.com>
Signed-off-by: default avatarLi Nan <linan122@huawei.com>
parents 54bbb7bf e6d4c65d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@

#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/pci.h>

#include "hns_roce_common.h"
#include "hns_roce_device.h"
@@ -675,7 +676,7 @@ void hns_roce_register_debugfs(struct hns_roce_dev *hr_dev)
{
	struct hns_roce_dev_debugfs *dbgfs = &hr_dev->dbgfs;

	dbgfs->root = debugfs_create_dir(dev_name(&hr_dev->ib_dev.dev),
	dbgfs->root = debugfs_create_dir(pci_name(hr_dev->pci_dev),
					 hns_roce_dbgfs_root);

	if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_DCA_MODE)
+22 −22
Original line number Diff line number Diff line
@@ -338,7 +338,7 @@ static int calc_hem_config(struct hns_roce_dev *hr_dev,
			   struct hns_roce_hem_mhop *mhop,
			   struct hns_roce_hem_index *index)
{
	struct ib_device *ibdev = &hr_dev->ib_dev;
	struct device *dev = hr_dev->dev;
	unsigned long mhop_obj = obj;
	u32 l0_idx, l1_idx, l2_idx;
	u32 chunk_ba_num;
@@ -369,13 +369,13 @@ static int calc_hem_config(struct hns_roce_dev *hr_dev,
		index->buf = l0_idx;
		break;
	default:
		ibdev_err(ibdev, "table %u not support mhop.hop_num = %u!\n",
		dev_err(dev, "table %u not support mhop.hop_num = %u!\n",
			table->type, mhop->hop_num);
		return -EINVAL;
	}

	if (unlikely(index->buf >= table->num_hem)) {
		ibdev_err(ibdev, "table %u exceed hem limt idx %llu, max %lu!\n",
		dev_err(dev, "table %u exceed hem limt idx %llu, max %lu!\n",
			table->type, index->buf, table->num_hem);
		return -EINVAL;
	}
@@ -488,14 +488,14 @@ static int set_mhop_hem(struct hns_roce_dev *hr_dev,
			struct hns_roce_hem_mhop *mhop,
			struct hns_roce_hem_index *index)
{
	struct ib_device *ibdev = &hr_dev->ib_dev;
	struct device *dev = hr_dev->dev;
	u32 step_idx;
	int ret = 0;

	if (index->inited & HEM_INDEX_L0) {
		ret = hr_dev->hw->set_hem(hr_dev, table, obj, 0);
		if (ret) {
			ibdev_err(ibdev, "set HEM step 0 failed!\n");
			dev_err(dev, "set HEM step 0 failed!\n");
			goto out;
		}
	}
@@ -503,7 +503,7 @@ static int set_mhop_hem(struct hns_roce_dev *hr_dev,
	if (index->inited & HEM_INDEX_L1) {
		ret = hr_dev->hw->set_hem(hr_dev, table, obj, 1);
		if (ret) {
			ibdev_err(ibdev, "set HEM step 1 failed!\n");
			dev_err(dev, "set HEM step 1 failed!\n");
			goto out;
		}
	}
@@ -515,7 +515,7 @@ static int set_mhop_hem(struct hns_roce_dev *hr_dev,
			step_idx = mhop->hop_num;
		ret = hr_dev->hw->set_hem(hr_dev, table, obj, step_idx);
		if (ret)
			ibdev_err(ibdev, "set HEM step last failed!\n");
			dev_err(dev, "set HEM step last failed!\n");
	}
out:
	return ret;
@@ -525,14 +525,14 @@ static int hns_roce_table_mhop_get(struct hns_roce_dev *hr_dev,
				   struct hns_roce_hem_table *table,
				   unsigned long obj)
{
	struct ib_device *ibdev = &hr_dev->ib_dev;
	struct hns_roce_hem_index index = {};
	struct hns_roce_hem_mhop mhop = {};
	struct device *dev = hr_dev->dev;
	int ret;

	ret = calc_hem_config(hr_dev, table, obj, &mhop, &index);
	if (ret) {
		ibdev_err(ibdev, "calc hem config failed!\n");
		dev_err(dev, "calc hem config failed!\n");
		return ret;
	}

@@ -544,7 +544,7 @@ static int hns_roce_table_mhop_get(struct hns_roce_dev *hr_dev,

	ret = alloc_mhop_hem(hr_dev, table, &mhop, &index);
	if (ret) {
		ibdev_err(ibdev, "alloc mhop hem failed!\n");
		dev_err(dev, "alloc mhop hem failed!\n");
		goto out;
	}

@@ -552,7 +552,7 @@ static int hns_roce_table_mhop_get(struct hns_roce_dev *hr_dev,
	if (table->type < HEM_TYPE_MTT) {
		ret = set_mhop_hem(hr_dev, table, obj, &mhop, &index);
		if (ret) {
			ibdev_err(ibdev, "set HEM address to HW failed!\n");
			dev_err(dev, "set HEM address to HW failed!\n");
			goto err_alloc;
		}
	}
@@ -616,7 +616,7 @@ static void clear_mhop_hem(struct hns_roce_dev *hr_dev,
			   struct hns_roce_hem_mhop *mhop,
			   struct hns_roce_hem_index *index)
{
	struct ib_device *ibdev = &hr_dev->ib_dev;
	struct device *dev = hr_dev->dev;
	u32 hop_num = mhop->hop_num;
	u32 chunk_ba_num;
	u32 step_idx;
@@ -646,20 +646,20 @@ static void clear_mhop_hem(struct hns_roce_dev *hr_dev,

		ret = hr_dev->hw->clear_hem(hr_dev, table, obj, step_idx);
		if (ret)
			ibdev_warn(ibdev, "failed to clear hop%u HEM, ret = %d.\n",
			dev_warn(dev, "failed to clear hop%u HEM, ret = %d.\n",
				 hop_num, ret);

		if (index->inited & HEM_INDEX_L1) {
			ret = hr_dev->hw->clear_hem(hr_dev, table, obj, 1);
			if (ret)
				ibdev_warn(ibdev, "failed to clear HEM step 1, ret = %d.\n",
				dev_warn(dev, "failed to clear HEM step 1, ret = %d.\n",
					 ret);
		}

		if (index->inited & HEM_INDEX_L0) {
			ret = hr_dev->hw->clear_hem(hr_dev, table, obj, 0);
			if (ret)
				ibdev_warn(ibdev, "failed to clear HEM step 0, ret = %d.\n",
				dev_warn(dev, "failed to clear HEM step 0, ret = %d.\n",
					 ret);
		}
	}
@@ -670,14 +670,14 @@ static void hns_roce_table_mhop_put(struct hns_roce_dev *hr_dev,
				    unsigned long obj,
				    int check_refcount)
{
	struct ib_device *ibdev = &hr_dev->ib_dev;
	struct hns_roce_hem_index index = {};
	struct hns_roce_hem_mhop mhop = {};
	struct device *dev = hr_dev->dev;
	int ret;

	ret = calc_hem_config(hr_dev, table, obj, &mhop, &index);
	if (ret) {
		ibdev_err(ibdev, "calc hem config failed!\n");
		dev_err(dev, "calc hem config failed!\n");
		return;
	}

+1 −1
Original line number Diff line number Diff line
@@ -680,7 +680,7 @@ static inline int set_rc_wqe(struct hns_roce_qp *qp,
	if (WARN_ON(ret))
		return ret;

	hr_reg_write(rc_sq_wqe, RC_SEND_WQE_FENCE,
	hr_reg_write(rc_sq_wqe, RC_SEND_WQE_SO,
		     (wr->send_flags & IB_SEND_FENCE) ? 1 : 0);

	hr_reg_write(rc_sq_wqe, RC_SEND_WQE_SE,
+1 −0
Original line number Diff line number Diff line
@@ -963,6 +963,7 @@ struct hns_roce_v2_rc_send_wqe {
#define RC_SEND_WQE_OWNER RC_SEND_WQE_FIELD_LOC(7, 7)
#define RC_SEND_WQE_CQE RC_SEND_WQE_FIELD_LOC(8, 8)
#define RC_SEND_WQE_FENCE RC_SEND_WQE_FIELD_LOC(9, 9)
#define RC_SEND_WQE_SO RC_SEND_WQE_FIELD_LOC(10, 10)
#define RC_SEND_WQE_SE RC_SEND_WQE_FIELD_LOC(11, 11)
#define RC_SEND_WQE_INLINE RC_SEND_WQE_FIELD_LOC(12, 12)
#define RC_SEND_WQE_WQE_INDEX RC_SEND_WQE_FIELD_LOC(30, 15)
+4 −3
Original line number Diff line number Diff line
@@ -446,15 +446,16 @@ static int hns_roce_set_page(struct ib_mr *ibmr, u64 addr)
}

int hns_roce_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
		       unsigned int *sg_offset)
		       unsigned int *sg_offset_p)
{
	unsigned int sg_offset = sg_offset_p ? *sg_offset_p : 0;
	struct hns_roce_dev *hr_dev = to_hr_dev(ibmr->device);
	struct ib_device *ibdev = &hr_dev->ib_dev;
	struct hns_roce_mr *mr = to_hr_mr(ibmr);
	struct hns_roce_mtr *mtr = &mr->pbl_mtr;
	int ret, sg_num = 0;

	if (!IS_ALIGNED(*sg_offset, HNS_ROCE_FRMR_ALIGN_SIZE) ||
	if (!IS_ALIGNED(sg_offset, HNS_ROCE_FRMR_ALIGN_SIZE) ||
	    ibmr->page_size < HNS_HW_PAGE_SIZE ||
	    ibmr->page_size > HNS_HW_MAX_PAGE_SIZE)
		return sg_num;
@@ -465,7 +466,7 @@ int hns_roce_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
	if (!mr->page_list)
		return sg_num;

	sg_num = ib_sg_to_pages(ibmr, sg, sg_nents, sg_offset, hns_roce_set_page);
	sg_num = ib_sg_to_pages(ibmr, sg, sg_nents, sg_offset_p, hns_roce_set_page);
	if (sg_num < 1) {
		ibdev_err(ibdev, "failed to store sg pages %u %u, cnt = %d.\n",
			  mr->npages, mr->pbl_mtr.hem_cfg.buf_pg_count, sg_num);