Commit 305d85ee authored by Junxian Huang's avatar Junxian Huang Committed by huwentao
Browse files

RDMA/hns: Use dev_* printings in hem code instead of ibdev_*

mainline inclusion
from mainline-v6.13-rc1
commit d81fb6511abf18591befaa5f4a972ffc838690ec
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IB4ZYK

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git/commit/?id=d81fb6511abf18591befaa5f4a972ffc838690ec



----------------------------------------------------------------------

The hem code is executed before ib_dev is registered, so use dev_*
printing instead of ibdev_* to avoid log like this:

(null): set HEM address to HW failed!

Fixes: 2f49de21 ("RDMA/hns: Optimize mhop get flow for multi-hop addressing")
Signed-off-by: default avatarJunxian Huang <huangjunxian6@hisilicon.com>
Link: https://patch.msgid.link/20241024124000.2931869-5-huangjunxian6@hisilicon.com


Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarhuwentao <huwentao19@h-partners.com>
parent 1208e3b0
Loading
Loading
Loading
Loading
+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;
	}