Commit 29dc0635 authored by Yunsheng Lin's avatar Yunsheng Lin Committed by Jason Gunthorpe
Browse files

RDMA/hns: Remove redundant 'use_lowmem' argument from hns_roce_init_hem_table()

As hns_roce_init_hem_table() is always called with use_lowmem
being '1', and table->lowmem is set according to that argument,
so remove table->lowmem too.

Also, as the table->lowmem is used to indicate a dma buffer
is allocated with GFP_HIGHUSER or GFP_KERNEL, and calling
dma_alloc_coherent() with GFP_KERNEL seems like a common
pattern.

Link: https://lore.kernel.org/r/20220922123315.3732205-7-xuhaoyue1@hisilicon.com


Signed-off-by: default avatarYunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: default avatarHaoyue Xu <xuhaoyue1@hisilicon.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent be1eeb66
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -240,7 +240,6 @@ struct hns_roce_hem_table {
	/* Single obj size */
	/* Single obj size */
	unsigned long	obj_size;
	unsigned long	obj_size;
	unsigned long	table_chunk_size;
	unsigned long	table_chunk_size;
	int		lowmem;
	struct mutex	mutex;
	struct mutex	mutex;
	struct hns_roce_hem **hem;
	struct hns_roce_hem **hem;
	u64		**bt_l1;
	u64		**bt_l1;
+3 −9
Original line number Original line Diff line number Diff line
@@ -455,7 +455,7 @@ static int alloc_mhop_hem(struct hns_roce_dev *hr_dev,
	 * alloc bt space chunk for MTT/CQE.
	 * alloc bt space chunk for MTT/CQE.
	 */
	 */
	size = table->type < HEM_TYPE_MTT ? mhop->buf_chunk_size : bt_size;
	size = table->type < HEM_TYPE_MTT ? mhop->buf_chunk_size : bt_size;
	flag = (table->lowmem ? GFP_KERNEL : GFP_HIGHUSER) | __GFP_NOWARN;
	flag = GFP_KERNEL | __GFP_NOWARN;
	table->hem[index->buf] = hns_roce_alloc_hem(hr_dev, size >> PAGE_SHIFT,
	table->hem[index->buf] = hns_roce_alloc_hem(hr_dev, size >> PAGE_SHIFT,
						    size, flag);
						    size, flag);
	if (!table->hem[index->buf]) {
	if (!table->hem[index->buf]) {
@@ -588,8 +588,7 @@ int hns_roce_table_get(struct hns_roce_dev *hr_dev,
	table->hem[i] = hns_roce_alloc_hem(hr_dev,
	table->hem[i] = hns_roce_alloc_hem(hr_dev,
				       table->table_chunk_size >> PAGE_SHIFT,
				       table->table_chunk_size >> PAGE_SHIFT,
				       table->table_chunk_size,
				       table->table_chunk_size,
				       (table->lowmem ? GFP_KERNEL :
				       GFP_KERNEL | __GFP_NOWARN);
					GFP_HIGHUSER) | __GFP_NOWARN);
	if (!table->hem[i]) {
	if (!table->hem[i]) {
		ret = -ENOMEM;
		ret = -ENOMEM;
		goto out;
		goto out;
@@ -725,9 +724,6 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev,
	int length;
	int length;
	int i, j;
	int i, j;


	if (!table->lowmem)
		return NULL;

	mutex_lock(&table->mutex);
	mutex_lock(&table->mutex);


	if (!hns_roce_check_whether_mhop(hr_dev, table->type)) {
	if (!hns_roce_check_whether_mhop(hr_dev, table->type)) {
@@ -783,8 +779,7 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev,


int hns_roce_init_hem_table(struct hns_roce_dev *hr_dev,
int hns_roce_init_hem_table(struct hns_roce_dev *hr_dev,
			    struct hns_roce_hem_table *table, u32 type,
			    struct hns_roce_hem_table *table, u32 type,
			    unsigned long obj_size, unsigned long nobj,
			    unsigned long obj_size, unsigned long nobj)
			    int use_lowmem)
{
{
	unsigned long obj_per_chunk;
	unsigned long obj_per_chunk;
	unsigned long num_hem;
	unsigned long num_hem;
@@ -861,7 +856,6 @@ int hns_roce_init_hem_table(struct hns_roce_dev *hr_dev,
	table->type = type;
	table->type = type;
	table->num_hem = num_hem;
	table->num_hem = num_hem;
	table->obj_size = obj_size;
	table->obj_size = obj_size;
	table->lowmem = use_lowmem;
	mutex_init(&table->mutex);
	mutex_init(&table->mutex);


	return 0;
	return 0;
+1 −2
Original line number Original line Diff line number Diff line
@@ -111,8 +111,7 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev,
			  dma_addr_t *dma_handle);
			  dma_addr_t *dma_handle);
int hns_roce_init_hem_table(struct hns_roce_dev *hr_dev,
int hns_roce_init_hem_table(struct hns_roce_dev *hr_dev,
			    struct hns_roce_hem_table *table, u32 type,
			    struct hns_roce_hem_table *table, u32 type,
			    unsigned long obj_size, unsigned long nobj,
			    unsigned long obj_size, unsigned long nobj);
			    int use_lowmem);
void hns_roce_cleanup_hem_table(struct hns_roce_dev *hr_dev,
void hns_roce_cleanup_hem_table(struct hns_roce_dev *hr_dev,
				struct hns_roce_hem_table *table);
				struct hns_roce_hem_table *table);
void hns_roce_cleanup_hem(struct hns_roce_dev *hr_dev);
void hns_roce_cleanup_hem(struct hns_roce_dev *hr_dev);
+10 −10
Original line number Original line Diff line number Diff line
@@ -659,7 +659,7 @@ static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)


	ret = hns_roce_init_hem_table(hr_dev, &hr_dev->mr_table.mtpt_table,
	ret = hns_roce_init_hem_table(hr_dev, &hr_dev->mr_table.mtpt_table,
				      HEM_TYPE_MTPT, hr_dev->caps.mtpt_entry_sz,
				      HEM_TYPE_MTPT, hr_dev->caps.mtpt_entry_sz,
				      hr_dev->caps.num_mtpts, 1);
				      hr_dev->caps.num_mtpts);
	if (ret) {
	if (ret) {
		dev_err(dev, "Failed to init MTPT context memory, aborting.\n");
		dev_err(dev, "Failed to init MTPT context memory, aborting.\n");
		return ret;
		return ret;
@@ -667,7 +667,7 @@ static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)


	ret = hns_roce_init_hem_table(hr_dev, &hr_dev->qp_table.qp_table,
	ret = hns_roce_init_hem_table(hr_dev, &hr_dev->qp_table.qp_table,
				      HEM_TYPE_QPC, hr_dev->caps.qpc_sz,
				      HEM_TYPE_QPC, hr_dev->caps.qpc_sz,
				      hr_dev->caps.num_qps, 1);
				      hr_dev->caps.num_qps);
	if (ret) {
	if (ret) {
		dev_err(dev, "Failed to init QP context memory, aborting.\n");
		dev_err(dev, "Failed to init QP context memory, aborting.\n");
		goto err_unmap_dmpt;
		goto err_unmap_dmpt;
@@ -677,7 +677,7 @@ static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)
				      HEM_TYPE_IRRL,
				      HEM_TYPE_IRRL,
				      hr_dev->caps.irrl_entry_sz *
				      hr_dev->caps.irrl_entry_sz *
				      hr_dev->caps.max_qp_init_rdma,
				      hr_dev->caps.max_qp_init_rdma,
				      hr_dev->caps.num_qps, 1);
				      hr_dev->caps.num_qps);
	if (ret) {
	if (ret) {
		dev_err(dev, "Failed to init irrl_table memory, aborting.\n");
		dev_err(dev, "Failed to init irrl_table memory, aborting.\n");
		goto err_unmap_qp;
		goto err_unmap_qp;
@@ -689,7 +689,7 @@ static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)
					      HEM_TYPE_TRRL,
					      HEM_TYPE_TRRL,
					      hr_dev->caps.trrl_entry_sz *
					      hr_dev->caps.trrl_entry_sz *
					      hr_dev->caps.max_qp_dest_rdma,
					      hr_dev->caps.max_qp_dest_rdma,
					      hr_dev->caps.num_qps, 1);
					      hr_dev->caps.num_qps);
		if (ret) {
		if (ret) {
			dev_err(dev,
			dev_err(dev,
				"Failed to init trrl_table memory, aborting.\n");
				"Failed to init trrl_table memory, aborting.\n");
@@ -699,7 +699,7 @@ static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)


	ret = hns_roce_init_hem_table(hr_dev, &hr_dev->cq_table.table,
	ret = hns_roce_init_hem_table(hr_dev, &hr_dev->cq_table.table,
				      HEM_TYPE_CQC, hr_dev->caps.cqc_entry_sz,
				      HEM_TYPE_CQC, hr_dev->caps.cqc_entry_sz,
				      hr_dev->caps.num_cqs, 1);
				      hr_dev->caps.num_cqs);
	if (ret) {
	if (ret) {
		dev_err(dev, "Failed to init CQ context memory, aborting.\n");
		dev_err(dev, "Failed to init CQ context memory, aborting.\n");
		goto err_unmap_trrl;
		goto err_unmap_trrl;
@@ -709,7 +709,7 @@ static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)
		ret = hns_roce_init_hem_table(hr_dev, &hr_dev->srq_table.table,
		ret = hns_roce_init_hem_table(hr_dev, &hr_dev->srq_table.table,
					      HEM_TYPE_SRQC,
					      HEM_TYPE_SRQC,
					      hr_dev->caps.srqc_entry_sz,
					      hr_dev->caps.srqc_entry_sz,
					      hr_dev->caps.num_srqs, 1);
					      hr_dev->caps.num_srqs);
		if (ret) {
		if (ret) {
			dev_err(dev,
			dev_err(dev,
				"Failed to init SRQ context memory, aborting.\n");
				"Failed to init SRQ context memory, aborting.\n");
@@ -722,7 +722,7 @@ static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)
					      &hr_dev->qp_table.sccc_table,
					      &hr_dev->qp_table.sccc_table,
					      HEM_TYPE_SCCC,
					      HEM_TYPE_SCCC,
					      hr_dev->caps.sccc_sz,
					      hr_dev->caps.sccc_sz,
					      hr_dev->caps.num_qps, 1);
					      hr_dev->caps.num_qps);
		if (ret) {
		if (ret) {
			dev_err(dev,
			dev_err(dev,
				"Failed to init SCC context memory, aborting.\n");
				"Failed to init SCC context memory, aborting.\n");
@@ -734,7 +734,7 @@ static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)
		ret = hns_roce_init_hem_table(hr_dev, &hr_dev->qpc_timer_table,
		ret = hns_roce_init_hem_table(hr_dev, &hr_dev->qpc_timer_table,
					      HEM_TYPE_QPC_TIMER,
					      HEM_TYPE_QPC_TIMER,
					      hr_dev->caps.qpc_timer_entry_sz,
					      hr_dev->caps.qpc_timer_entry_sz,
					      hr_dev->caps.num_qpc_timer, 1);
					      hr_dev->caps.num_qpc_timer);
		if (ret) {
		if (ret) {
			dev_err(dev,
			dev_err(dev,
				"Failed to init QPC timer memory, aborting.\n");
				"Failed to init QPC timer memory, aborting.\n");
@@ -746,7 +746,7 @@ static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)
		ret = hns_roce_init_hem_table(hr_dev, &hr_dev->cqc_timer_table,
		ret = hns_roce_init_hem_table(hr_dev, &hr_dev->cqc_timer_table,
					      HEM_TYPE_CQC_TIMER,
					      HEM_TYPE_CQC_TIMER,
					      hr_dev->caps.cqc_timer_entry_sz,
					      hr_dev->caps.cqc_timer_entry_sz,
					      hr_dev->caps.cqc_timer_bt_num, 1);
					      hr_dev->caps.cqc_timer_bt_num);
		if (ret) {
		if (ret) {
			dev_err(dev,
			dev_err(dev,
				"Failed to init CQC timer memory, aborting.\n");
				"Failed to init CQC timer memory, aborting.\n");
@@ -758,7 +758,7 @@ static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)
		ret = hns_roce_init_hem_table(hr_dev, &hr_dev->gmv_table,
		ret = hns_roce_init_hem_table(hr_dev, &hr_dev->gmv_table,
					      HEM_TYPE_GMV,
					      HEM_TYPE_GMV,
					      hr_dev->caps.gmv_entry_sz,
					      hr_dev->caps.gmv_entry_sz,
					      hr_dev->caps.gmv_entry_num, 1);
					      hr_dev->caps.gmv_entry_num);
		if (ret) {
		if (ret) {
			dev_err(dev,
			dev_err(dev,
				"failed to init gmv table memory, ret = %d\n",
				"failed to init gmv table memory, ret = %d\n",