Commit 4bbc4730 authored by wenglianfa's avatar wenglianfa Committed by Juan Zhou
Browse files

RDMA/hns: Add mutex_destroy()

parent e94b6c5b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -558,4 +558,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
@@ -878,6 +878,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;
	}

@@ -892,6 +893,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
@@ -2856,6 +2856,8 @@ static void free_mr_exit(struct hns_roce_dev *hr_dev)
		kfree(free_mr->rsv_pd);
		free_mr->rsv_pd = NULL;
	}

	mutex_destroy(&free_mr->mutex);
}

static int free_mr_alloc_res(struct hns_roce_dev *hr_dev)
@@ -3006,8 +3008,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)
+15 −0
Original line number Diff line number Diff line
@@ -605,6 +605,10 @@ 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:
@@ -625,6 +629,10 @@ static void hns_roce_dealloc_ucontext(struct ib_ucontext *ibcontext)
	list_del(&context->list);
	mutex_unlock(&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(&context->page_mutex);

	hns_roce_unregister_uctx_debugfs(context);

	hns_roce_unregister_udca(hr_dev, context);
@@ -1238,6 +1246,9 @@ 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);
}

/**
@@ -1305,6 +1316,10 @@ static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev)

err_uar_table_free:
	ida_destroy(&hr_dev->uar_ida.ida);
	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
@@ -1237,7 +1237,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) {
@@ -1245,7 +1245,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;
		}
	}

@@ -1316,6 +1316,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;
}

@@ -1331,6 +1333,7 @@ void hns_roce_qp_destroy(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
	free_qp_wqe(hr_dev, hr_qp, udata);
	free_kernel_wrid(hr_qp);
	free_qp_db(hr_dev, hr_qp, udata);
	mutex_destroy(&hr_qp->mutex);
}

static int check_qp_type(struct hns_roce_dev *hr_dev, enum ib_qp_type type,
@@ -1700,5 +1703,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