linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-next 0/3] Allocate MR cleanups
@ 2020-07-06 12:03 Gal Pressman
  2020-07-06 12:03 ` [PATCH for-next 1/3] RDMA/core: Check for error instead of success in alloc MR function Gal Pressman
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Gal Pressman @ 2020-07-06 12:03 UTC (permalink / raw)
  To: Jason Gunthorpe, Doug Ledford
  Cc: linux-rdma, Selvin Xavier, Devesh Sharma, Somnath Kotur,
	Sriharsha Basavapatna, Potnuri Bharat Teja, Lijun Ou, Weihang Li,
	Faisal Latif, Shiraz Saleem, Yishai Hadas, Leon Romanovsky,
	Michal Kalderon, Ariel Elior, Adit Ranadive, VMware PV-Drivers,
	Dennis Dalessandro, Mike Marciniszyn, Zhu Yanjun,
	Bernard Metzler, Gal Pressman

The allocate MR functionality is limited to kernel users, there is no
reason to pass a redundant udata parameter.
In addition, a small cleanup was added to the MR allocation function to
keep the main flow unindented.

Gal Pressman (3):
  RDMA/core: Check for error instead of success in alloc MR function
  RDMA/core: Remove ib_alloc_mr_user function
  RDMA: Remove the udata parameter from alloc_mr callback

 drivers/infiniband/core/verbs.c               | 36 +++++++++----------
 drivers/infiniband/hw/bnxt_re/ib_verbs.c      |  2 +-
 drivers/infiniband/hw/bnxt_re/ib_verbs.h      |  2 +-
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h        |  2 +-
 drivers/infiniband/hw/cxgb4/mem.c             |  2 +-
 drivers/infiniband/hw/hns/hns_roce_device.h   |  2 +-
 drivers/infiniband/hw/hns/hns_roce_mr.c       |  2 +-
 drivers/infiniband/hw/i40iw/i40iw_verbs.c     |  3 +-
 drivers/infiniband/hw/mlx4/mlx4_ib.h          |  2 +-
 drivers/infiniband/hw/mlx4/mr.c               |  2 +-
 drivers/infiniband/hw/mlx5/mlx5_ib.h          |  2 +-
 drivers/infiniband/hw/mlx5/mr.c               |  2 +-
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c   |  2 +-
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.h   |  2 +-
 drivers/infiniband/hw/qedr/verbs.c            |  2 +-
 drivers/infiniband/hw/qedr/verbs.h            |  2 +-
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_mr.c  |  2 +-
 .../infiniband/hw/vmw_pvrdma/pvrdma_verbs.h   |  2 +-
 drivers/infiniband/sw/rdmavt/mr.c             |  2 +-
 drivers/infiniband/sw/rdmavt/mr.h             |  2 +-
 drivers/infiniband/sw/rxe/rxe_verbs.c         |  2 +-
 drivers/infiniband/sw/siw/siw_verbs.c         |  2 +-
 drivers/infiniband/sw/siw/siw_verbs.h         |  2 +-
 include/rdma/ib_verbs.h                       | 12 ++-----
 24 files changed, 43 insertions(+), 50 deletions(-)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH for-next 1/3] RDMA/core: Check for error instead of success in alloc MR function
  2020-07-06 12:03 [PATCH for-next 0/3] Allocate MR cleanups Gal Pressman
@ 2020-07-06 12:03 ` Gal Pressman
  2020-07-06 12:32   ` Leon Romanovsky
  2020-07-06 12:03 ` [PATCH for-next 2/3] RDMA/core: Remove ib_alloc_mr_user function Gal Pressman
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Gal Pressman @ 2020-07-06 12:03 UTC (permalink / raw)
  To: Jason Gunthorpe, Doug Ledford
  Cc: linux-rdma, Selvin Xavier, Devesh Sharma, Somnath Kotur,
	Sriharsha Basavapatna, Potnuri Bharat Teja, Lijun Ou, Weihang Li,
	Faisal Latif, Shiraz Saleem, Yishai Hadas, Leon Romanovsky,
	Michal Kalderon, Ariel Elior, Adit Ranadive, VMware PV-Drivers,
	Dennis Dalessandro, Mike Marciniszyn, Zhu Yanjun,
	Bernard Metzler, Gal Pressman

The common kernel pattern is to check for error, not success.
Flip the if statement accordingly and keep the main flow unindented.

Signed-off-by: Gal Pressman <galpress@amazon.com>
---
 drivers/infiniband/core/verbs.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 7232e6ec2e91..759de1372c59 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -2133,18 +2133,19 @@ struct ib_mr *ib_alloc_mr_user(struct ib_pd *pd, enum ib_mr_type mr_type,
 	}
 
 	mr = pd->device->ops.alloc_mr(pd, mr_type, max_num_sg, udata);
-	if (!IS_ERR(mr)) {
-		mr->device  = pd->device;
-		mr->pd      = pd;
-		mr->dm      = NULL;
-		mr->uobject = NULL;
-		atomic_inc(&pd->usecnt);
-		mr->need_inval = false;
-		mr->res.type = RDMA_RESTRACK_MR;
-		rdma_restrack_kadd(&mr->res);
-		mr->type = mr_type;
-		mr->sig_attrs = NULL;
-	}
+	if (IS_ERR(mr))
+		goto out;
+
+	mr->device  = pd->device;
+	mr->pd      = pd;
+	mr->dm      = NULL;
+	mr->uobject = NULL;
+	atomic_inc(&pd->usecnt);
+	mr->need_inval = false;
+	mr->res.type = RDMA_RESTRACK_MR;
+	rdma_restrack_kadd(&mr->res);
+	mr->type = mr_type;
+	mr->sig_attrs = NULL;
 
 out:
 	trace_mr_alloc(pd, mr_type, max_num_sg, mr);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH for-next 2/3] RDMA/core: Remove ib_alloc_mr_user function
  2020-07-06 12:03 [PATCH for-next 0/3] Allocate MR cleanups Gal Pressman
  2020-07-06 12:03 ` [PATCH for-next 1/3] RDMA/core: Check for error instead of success in alloc MR function Gal Pressman
@ 2020-07-06 12:03 ` Gal Pressman
  2020-07-06 12:35   ` Leon Romanovsky
  2020-07-06 12:03 ` [PATCH for-next 3/3] RDMA: Remove the udata parameter from alloc_mr callback Gal Pressman
  2020-07-06 22:26 ` [PATCH for-next 0/3] Allocate MR cleanups Jason Gunthorpe
  3 siblings, 1 reply; 8+ messages in thread
From: Gal Pressman @ 2020-07-06 12:03 UTC (permalink / raw)
  To: Jason Gunthorpe, Doug Ledford
  Cc: linux-rdma, Selvin Xavier, Devesh Sharma, Somnath Kotur,
	Sriharsha Basavapatna, Potnuri Bharat Teja, Lijun Ou, Weihang Li,
	Faisal Latif, Shiraz Saleem, Yishai Hadas, Leon Romanovsky,
	Michal Kalderon, Ariel Elior, Adit Ranadive, VMware PV-Drivers,
	Dennis Dalessandro, Mike Marciniszyn, Zhu Yanjun,
	Bernard Metzler, Gal Pressman

Allocating an MR flow can only be initiated by kernel users, and not
from userspace. As a result, the udata parameter is always being passed
as NULL. Rename ib_alloc_mr_user function to ib_alloc_mr and remove the
udata parameter.

Signed-off-by: Gal Pressman <galpress@amazon.com>
---
 drivers/infiniband/core/verbs.c | 11 +++++------
 include/rdma/ib_verbs.h         | 10 ++--------
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 759de1372c59..5242155ced47 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -2104,11 +2104,10 @@ int ib_dereg_mr_user(struct ib_mr *mr, struct ib_udata *udata)
 EXPORT_SYMBOL(ib_dereg_mr_user);
 
 /**
- * ib_alloc_mr_user() - Allocates a memory region
+ * ib_alloc_mr() - Allocates a memory region
  * @pd:            protection domain associated with the region
  * @mr_type:       memory region type
  * @max_num_sg:    maximum sg entries available for registration.
- * @udata:	   user data or null for kernel objects
  *
  * Notes:
  * Memory registeration page/sg lists must not exceed max_num_sg.
@@ -2116,8 +2115,8 @@ EXPORT_SYMBOL(ib_dereg_mr_user);
  * max_num_sg * used_page_size.
  *
  */
-struct ib_mr *ib_alloc_mr_user(struct ib_pd *pd, enum ib_mr_type mr_type,
-			       u32 max_num_sg, struct ib_udata *udata)
+struct ib_mr *ib_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
+			  u32 max_num_sg)
 {
 	struct ib_mr *mr;
 
@@ -2132,7 +2131,7 @@ struct ib_mr *ib_alloc_mr_user(struct ib_pd *pd, enum ib_mr_type mr_type,
 		goto out;
 	}
 
-	mr = pd->device->ops.alloc_mr(pd, mr_type, max_num_sg, udata);
+	mr = pd->device->ops.alloc_mr(pd, mr_type, max_num_sg, NULL);
 	if (IS_ERR(mr))
 		goto out;
 
@@ -2151,7 +2150,7 @@ struct ib_mr *ib_alloc_mr_user(struct ib_pd *pd, enum ib_mr_type mr_type,
 	trace_mr_alloc(pd, mr_type, max_num_sg, mr);
 	return mr;
 }
-EXPORT_SYMBOL(ib_alloc_mr_user);
+EXPORT_SYMBOL(ib_alloc_mr);
 
 /**
  * ib_alloc_mr_integrity() - Allocates an integrity memory region
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 1e902a8f1713..3b53fdc975f6 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -4268,14 +4268,8 @@ static inline int ib_dereg_mr(struct ib_mr *mr)
 	return ib_dereg_mr_user(mr, NULL);
 }
 
-struct ib_mr *ib_alloc_mr_user(struct ib_pd *pd, enum ib_mr_type mr_type,
-			       u32 max_num_sg, struct ib_udata *udata);
-
-static inline struct ib_mr *ib_alloc_mr(struct ib_pd *pd,
-					enum ib_mr_type mr_type, u32 max_num_sg)
-{
-	return ib_alloc_mr_user(pd, mr_type, max_num_sg, NULL);
-}
+struct ib_mr *ib_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
+			  u32 max_num_sg);
 
 struct ib_mr *ib_alloc_mr_integrity(struct ib_pd *pd,
 				    u32 max_num_data_sg,
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH for-next 3/3] RDMA: Remove the udata parameter from alloc_mr callback
  2020-07-06 12:03 [PATCH for-next 0/3] Allocate MR cleanups Gal Pressman
  2020-07-06 12:03 ` [PATCH for-next 1/3] RDMA/core: Check for error instead of success in alloc MR function Gal Pressman
  2020-07-06 12:03 ` [PATCH for-next 2/3] RDMA/core: Remove ib_alloc_mr_user function Gal Pressman
@ 2020-07-06 12:03 ` Gal Pressman
  2020-07-06 12:36   ` Leon Romanovsky
  2020-07-06 22:26 ` [PATCH for-next 0/3] Allocate MR cleanups Jason Gunthorpe
  3 siblings, 1 reply; 8+ messages in thread
From: Gal Pressman @ 2020-07-06 12:03 UTC (permalink / raw)
  To: Jason Gunthorpe, Doug Ledford
  Cc: linux-rdma, Selvin Xavier, Devesh Sharma, Somnath Kotur,
	Sriharsha Basavapatna, Potnuri Bharat Teja, Lijun Ou, Weihang Li,
	Faisal Latif, Shiraz Saleem, Yishai Hadas, Leon Romanovsky,
	Michal Kalderon, Ariel Elior, Adit Ranadive, VMware PV-Drivers,
	Dennis Dalessandro, Mike Marciniszyn, Zhu Yanjun,
	Bernard Metzler, Gal Pressman

Allocating an MR flow can only be initiated by kernel users, and not
from userspace so a udata parameter is redundant.

Signed-off-by: Gal Pressman <galpress@amazon.com>
---
 drivers/infiniband/core/verbs.c                 | 2 +-
 drivers/infiniband/hw/bnxt_re/ib_verbs.c        | 2 +-
 drivers/infiniband/hw/bnxt_re/ib_verbs.h        | 2 +-
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h          | 2 +-
 drivers/infiniband/hw/cxgb4/mem.c               | 2 +-
 drivers/infiniband/hw/hns/hns_roce_device.h     | 2 +-
 drivers/infiniband/hw/hns/hns_roce_mr.c         | 2 +-
 drivers/infiniband/hw/i40iw/i40iw_verbs.c       | 3 +--
 drivers/infiniband/hw/mlx4/mlx4_ib.h            | 2 +-
 drivers/infiniband/hw/mlx4/mr.c                 | 2 +-
 drivers/infiniband/hw/mlx5/mlx5_ib.h            | 2 +-
 drivers/infiniband/hw/mlx5/mr.c                 | 2 +-
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c     | 2 +-
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.h     | 2 +-
 drivers/infiniband/hw/qedr/verbs.c              | 2 +-
 drivers/infiniband/hw/qedr/verbs.h              | 2 +-
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_mr.c    | 2 +-
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h | 2 +-
 drivers/infiniband/sw/rdmavt/mr.c               | 2 +-
 drivers/infiniband/sw/rdmavt/mr.h               | 2 +-
 drivers/infiniband/sw/rxe/rxe_verbs.c           | 2 +-
 drivers/infiniband/sw/siw/siw_verbs.c           | 2 +-
 drivers/infiniband/sw/siw/siw_verbs.h           | 2 +-
 include/rdma/ib_verbs.h                         | 2 +-
 24 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 5242155ced47..26f1de76da99 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -2131,7 +2131,7 @@ struct ib_mr *ib_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
 		goto out;
 	}
 
-	mr = pd->device->ops.alloc_mr(pd, mr_type, max_num_sg, NULL);
+	mr = pd->device->ops.alloc_mr(pd, mr_type, max_num_sg);
 	if (IS_ERR(mr))
 		goto out;
 
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index 8b6ad5cddfce..f32c7e85ae05 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -3569,7 +3569,7 @@ int bnxt_re_map_mr_sg(struct ib_mr *ib_mr, struct scatterlist *sg, int sg_nents,
 }
 
 struct ib_mr *bnxt_re_alloc_mr(struct ib_pd *ib_pd, enum ib_mr_type type,
-			       u32 max_num_sg, struct ib_udata *udata)
+			       u32 max_num_sg)
 {
 	struct bnxt_re_pd *pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd);
 	struct bnxt_re_dev *rdev = pd->rdev;
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.h b/drivers/infiniband/hw/bnxt_re/ib_verbs.h
index e5fbbeba6d28..b4a06b553b04 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.h
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.h
@@ -201,7 +201,7 @@ struct ib_mr *bnxt_re_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
 int bnxt_re_map_mr_sg(struct ib_mr *ib_mr, struct scatterlist *sg, int sg_nents,
 		      unsigned int *sg_offset);
 struct ib_mr *bnxt_re_alloc_mr(struct ib_pd *ib_pd, enum ib_mr_type mr_type,
-			       u32 max_num_sg, struct ib_udata *udata);
+			       u32 max_num_sg);
 int bnxt_re_dereg_mr(struct ib_mr *mr, struct ib_udata *udata);
 struct ib_mw *bnxt_re_alloc_mw(struct ib_pd *ib_pd, enum ib_mw_type type,
 			       struct ib_udata *udata);
diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
index 27da0705c88a..2b2b009b371a 100644
--- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
+++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
@@ -980,7 +980,7 @@ int c4iw_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len);
 void c4iw_qp_add_ref(struct ib_qp *qp);
 void c4iw_qp_rem_ref(struct ib_qp *qp);
 struct ib_mr *c4iw_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-			    u32 max_num_sg, struct ib_udata *udata);
+			    u32 max_num_sg);
 int c4iw_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
 		   unsigned int *sg_offset);
 int c4iw_dealloc_mw(struct ib_mw *mw);
diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
index 962dc97a8ff2..ea6fb2c5b1a7 100644
--- a/drivers/infiniband/hw/cxgb4/mem.c
+++ b/drivers/infiniband/hw/cxgb4/mem.c
@@ -691,7 +691,7 @@ int c4iw_dealloc_mw(struct ib_mw *mw)
 }
 
 struct ib_mr *c4iw_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-			    u32 max_num_sg, struct ib_udata *udata)
+			    u32 max_num_sg)
 {
 	struct c4iw_dev *rhp;
 	struct c4iw_pd *php;
diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
index a61f0c4d4dbb..5b946b5bd586 100644
--- a/drivers/infiniband/hw/hns/hns_roce_device.h
+++ b/drivers/infiniband/hw/hns/hns_roce_device.h
@@ -1191,7 +1191,7 @@ int hns_roce_rereg_user_mr(struct ib_mr *mr, int flags, u64 start, u64 length,
 			   u64 virt_addr, int mr_access_flags, struct ib_pd *pd,
 			   struct ib_udata *udata);
 struct ib_mr *hns_roce_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-				u32 max_num_sg, struct ib_udata *udata);
+				u32 max_num_sg);
 int hns_roce_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
 		       unsigned int *sg_offset);
 int hns_roce_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c
index 4c0bbb12770d..1380cdab5701 100644
--- a/drivers/infiniband/hw/hns/hns_roce_mr.c
+++ b/drivers/infiniband/hw/hns/hns_roce_mr.c
@@ -414,7 +414,7 @@ int hns_roce_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
 }
 
 struct ib_mr *hns_roce_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-				u32 max_num_sg, struct ib_udata *udata)
+				u32 max_num_sg)
 {
 	struct hns_roce_dev *hr_dev = to_hr_dev(pd->device);
 	struct device *dev = hr_dev->dev;
diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
index 19af29a48c55..f9ef3ac2f4cd 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_verbs.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
@@ -1543,10 +1543,9 @@ static int i40iw_hw_alloc_stag(struct i40iw_device *iwdev, struct i40iw_mr *iwmr
  * @pd: ibpd pointer
  * @mr_type: memory for stag registrion
  * @max_num_sg: man number of pages
- * @udata: user data or NULL for kernel objects
  */
 static struct ib_mr *i40iw_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-				    u32 max_num_sg, struct ib_udata *udata)
+				    u32 max_num_sg)
 {
 	struct i40iw_pd *iwpd = to_iwpd(pd);
 	struct i40iw_device *iwdev = to_iwdev(pd->device);
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 6f4ea1067095..38e87a700a2a 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -729,7 +729,7 @@ struct ib_mw *mlx4_ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type,
 			       struct ib_udata *udata);
 int mlx4_ib_dealloc_mw(struct ib_mw *mw);
 struct ib_mr *mlx4_ib_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-			       u32 max_num_sg, struct ib_udata *udata);
+			       u32 max_num_sg);
 int mlx4_ib_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
 		      unsigned int *sg_offset);
 int mlx4_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
index 7e0b205c05eb..6eecedeff2d3 100644
--- a/drivers/infiniband/hw/mlx4/mr.c
+++ b/drivers/infiniband/hw/mlx4/mr.c
@@ -655,7 +655,7 @@ int mlx4_ib_dealloc_mw(struct ib_mw *ibmw)
 }
 
 struct ib_mr *mlx4_ib_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-			       u32 max_num_sg, struct ib_udata *udata)
+			       u32 max_num_sg)
 {
 	struct mlx4_ib_dev *dev = to_mdev(pd->device);
 	struct mlx4_ib_mr *mr;
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index da03d762c6a2..68035a6bb659 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -1205,7 +1205,7 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
 			  struct ib_pd *pd, struct ib_udata *udata);
 int mlx5_ib_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
 struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-			       u32 max_num_sg, struct ib_udata *udata);
+			       u32 max_num_sg);
 struct ib_mr *mlx5_ib_alloc_mr_integrity(struct ib_pd *pd,
 					 u32 max_num_sg,
 					 u32 max_num_meta_sg);
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index 44683073be0c..3e6f2f9c6655 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -1961,7 +1961,7 @@ static struct ib_mr *__mlx5_ib_alloc_mr(struct ib_pd *pd,
 }
 
 struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-			       u32 max_num_sg, struct ib_udata *udata)
+			       u32 max_num_sg)
 {
 	return __mlx5_ib_alloc_mr(pd, mr_type, max_num_sg, 0);
 }
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index d11c74390a12..6cdbec13756a 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -2901,7 +2901,7 @@ int ocrdma_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags cq_flags)
 }
 
 struct ib_mr *ocrdma_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type,
-			      u32 max_num_sg, struct ib_udata *udata)
+			      u32 max_num_sg)
 {
 	int status;
 	struct ocrdma_mr *mr;
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.h b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.h
index 3a5010881be5..df8e3b923a44 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.h
@@ -101,7 +101,7 @@ struct ib_mr *ocrdma_get_dma_mr(struct ib_pd *, int acc);
 struct ib_mr *ocrdma_reg_user_mr(struct ib_pd *, u64 start, u64 length,
 				 u64 virt, int acc, struct ib_udata *);
 struct ib_mr *ocrdma_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-			      u32 max_num_sg, struct ib_udata *udata);
+			      u32 max_num_sg);
 int ocrdma_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
 		     unsigned int *sg_offset);
 
diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
index 9b9e80266367..3d7d5617818f 100644
--- a/drivers/infiniband/hw/qedr/verbs.c
+++ b/drivers/infiniband/hw/qedr/verbs.c
@@ -3003,7 +3003,7 @@ static struct qedr_mr *__qedr_alloc_mr(struct ib_pd *ibpd,
 }
 
 struct ib_mr *qedr_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type,
-			    u32 max_num_sg, struct ib_udata *udata)
+			    u32 max_num_sg)
 {
 	struct qedr_mr *mr;
 
diff --git a/drivers/infiniband/hw/qedr/verbs.h b/drivers/infiniband/hw/qedr/verbs.h
index 5e02387e068d..39dd6286ba39 100644
--- a/drivers/infiniband/hw/qedr/verbs.h
+++ b/drivers/infiniband/hw/qedr/verbs.h
@@ -84,7 +84,7 @@ int qedr_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg,
 		   int sg_nents, unsigned int *sg_offset);
 
 struct ib_mr *qedr_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-			    u32 max_num_sg, struct ib_udata *udata);
+			    u32 max_num_sg);
 int qedr_poll_cq(struct ib_cq *, int num_entries, struct ib_wc *wc);
 int qedr_post_send(struct ib_qp *, const struct ib_send_wr *,
 		   const struct ib_send_wr **bad_wr);
diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_mr.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_mr.c
index b039f1f00e05..77a010e68208 100644
--- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_mr.c
+++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_mr.c
@@ -202,7 +202,7 @@ struct ib_mr *pvrdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
  * @return: ib_mr pointer on success, otherwise returns an errno.
  */
 struct ib_mr *pvrdma_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-			      u32 max_num_sg, struct ib_udata *udata)
+			      u32 max_num_sg)
 {
 	struct pvrdma_dev *dev = to_vdev(pd->device);
 	struct pvrdma_user_mr *mr;
diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h
index 267702226f10..699b20849a7e 100644
--- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h
+++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h
@@ -406,7 +406,7 @@ struct ib_mr *pvrdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
 				 struct ib_udata *udata);
 int pvrdma_dereg_mr(struct ib_mr *mr, struct ib_udata *udata);
 struct ib_mr *pvrdma_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-			      u32 max_num_sg, struct ib_udata *udata);
+			      u32 max_num_sg);
 int pvrdma_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg,
 		     int sg_nents, unsigned int *sg_offset);
 int pvrdma_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
diff --git a/drivers/infiniband/sw/rdmavt/mr.c b/drivers/infiniband/sw/rdmavt/mr.c
index 60864e5ca7cb..2f7c25fea44a 100644
--- a/drivers/infiniband/sw/rdmavt/mr.c
+++ b/drivers/infiniband/sw/rdmavt/mr.c
@@ -576,7 +576,7 @@ int rvt_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
  * Return: the memory region on success, otherwise return an errno.
  */
 struct ib_mr *rvt_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-			   u32 max_num_sg, struct ib_udata *udata)
+			   u32 max_num_sg)
 {
 	struct rvt_mr *mr;
 
diff --git a/drivers/infiniband/sw/rdmavt/mr.h b/drivers/infiniband/sw/rdmavt/mr.h
index 780fc63af98b..b3aba359401b 100644
--- a/drivers/infiniband/sw/rdmavt/mr.h
+++ b/drivers/infiniband/sw/rdmavt/mr.h
@@ -71,7 +71,7 @@ struct ib_mr *rvt_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
 			      struct ib_udata *udata);
 int rvt_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
 struct ib_mr *rvt_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-			   u32 max_num_sg, struct ib_udata *udata);
+			   u32 max_num_sg);
 int rvt_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg,
 		  int sg_nents, unsigned int *sg_offset);
 
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index b8a22af724e8..0472df52d36d 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -975,7 +975,7 @@ static int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
 }
 
 static struct ib_mr *rxe_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type,
-				  u32 max_num_sg, struct ib_udata *udata)
+				  u32 max_num_sg)
 {
 	struct rxe_dev *rxe = to_rdev(ibpd->device);
 	struct rxe_pd *pd = to_rpd(ibpd);
diff --git a/drivers/infiniband/sw/siw/siw_verbs.c b/drivers/infiniband/sw/siw/siw_verbs.c
index 987e2ba05dbc..0d509f7a10a6 100644
--- a/drivers/infiniband/sw/siw/siw_verbs.c
+++ b/drivers/infiniband/sw/siw/siw_verbs.c
@@ -1373,7 +1373,7 @@ struct ib_mr *siw_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,
 }
 
 struct ib_mr *siw_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
-			   u32 max_sge, struct ib_udata *udata)
+			   u32 max_sge)
 {
 	struct siw_device *sdev = to_siw_dev(pd->device);
 	struct siw_mr *mr = NULL;
diff --git a/drivers/infiniband/sw/siw/siw_verbs.h b/drivers/infiniband/sw/siw/siw_verbs.h
index 1a731989fad6..9335c48c01de 100644
--- a/drivers/infiniband/sw/siw/siw_verbs.h
+++ b/drivers/infiniband/sw/siw/siw_verbs.h
@@ -69,7 +69,7 @@ int siw_req_notify_cq(struct ib_cq *base_cq, enum ib_cq_notify_flags flags);
 struct ib_mr *siw_reg_user_mr(struct ib_pd *base_pd, u64 start, u64 len,
 			      u64 rnic_va, int rights, struct ib_udata *udata);
 struct ib_mr *siw_alloc_mr(struct ib_pd *base_pd, enum ib_mr_type mr_type,
-			   u32 max_sge, struct ib_udata *udata);
+			   u32 max_sge);
 struct ib_mr *siw_get_dma_mr(struct ib_pd *base_pd, int rights);
 int siw_map_mr_sg(struct ib_mr *base_mr, struct scatterlist *sl, int num_sle,
 		  unsigned int *sg_off);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 3b53fdc975f6..f80e60fe97ea 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2477,7 +2477,7 @@ struct ib_device_ops {
 			     struct ib_pd *pd, struct ib_udata *udata);
 	int (*dereg_mr)(struct ib_mr *mr, struct ib_udata *udata);
 	struct ib_mr *(*alloc_mr)(struct ib_pd *pd, enum ib_mr_type mr_type,
-				  u32 max_num_sg, struct ib_udata *udata);
+				  u32 max_num_sg);
 	struct ib_mr *(*alloc_mr_integrity)(struct ib_pd *pd,
 					    u32 max_num_data_sg,
 					    u32 max_num_meta_sg);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH for-next 1/3] RDMA/core: Check for error instead of success in alloc MR function
  2020-07-06 12:03 ` [PATCH for-next 1/3] RDMA/core: Check for error instead of success in alloc MR function Gal Pressman
@ 2020-07-06 12:32   ` Leon Romanovsky
  0 siblings, 0 replies; 8+ messages in thread
From: Leon Romanovsky @ 2020-07-06 12:32 UTC (permalink / raw)
  To: Gal Pressman
  Cc: Jason Gunthorpe, Doug Ledford, linux-rdma, Selvin Xavier,
	Devesh Sharma, Somnath Kotur, Sriharsha Basavapatna,
	Potnuri Bharat Teja, Lijun Ou, Weihang Li, Faisal Latif,
	Shiraz Saleem, Yishai Hadas, Michal Kalderon, Ariel Elior,
	Adit Ranadive, VMware PV-Drivers, Dennis Dalessandro,
	Mike Marciniszyn, Zhu Yanjun, Bernard Metzler

On Mon, Jul 06, 2020 at 03:03:41PM +0300, Gal Pressman wrote:
> The common kernel pattern is to check for error, not success.
> Flip the if statement accordingly and keep the main flow unindented.
>
> Signed-off-by: Gal Pressman <galpress@amazon.com>
> ---
>  drivers/infiniband/core/verbs.c | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
>

Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH for-next 2/3] RDMA/core: Remove ib_alloc_mr_user function
  2020-07-06 12:03 ` [PATCH for-next 2/3] RDMA/core: Remove ib_alloc_mr_user function Gal Pressman
@ 2020-07-06 12:35   ` Leon Romanovsky
  0 siblings, 0 replies; 8+ messages in thread
From: Leon Romanovsky @ 2020-07-06 12:35 UTC (permalink / raw)
  To: Gal Pressman
  Cc: Jason Gunthorpe, Doug Ledford, linux-rdma, Selvin Xavier,
	Devesh Sharma, Somnath Kotur, Sriharsha Basavapatna,
	Potnuri Bharat Teja, Lijun Ou, Weihang Li, Faisal Latif,
	Shiraz Saleem, Yishai Hadas, Michal Kalderon, Ariel Elior,
	Adit Ranadive, VMware PV-Drivers, Dennis Dalessandro,
	Mike Marciniszyn, Zhu Yanjun, Bernard Metzler

On Mon, Jul 06, 2020 at 03:03:42PM +0300, Gal Pressman wrote:
> Allocating an MR flow can only be initiated by kernel users, and not
> from userspace. As a result, the udata parameter is always being passed
> as NULL. Rename ib_alloc_mr_user function to ib_alloc_mr and remove the
> udata parameter.
>
> Signed-off-by: Gal Pressman <galpress@amazon.com>
> ---
>  drivers/infiniband/core/verbs.c | 11 +++++------
>  include/rdma/ib_verbs.h         | 10 ++--------
>  2 files changed, 7 insertions(+), 14 deletions(-)
>

Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH for-next 3/3] RDMA: Remove the udata parameter from alloc_mr callback
  2020-07-06 12:03 ` [PATCH for-next 3/3] RDMA: Remove the udata parameter from alloc_mr callback Gal Pressman
@ 2020-07-06 12:36   ` Leon Romanovsky
  0 siblings, 0 replies; 8+ messages in thread
From: Leon Romanovsky @ 2020-07-06 12:36 UTC (permalink / raw)
  To: Gal Pressman
  Cc: Jason Gunthorpe, Doug Ledford, linux-rdma, Selvin Xavier,
	Devesh Sharma, Somnath Kotur, Sriharsha Basavapatna,
	Potnuri Bharat Teja, Lijun Ou, Weihang Li, Faisal Latif,
	Shiraz Saleem, Yishai Hadas, Michal Kalderon, Ariel Elior,
	Adit Ranadive, VMware PV-Drivers, Dennis Dalessandro,
	Mike Marciniszyn, Zhu Yanjun, Bernard Metzler

On Mon, Jul 06, 2020 at 03:03:43PM +0300, Gal Pressman wrote:
> Allocating an MR flow can only be initiated by kernel users, and not
> from userspace so a udata parameter is redundant.
>
> Signed-off-by: Gal Pressman <galpress@amazon.com>
> ---
>  drivers/infiniband/core/verbs.c                 | 2 +-
>  drivers/infiniband/hw/bnxt_re/ib_verbs.c        | 2 +-
>  drivers/infiniband/hw/bnxt_re/ib_verbs.h        | 2 +-
>  drivers/infiniband/hw/cxgb4/iw_cxgb4.h          | 2 +-
>  drivers/infiniband/hw/cxgb4/mem.c               | 2 +-
>  drivers/infiniband/hw/hns/hns_roce_device.h     | 2 +-
>  drivers/infiniband/hw/hns/hns_roce_mr.c         | 2 +-
>  drivers/infiniband/hw/i40iw/i40iw_verbs.c       | 3 +--
>  drivers/infiniband/hw/mlx4/mlx4_ib.h            | 2 +-
>  drivers/infiniband/hw/mlx4/mr.c                 | 2 +-
>  drivers/infiniband/hw/mlx5/mlx5_ib.h            | 2 +-
>  drivers/infiniband/hw/mlx5/mr.c                 | 2 +-
>  drivers/infiniband/hw/ocrdma/ocrdma_verbs.c     | 2 +-
>  drivers/infiniband/hw/ocrdma/ocrdma_verbs.h     | 2 +-
>  drivers/infiniband/hw/qedr/verbs.c              | 2 +-
>  drivers/infiniband/hw/qedr/verbs.h              | 2 +-
>  drivers/infiniband/hw/vmw_pvrdma/pvrdma_mr.c    | 2 +-
>  drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h | 2 +-
>  drivers/infiniband/sw/rdmavt/mr.c               | 2 +-
>  drivers/infiniband/sw/rdmavt/mr.h               | 2 +-
>  drivers/infiniband/sw/rxe/rxe_verbs.c           | 2 +-
>  drivers/infiniband/sw/siw/siw_verbs.c           | 2 +-
>  drivers/infiniband/sw/siw/siw_verbs.h           | 2 +-
>  include/rdma/ib_verbs.h                         | 2 +-
>  24 files changed, 24 insertions(+), 25 deletions(-)

Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH for-next 0/3] Allocate MR cleanups
  2020-07-06 12:03 [PATCH for-next 0/3] Allocate MR cleanups Gal Pressman
                   ` (2 preceding siblings ...)
  2020-07-06 12:03 ` [PATCH for-next 3/3] RDMA: Remove the udata parameter from alloc_mr callback Gal Pressman
@ 2020-07-06 22:26 ` Jason Gunthorpe
  3 siblings, 0 replies; 8+ messages in thread
From: Jason Gunthorpe @ 2020-07-06 22:26 UTC (permalink / raw)
  To: Gal Pressman
  Cc: Doug Ledford, linux-rdma, Selvin Xavier, Devesh Sharma,
	Somnath Kotur, Sriharsha Basavapatna, Potnuri Bharat Teja,
	Lijun Ou, Weihang Li, Faisal Latif, Shiraz Saleem, Yishai Hadas,
	Leon Romanovsky, Michal Kalderon, Ariel Elior, Adit Ranadive,
	VMware PV-Drivers, Dennis Dalessandro, Mike Marciniszyn,
	Zhu Yanjun, Bernard Metzler

On Mon, Jul 06, 2020 at 03:03:40PM +0300, Gal Pressman wrote:
> The allocate MR functionality is limited to kernel users, there is no
> reason to pass a redundant udata parameter.
> In addition, a small cleanup was added to the MR allocation function to
> keep the main flow unindented.
> 
> Gal Pressman (3):
>   RDMA/core: Check for error instead of success in alloc MR function
>   RDMA/core: Remove ib_alloc_mr_user function
>   RDMA: Remove the udata parameter from alloc_mr callback

Applied to for-next, thanks

Jason

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-07-06 22:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-06 12:03 [PATCH for-next 0/3] Allocate MR cleanups Gal Pressman
2020-07-06 12:03 ` [PATCH for-next 1/3] RDMA/core: Check for error instead of success in alloc MR function Gal Pressman
2020-07-06 12:32   ` Leon Romanovsky
2020-07-06 12:03 ` [PATCH for-next 2/3] RDMA/core: Remove ib_alloc_mr_user function Gal Pressman
2020-07-06 12:35   ` Leon Romanovsky
2020-07-06 12:03 ` [PATCH for-next 3/3] RDMA: Remove the udata parameter from alloc_mr callback Gal Pressman
2020-07-06 12:36   ` Leon Romanovsky
2020-07-06 22:26 ` [PATCH for-next 0/3] Allocate MR cleanups Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).