Commit 04615247 authored by wenglianfa's avatar wenglianfa Committed by huwentao0417
Browse files

RDMA/hns: Add mutex_destroy()

mainline inclusion
from mainline-v6.10-rc1
commit 9a84848dcee289966e8a2c21223bb0d7bc44f201
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9SONH

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



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

Add mutex_destroy().

Signed-off-by: default avatarwenglianfa <wenglianfa@huawei.com>
Signed-off-by: default avatarJunxian Huang <huangjunxian6@hisilicon.com>
Link: https://lore.kernel.org/r/20240412091616.370789-9-huangjunxian6@hisilicon.com


Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarhuwentao0417 <huwentao19@h-partners.com>
parent e9ad773d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -667,4 +667,5 @@ void hns_roce_cleanup_cq_table(struct hns_roce_dev *hr_dev)

	for (i = 0; i < HNS_ROCE_CQ_BANK_NUM; i++)
		ida_destroy(&hr_dev->cq_table.bank[i].ida);
	mutex_destroy(&hr_dev->cq_table.bank_mutex);
}
+2 −0
Original line number Diff line number Diff line
@@ -936,6 +936,7 @@ void hns_roce_cleanup_hem_table(struct hns_roce_dev *hr_dev,

	if (hns_roce_check_whether_mhop(hr_dev, table->type)) {
		hns_roce_cleanup_mhop_hem_table(hr_dev, table);
		mutex_destroy(&table->mutex);
		return;
	}

@@ -950,6 +951,7 @@ void hns_roce_cleanup_hem_table(struct hns_roce_dev *hr_dev,
			hns_roce_free_hem(hr_dev, table->hem[i]);
		}

	mutex_destroy(&table->mutex);
	kfree(table->hem);
}

+5 −1
Original line number Diff line number Diff line
@@ -3063,6 +3063,8 @@ static void free_mr_exit(struct hns_roce_dev *hr_dev)

	free_mr_uninit_cq(hr_dev);
	free_mr_uninit_pd(hr_dev);

	mutex_destroy(&free_mr->mutex);
}

static int free_mr_alloc_res(struct hns_roce_dev *hr_dev)
@@ -3201,8 +3203,10 @@ static int free_mr_init(struct hns_roce_dev *hr_dev)
	mutex_init(&free_mr->mutex);

	ret = free_mr_alloc_res(hr_dev);
	if (ret)
	if (ret) {
		mutex_destroy(&free_mr->mutex);
		return ret;
	}

	ret = free_mr_modify_qp(hr_dev);
	if (ret)
+14 −0
Original line number Diff line number Diff line
@@ -630,6 +630,9 @@ static int hns_roce_alloc_ucontext(struct ib_ucontext *uctx,
	hns_roce_dealloc_reset_entry(context);

error_fail_reset_entry:
	if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_CQ_RECORD_DB ||
	    hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_RECORD_DB)
		mutex_destroy(&context->page_mutex);
	hns_roce_dealloc_uar_entry(context);

error_fail_uar_entry:
@@ -653,6 +656,9 @@ static void hns_roce_dealloc_ucontext(struct ib_ucontext *ibcontext)
	hns_roce_unregister_uctx_debugfs(context);

	hns_roce_unregister_udca(hr_dev, context);
	if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_CQ_RECORD_DB ||
	    hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_RECORD_DB)
		mutex_destroy(&context->page_mutex);

	hns_roce_dealloc_uar_entry(context);
	hns_roce_dealloc_reset_entry(context);
@@ -1306,6 +1312,10 @@ static void hns_roce_teardown_hca(struct hns_roce_dev *hr_dev)

	hns_roce_cleanup_bitmap(hr_dev);
	mutex_destroy(&hr_dev->uctx_list_mutex);

	if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_CQ_RECORD_DB ||
	    hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_RECORD_DB)
		mutex_destroy(&hr_dev->pgdir_mutex);
}

/**
@@ -1375,6 +1385,10 @@ static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev)
err_uar_table_free:
	ida_destroy(&hr_dev->uar_ida.ida);
	mutex_destroy(&hr_dev->uctx_list_mutex);
	if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_CQ_RECORD_DB ||
	    hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_RECORD_DB)
		mutex_destroy(&hr_dev->pgdir_mutex);

	return ret;
}

+7 −2
Original line number Diff line number Diff line
@@ -1312,7 +1312,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
	ret = set_qp_param(hr_dev, hr_qp, init_attr, udata, &ucmd);
	if (ret) {
		ibdev_err(ibdev, "failed to set QP param, ret = %d.\n", ret);
		return ret;
		goto err_out;
	}

	if (!udata) {
@@ -1320,7 +1320,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
		if (ret) {
			ibdev_err(ibdev, "failed to alloc wrid, ret = %d.\n",
				  ret);
			return ret;
			goto err_out;
		}
	}

@@ -1391,6 +1391,8 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
	free_qpn(hr_dev, hr_qp);
err_qpn:
	free_kernel_wrid(hr_qp);
err_out:
	mutex_destroy(&hr_qp->mutex);
	return ret;
}

@@ -1407,6 +1409,7 @@ void hns_roce_qp_destroy(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
	free_kernel_wrid(hr_qp);
	free_qp_db(hr_dev, hr_qp, udata);

	mutex_destroy(&hr_qp->mutex);
	kfree(hr_qp);
}

@@ -1788,5 +1791,7 @@ void hns_roce_cleanup_qp_table(struct hns_roce_dev *hr_dev)

	for (i = 0; i < HNS_ROCE_QP_BANK_NUM; i++)
		ida_destroy(&hr_dev->qp_table.bank[i].ida);
	mutex_destroy(&hr_dev->qp_table.bank_mutex);
	mutex_destroy(&hr_dev->qp_table.scc_mutex);
	kfree(hr_dev->qp_table.idx_table.spare_idx);
}
Loading