linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH rdma-next 00/10] Relaxed ordering memory regions
@ 2020-01-08 18:05 Yishai Hadas
  2020-01-08 18:05 ` [PATCH rdma-next 01/10] net/mlx5: Expose relaxed ordering bits Yishai Hadas
                   ` (10 more replies)
  0 siblings, 11 replies; 19+ messages in thread
From: Yishai Hadas @ 2020-01-08 18:05 UTC (permalink / raw)
  To: linux-rdma, jgg, dledford; +Cc: saeedm, yishaih, maorg, michaelgur, netdev

This series adds an ioctl command to allocate an async event file followed by a
new ioctl command to get a device context.

The get device context command enables reading some core generic capabilities
such as supporting an optional MR access flags by IB core and its related
drivers.

Once the above is enabled, a new optional MR access flag named
IB_UVERBS_ACCESS_RELAXED_ORDERING is added and is used by mlx5 driver.

This optional flag allows creation of relaxed ordering memory regions.  Access
through such MRs can improve performance by allowing the system to reorder
certain accesses.

As relaxed ordering is an optimization, drivers that do not support it can
simply ignore it.

Note: This series relies on the 'Refactoring FD usage' series [1] that was sent
to rdma-next.
[1] https://patchwork.kernel.org/project/linux-rdma/list/?series=225541

Yishai

Jason Gunthorpe (3):
  RDMA/core: Add UVERBS_METHOD_ASYNC_EVENT_ALLOC
  RDMA/core: Remove ucontext_lock from the uverbs_destry_ufile_hw() path
  RDMA/uverbs: Add ioctl command to get a device context

Michael Guralnik (7):
  net/mlx5: Expose relaxed ordering bits
  RDMA/uverbs: Verify MR access flags
  RDMA/core: Add optional access flags range
  RDMA/efa: Allow passing of optional access flags for MR registration
  RDMA/uverbs: Add new relaxed ordering memory region access flag
  RDMA/core: Add the core support field to METHOD_GET_CONTEXT
  RDMA/mlx5: Set relaxed ordering when requested

 drivers/infiniband/core/rdma_core.c                |  21 +---
 drivers/infiniband/core/uverbs.h                   |   3 +
 drivers/infiniband/core/uverbs_cmd.c               | 133 ++++++++++++---------
 drivers/infiniband/core/uverbs_main.c              |  11 +-
 .../infiniband/core/uverbs_std_types_async_fd.c    |  21 +++-
 drivers/infiniband/core/uverbs_std_types_device.c  |  38 ++++++
 drivers/infiniband/hw/efa/efa_verbs.c              |   1 +
 drivers/infiniband/hw/mlx5/mlx5_ib.h               |   5 +-
 drivers/infiniband/hw/mlx5/mr.c                    |  19 ++-
 drivers/infiniband/hw/mlx5/odp.c                   |   2 +-
 drivers/infiniband/hw/mlx5/qp.c                    |   2 +-
 include/linux/mlx5/mlx5_ifc.h                      |   7 +-
 include/rdma/ib_verbs.h                            |   8 +-
 include/uapi/rdma/ib_user_ioctl_cmds.h             |  14 +++
 include/uapi/rdma/ib_user_ioctl_verbs.h            |  12 ++
 15 files changed, 209 insertions(+), 88 deletions(-)

-- 
1.8.3.1


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

* [PATCH rdma-next 01/10] net/mlx5: Expose relaxed ordering bits
  2020-01-08 18:05 [PATCH rdma-next 00/10] Relaxed ordering memory regions Yishai Hadas
@ 2020-01-08 18:05 ` Yishai Hadas
  2020-01-08 18:05 ` [PATCH rdma-next 02/10] RDMA/core: Add UVERBS_METHOD_ASYNC_EVENT_ALLOC Yishai Hadas
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Yishai Hadas @ 2020-01-08 18:05 UTC (permalink / raw)
  To: linux-rdma, jgg, dledford; +Cc: saeedm, yishaih, maorg, michaelgur, netdev

From: Michael Guralnik <michaelgur@mellanox.com>

Expose relaxed ordering bits in HCA capability and mkey context structs.

Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
---
 include/linux/mlx5/mlx5_ifc.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 5d54fcc..8edcca4 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -1160,7 +1160,8 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8         log_max_cq[0x5];
 
 	u8         log_max_eq_sz[0x8];
-	u8         reserved_at_e8[0x2];
+	u8         relaxed_ordering_write[0x1];
+	u8         relaxed_ordering_read[0x1];
 	u8         log_max_mkey[0x6];
 	u8         reserved_at_f0[0x8];
 	u8         dump_fill_mkey[0x1];
@@ -3271,7 +3272,9 @@ struct mlx5_ifc_mkc_bits {
 
 	u8         translations_octword_size[0x20];
 
-	u8         reserved_at_1c0[0x1b];
+	u8         reserved_at_1c0[0x19];
+	u8         relaxed_ordering_read[0x1];
+	u8         reserved_at_1d9[0x1];
 	u8         log_page_size[0x5];
 
 	u8         reserved_at_1e0[0x20];
-- 
1.8.3.1


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

* [PATCH rdma-next 02/10] RDMA/core: Add UVERBS_METHOD_ASYNC_EVENT_ALLOC
  2020-01-08 18:05 [PATCH rdma-next 00/10] Relaxed ordering memory regions Yishai Hadas
  2020-01-08 18:05 ` [PATCH rdma-next 01/10] net/mlx5: Expose relaxed ordering bits Yishai Hadas
@ 2020-01-08 18:05 ` Yishai Hadas
  2020-01-08 18:05 ` [PATCH rdma-next 03/10] RDMA/core: Remove ucontext_lock from the uverbs_destry_ufile_hw() path Yishai Hadas
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Yishai Hadas @ 2020-01-08 18:05 UTC (permalink / raw)
  To: linux-rdma, jgg, dledford; +Cc: saeedm, yishaih, maorg, michaelgur, netdev

From: Jason Gunthorpe <jgg@mellanox.com>

Allow the async FD to be allocated separately from the context.

This is necessary to introduce the ioctl to create a context, as an ioctl
should only ever create a single uobject at a time.

If multiple async FDs are created then the first one is used to deliver
affiliated events from any ib_uevent_object, with all subsequent ones will
receive only unaffiliated events.

Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
---
 drivers/infiniband/core/uverbs_main.c              |  4 +++-
 .../infiniband/core/uverbs_std_types_async_fd.c    | 23 +++++++++++++++++++++-
 include/uapi/rdma/ib_user_ioctl_cmds.h             |  8 ++++++++
 3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 1f279b0a..fb9e752 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -475,7 +475,9 @@ void ib_uverbs_init_async_event_file(
 
 	ib_uverbs_init_event_queue(&async_file->ev_queue);
 
-	if (!WARN_ON(uverbs_file->async_file)) {
+	/* The first async_event_file becomes the default one for the file. */
+	lockdep_assert_held(&uverbs_file->ucontext_lock);
+	if (!uverbs_file->async_file) {
 		/* Pairs with the put in ib_uverbs_release_file */
 		uverbs_uobject_get(&async_file->uobj);
 		smp_store_release(&uverbs_file->async_file, async_file);
diff --git a/drivers/infiniband/core/uverbs_std_types_async_fd.c b/drivers/infiniband/core/uverbs_std_types_async_fd.c
index 31ff968..484dba1 100644
--- a/drivers/infiniband/core/uverbs_std_types_async_fd.c
+++ b/drivers/infiniband/core/uverbs_std_types_async_fd.c
@@ -8,6 +8,19 @@
 #include "rdma_core.h"
 #include "uverbs.h"
 
+static int UVERBS_HANDLER(UVERBS_METHOD_ASYNC_EVENT_ALLOC)(
+	struct uverbs_attr_bundle *attrs)
+{
+	struct ib_uobject *uobj =
+		uverbs_attr_get_uobject(attrs, UVERBS_METHOD_ASYNC_EVENT_ALLOC);
+
+	mutex_lock(&attrs->ufile->ucontext_lock);
+	ib_uverbs_init_async_event_file(
+		container_of(uobj, struct ib_uverbs_async_event_file, uobj));
+	mutex_unlock(&attrs->ufile->ucontext_lock);
+	return 0;
+}
+
 static int uverbs_async_event_destroy_uobj(struct ib_uobject *uobj,
 					   enum rdma_remove_reason why)
 {
@@ -19,13 +32,21 @@ static int uverbs_async_event_destroy_uobj(struct ib_uobject *uobj,
 	return 0;
 }
 
+DECLARE_UVERBS_NAMED_METHOD(
+	UVERBS_METHOD_ASYNC_EVENT_ALLOC,
+	UVERBS_ATTR_FD(UVERBS_ATTR_ASYNC_EVENT_ALLOC_FD_HANDLE,
+		       UVERBS_OBJECT_ASYNC_EVENT,
+		       UVERBS_ACCESS_NEW,
+		       UA_MANDATORY));
+
 DECLARE_UVERBS_NAMED_OBJECT(
 	UVERBS_OBJECT_ASYNC_EVENT,
 	UVERBS_TYPE_ALLOC_FD(sizeof(struct ib_uverbs_async_event_file),
 			     uverbs_async_event_destroy_uobj,
 			     &uverbs_async_event_fops,
 			     "[infinibandevent]",
-			     O_RDONLY));
+			     O_RDONLY),
+	&UVERBS_METHOD(UVERBS_METHOD_ASYNC_EVENT_ALLOC));
 
 const struct uapi_definition uverbs_def_obj_async_fd[] = {
 	UAPI_DEF_CHAIN_OBJ_TREE_NAMED(UVERBS_OBJECT_ASYNC_EVENT),
diff --git a/include/uapi/rdma/ib_user_ioctl_cmds.h b/include/uapi/rdma/ib_user_ioctl_cmds.h
index 9cfadb5..498955c 100644
--- a/include/uapi/rdma/ib_user_ioctl_cmds.h
+++ b/include/uapi/rdma/ib_user_ioctl_cmds.h
@@ -242,4 +242,12 @@ enum uverbs_attrs_flow_destroy_ids {
 	UVERBS_ATTR_DESTROY_FLOW_HANDLE,
 };
 
+enum uverbs_method_async_event {
+	UVERBS_METHOD_ASYNC_EVENT_ALLOC,
+};
+
+enum uverbs_attrs_async_event_create {
+	UVERBS_ATTR_ASYNC_EVENT_ALLOC_FD_HANDLE,
+};
+
 #endif
-- 
1.8.3.1


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

* [PATCH rdma-next 03/10] RDMA/core: Remove ucontext_lock from the uverbs_destry_ufile_hw() path
  2020-01-08 18:05 [PATCH rdma-next 00/10] Relaxed ordering memory regions Yishai Hadas
  2020-01-08 18:05 ` [PATCH rdma-next 01/10] net/mlx5: Expose relaxed ordering bits Yishai Hadas
  2020-01-08 18:05 ` [PATCH rdma-next 02/10] RDMA/core: Add UVERBS_METHOD_ASYNC_EVENT_ALLOC Yishai Hadas
@ 2020-01-08 18:05 ` Yishai Hadas
  2020-01-08 18:05 ` [PATCH rdma-next 04/10] RDMA/uverbs: Add ioctl command to get a device context Yishai Hadas
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Yishai Hadas @ 2020-01-08 18:05 UTC (permalink / raw)
  To: linux-rdma, jgg, dledford; +Cc: saeedm, yishaih, maorg, michaelgur, netdev

From: Jason Gunthorpe <jgg@mellanox.com>

This lock only serializes ucontext creation. Instead of checking the
ucontext_lock during destruction hold the existing hw_destroy_rwsem
during creation, which is the standard pattern for object creation.

The simplification of locking is needed for the next patch.

Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
---
 drivers/infiniband/core/rdma_core.c  | 21 +--------------------
 drivers/infiniband/core/uverbs_cmd.c |  5 ++++-
 2 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c
index f839b93..58af6a7 100644
--- a/drivers/infiniband/core/rdma_core.c
+++ b/drivers/infiniband/core/rdma_core.c
@@ -863,9 +863,7 @@ static int __uverbs_cleanup_ufile(struct ib_uverbs_file *ufile,
 }
 
 /*
- * Destroy the uncontext and every uobject associated with it. If called with
- * reason != RDMA_REMOVE_CLOSE this will not return until the destruction has
- * been completed and ufile->ucontext is NULL.
+ * Destroy the uncontext and every uobject associated with it.
  *
  * This is internally locked and can be called in parallel from multiple
  * contexts.
@@ -873,22 +871,6 @@ static int __uverbs_cleanup_ufile(struct ib_uverbs_file *ufile,
 void uverbs_destroy_ufile_hw(struct ib_uverbs_file *ufile,
 			     enum rdma_remove_reason reason)
 {
-	if (reason == RDMA_REMOVE_CLOSE) {
-		/*
-		 * During destruction we might trigger something that
-		 * synchronously calls release on any file descriptor. For
-		 * this reason all paths that come from file_operations
-		 * release must use try_lock. They can progress knowing that
-		 * there is an ongoing uverbs_destroy_ufile_hw that will clean
-		 * up the driver resources.
-		 */
-		if (!mutex_trylock(&ufile->ucontext_lock))
-			return;
-
-	} else {
-		mutex_lock(&ufile->ucontext_lock);
-	}
-
 	down_write(&ufile->hw_destroy_rwsem);
 
 	/*
@@ -917,7 +899,6 @@ void uverbs_destroy_ufile_hw(struct ib_uverbs_file *ufile,
 
 done:
 	up_write(&ufile->hw_destroy_rwsem);
-	mutex_unlock(&ufile->ucontext_lock);
 }
 
 const struct uverbs_obj_type_class uverbs_fd_class = {
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 29b1b5a..d71ffe4 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -218,6 +218,8 @@ static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs)
 	if (ret)
 		return ret;
 
+	if (!down_read_trylock(&file->hw_destroy_rwsem))
+		return -EIO;
 	mutex_lock(&file->ucontext_lock);
 	ib_dev = srcu_dereference(file->device->ib_dev,
 				  &file->device->disassociate_srcu);
@@ -284,7 +286,7 @@ static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs)
 	smp_store_release(&file->ucontext, ucontext);
 
 	mutex_unlock(&file->ucontext_lock);
-
+	up_read(&file->hw_destroy_rwsem);
 	return 0;
 
 err_uobj:
@@ -298,6 +300,7 @@ static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs)
 
 err:
 	mutex_unlock(&file->ucontext_lock);
+	up_read(&file->hw_destroy_rwsem);
 	return ret;
 }
 
-- 
1.8.3.1


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

* [PATCH rdma-next 04/10] RDMA/uverbs: Add ioctl command to get a device context
  2020-01-08 18:05 [PATCH rdma-next 00/10] Relaxed ordering memory regions Yishai Hadas
                   ` (2 preceding siblings ...)
  2020-01-08 18:05 ` [PATCH rdma-next 03/10] RDMA/core: Remove ucontext_lock from the uverbs_destry_ufile_hw() path Yishai Hadas
@ 2020-01-08 18:05 ` Yishai Hadas
  2020-01-08 18:05 ` [PATCH rdma-next 05/10] RDMA/uverbs: Verify MR access flags Yishai Hadas
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Yishai Hadas @ 2020-01-08 18:05 UTC (permalink / raw)
  To: linux-rdma, jgg, dledford; +Cc: saeedm, yishaih, maorg, michaelgur, netdev

From: Jason Gunthorpe <jgg@mellanox.com>

Allow future extensions of the get context command through the uverbs
ioctl kabi.

Unlike the uverbs version this does not return an async_fd as well,
that has to be done with another command.

Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
---
 drivers/infiniband/core/uverbs.h                   |   3 +
 drivers/infiniband/core/uverbs_cmd.c               | 132 ++++++++++++---------
 drivers/infiniband/core/uverbs_main.c              |   9 +-
 .../infiniband/core/uverbs_std_types_async_fd.c    |   2 -
 drivers/infiniband/core/uverbs_std_types_device.c  |  30 +++++
 include/uapi/rdma/ib_user_ioctl_cmds.h             |   5 +
 6 files changed, 119 insertions(+), 62 deletions(-)

diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
index aaa5c75..4d4cec4 100644
--- a/drivers/infiniband/core/uverbs.h
+++ b/drivers/infiniband/core/uverbs.h
@@ -220,6 +220,9 @@ struct ib_ucq_object {
 void ib_uverbs_free_event_queue(struct ib_uverbs_event_queue *event_queue);
 void ib_uverbs_flow_resources_free(struct ib_uflow_resources *uflow_res);
 
+int ib_alloc_ucontext(struct uverbs_attr_bundle *attrs);
+int ib_init_ucontext(struct uverbs_attr_bundle *attrs);
+
 void ib_uverbs_release_ucq(struct ib_uverbs_completion_event_file *ev_file,
 			   struct ib_ucq_object *uobj);
 void ib_uverbs_release_uevent(struct ib_uevent_object *uobj);
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index d71ffe4..c8693f5 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -203,104 +203,118 @@ struct ib_udata *uverbs_get_cleared_udata(struct uverbs_attr_bundle *attrs)
 #define ib_uverbs_lookup_comp_file(_fd, _ufile)                                \
 	_ib_uverbs_lookup_comp_file((_fd)*typecheck(s32, _fd), _ufile)
 
-static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs)
+int ib_alloc_ucontext(struct uverbs_attr_bundle *attrs)
 {
-	struct ib_uverbs_file *file = attrs->ufile;
-	struct ib_uverbs_get_context      cmd;
-	struct ib_uverbs_get_context_resp resp;
-	struct ib_ucontext		 *ucontext;
-	struct ib_rdmacg_object		 cg_obj;
+	struct ib_uverbs_file *ufile = attrs->ufile;
+	struct ib_ucontext *ucontext;
 	struct ib_device *ib_dev;
-	struct ib_uobject *uobj;
-	int ret;
 
-	ret = uverbs_request(attrs, &cmd, sizeof(cmd));
-	if (ret)
-		return ret;
+	ib_dev = srcu_dereference(ufile->device->ib_dev,
+				  &ufile->device->disassociate_srcu);
+	if (!ib_dev)
+		return -EIO;
+
+	ucontext = rdma_zalloc_drv_obj(ib_dev, ib_ucontext);
+	if (!ucontext)
+		return -ENOMEM;
+
+	ucontext->res.type = RDMA_RESTRACK_CTX;
+	ucontext->device = ib_dev;
+	ucontext->ufile = ufile;
+	xa_init_flags(&ucontext->mmap_xa, XA_FLAGS_ALLOC);
+	attrs->context = ucontext;
+	return 0;
+}
+
+int ib_init_ucontext(struct uverbs_attr_bundle *attrs)
+{
+	struct ib_ucontext *ucontext = attrs->context;
+	struct ib_uverbs_file *file = attrs->ufile;
+	int ret;
 
 	if (!down_read_trylock(&file->hw_destroy_rwsem))
 		return -EIO;
 	mutex_lock(&file->ucontext_lock);
-	ib_dev = srcu_dereference(file->device->ib_dev,
-				  &file->device->disassociate_srcu);
-	if (!ib_dev) {
-		ret = -EIO;
-		goto err;
-	}
-
 	if (file->ucontext) {
 		ret = -EINVAL;
 		goto err;
 	}
 
-	ret = ib_rdmacg_try_charge(&cg_obj, ib_dev, RDMACG_RESOURCE_HCA_HANDLE);
+	ret = ib_rdmacg_try_charge(&ucontext->cg_obj, ucontext->device,
+				   RDMACG_RESOURCE_HCA_HANDLE);
 	if (ret)
 		goto err;
 
-	ucontext = rdma_zalloc_drv_obj(ib_dev, ib_ucontext);
-	if (!ucontext) {
-		ret = -ENOMEM;
-		goto err_alloc;
-	}
+	ret = ucontext->device->ops.alloc_ucontext(ucontext,
+						   &attrs->driver_udata);
+	if (ret)
+		goto err_uncharge;
 
-	attrs->context = ucontext;
+	rdma_restrack_uadd(&ucontext->res);
 
-	ucontext->res.type = RDMA_RESTRACK_CTX;
-	ucontext->device = ib_dev;
-	ucontext->cg_obj = cg_obj;
-	/* ufile is required when some objects are released */
-	ucontext->ufile = file;
+	/*
+	 * Make sure that ib_uverbs_get_ucontext() sees the pointer update
+	 * only after all writes to setup the ucontext have completed
+	 */
+	smp_store_release(&file->ucontext, ucontext);
+
+	mutex_unlock(&file->ucontext_lock);
+	up_read(&file->hw_destroy_rwsem);
+	return 0;
 
-	ucontext->closing = false;
-	ucontext->cleanup_retryable = false;
+err_uncharge:
+	ib_rdmacg_uncharge(&ucontext->cg_obj, ucontext->device,
+			   RDMACG_RESOURCE_HCA_HANDLE);
+err:
+	mutex_unlock(&file->ucontext_lock);
+	up_read(&file->hw_destroy_rwsem);
+	return ret;
+}
 
-	xa_init_flags(&ucontext->mmap_xa, XA_FLAGS_ALLOC);
+static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs)
+{
+	struct ib_uverbs_get_context_resp resp;
+	struct ib_uverbs_get_context cmd;
+	struct ib_device *ib_dev;
+	struct ib_uobject *uobj;
+	int ret;
+
+	ret = uverbs_request(attrs, &cmd, sizeof(cmd));
+	if (ret)
+		return ret;
+
+	ret = ib_alloc_ucontext(attrs);
+	if (ret)
+		return ret;
 
 	uobj = uobj_alloc(UVERBS_OBJECT_ASYNC_EVENT, attrs, &ib_dev);
 	if (IS_ERR(uobj)) {
 		ret = PTR_ERR(uobj);
-		goto err_free;
+		goto err_ucontext;
 	}
 
-	resp.async_fd = uobj->id;
-	resp.num_comp_vectors = file->device->num_comp_vectors;
-
+	resp = (struct ib_uverbs_get_context_resp){
+		.num_comp_vectors = attrs->ufile->device->num_comp_vectors,
+		.async_fd = uobj->id,
+	};
 	ret = uverbs_response(attrs, &resp, sizeof(resp));
 	if (ret)
 		goto err_uobj;
 
-	ret = ib_dev->ops.alloc_ucontext(ucontext, &attrs->driver_udata);
+	ret = ib_init_ucontext(attrs);
 	if (ret)
 		goto err_uobj;
 
-	rdma_restrack_uadd(&ucontext->res);
-
 	ib_uverbs_init_async_event_file(
 		container_of(uobj, struct ib_uverbs_async_event_file, uobj));
 	rdma_alloc_commit_uobject(uobj, attrs);
-
-	/*
-	 * Make sure that ib_uverbs_get_ucontext() sees the pointer update
-	 * only after all writes to setup the ucontext have completed
-	 */
-	smp_store_release(&file->ucontext, ucontext);
-
-	mutex_unlock(&file->ucontext_lock);
-	up_read(&file->hw_destroy_rwsem);
 	return 0;
 
 err_uobj:
 	rdma_alloc_abort_uobject(uobj, attrs);
-
-err_free:
-	kfree(ucontext);
-
-err_alloc:
-	ib_rdmacg_uncharge(&cg_obj, ib_dev, RDMACG_RESOURCE_HCA_HANDLE);
-
-err:
-	mutex_unlock(&file->ucontext_lock);
-	up_read(&file->hw_destroy_rwsem);
+err_ucontext:
+	kfree(attrs->context);
+	attrs->context = NULL;
 	return ret;
 }
 
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index fb9e752..2d4083b 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -150,6 +150,9 @@ void ib_uverbs_release_uevent(struct ib_uevent_object *uobj)
 		READ_ONCE(uobj->uobject.ufile->async_file);
 	struct ib_uverbs_event *evt, *tmp;
 
+	if (!async_file)
+		return;
+
 	spin_lock_irq(&async_file->ev_queue.lock);
 	list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) {
 		list_del(&evt->list);
@@ -391,6 +394,9 @@ void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
 	struct ib_uverbs_event *entry;
 	unsigned long flags;
 
+	if (!async_file)
+		return;
+
 	spin_lock_irqsave(&async_file->ev_queue.lock, flags);
 	if (async_file->ev_queue.is_closed) {
 		spin_unlock_irqrestore(&async_file->ev_queue.lock, flags);
@@ -476,12 +482,13 @@ void ib_uverbs_init_async_event_file(
 	ib_uverbs_init_event_queue(&async_file->ev_queue);
 
 	/* The first async_event_file becomes the default one for the file. */
-	lockdep_assert_held(&uverbs_file->ucontext_lock);
+	mutex_lock(&uverbs_file->ucontext_lock);
 	if (!uverbs_file->async_file) {
 		/* Pairs with the put in ib_uverbs_release_file */
 		uverbs_uobject_get(&async_file->uobj);
 		smp_store_release(&uverbs_file->async_file, async_file);
 	}
+	mutex_unlock(&uverbs_file->ucontext_lock);
 
 	INIT_IB_EVENT_HANDLER(&async_file->event_handler, ib_dev,
 			      ib_uverbs_event_handler);
diff --git a/drivers/infiniband/core/uverbs_std_types_async_fd.c b/drivers/infiniband/core/uverbs_std_types_async_fd.c
index 484dba1..82ec080 100644
--- a/drivers/infiniband/core/uverbs_std_types_async_fd.c
+++ b/drivers/infiniband/core/uverbs_std_types_async_fd.c
@@ -14,10 +14,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_ASYNC_EVENT_ALLOC)(
 	struct ib_uobject *uobj =
 		uverbs_attr_get_uobject(attrs, UVERBS_METHOD_ASYNC_EVENT_ALLOC);
 
-	mutex_lock(&attrs->ufile->ucontext_lock);
 	ib_uverbs_init_async_event_file(
 		container_of(uobj, struct ib_uverbs_async_event_file, uobj));
-	mutex_unlock(&attrs->ufile->ucontext_lock);
 	return 0;
 }
 
diff --git a/drivers/infiniband/core/uverbs_std_types_device.c b/drivers/infiniband/core/uverbs_std_types_device.c
index 2a3f2f0..2c59435 100644
--- a/drivers/infiniband/core/uverbs_std_types_device.c
+++ b/drivers/infiniband/core/uverbs_std_types_device.c
@@ -200,6 +200,35 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QUERY_PORT)(
 					     &resp, sizeof(resp));
 }
 
+static int UVERBS_HANDLER(UVERBS_METHOD_GET_CONTEXT)(
+	struct uverbs_attr_bundle *attrs)
+{
+	u32 num_comp = attrs->ufile->device->num_comp_vectors;
+	int ret;
+
+	ret = uverbs_copy_to(attrs, UVERBS_ATTR_GET_CONTEXT_NUM_COMP_VECTORS,
+			     &num_comp, sizeof(num_comp));
+	if (IS_UVERBS_COPY_ERR(ret))
+		return ret;
+
+	ret = ib_alloc_ucontext(attrs);
+	if (ret)
+		return ret;
+	ret = ib_init_ucontext(attrs);
+	if (ret) {
+		kfree(attrs->context);
+		attrs->context = NULL;
+		return ret;
+	}
+	return 0;
+}
+
+DECLARE_UVERBS_NAMED_METHOD(
+	UVERBS_METHOD_GET_CONTEXT,
+	UVERBS_ATTR_PTR_OUT(UVERBS_ATTR_GET_CONTEXT_NUM_COMP_VECTORS,
+			    UVERBS_ATTR_TYPE(u32), UA_OPTIONAL),
+	UVERBS_ATTR_UHW());
+
 DECLARE_UVERBS_NAMED_METHOD(
 	UVERBS_METHOD_INFO_HANDLES,
 	/* Also includes any device specific object ids */
@@ -220,6 +249,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QUERY_PORT)(
 		UA_MANDATORY));
 
 DECLARE_UVERBS_GLOBAL_METHODS(UVERBS_OBJECT_DEVICE,
+			      &UVERBS_METHOD(UVERBS_METHOD_GET_CONTEXT),
 			      &UVERBS_METHOD(UVERBS_METHOD_INVOKE_WRITE),
 			      &UVERBS_METHOD(UVERBS_METHOD_INFO_HANDLES),
 			      &UVERBS_METHOD(UVERBS_METHOD_QUERY_PORT));
diff --git a/include/uapi/rdma/ib_user_ioctl_cmds.h b/include/uapi/rdma/ib_user_ioctl_cmds.h
index 498955c..da6c63c 100644
--- a/include/uapi/rdma/ib_user_ioctl_cmds.h
+++ b/include/uapi/rdma/ib_user_ioctl_cmds.h
@@ -68,6 +68,7 @@ enum uverbs_methods_device {
 	UVERBS_METHOD_INVOKE_WRITE,
 	UVERBS_METHOD_INFO_HANDLES,
 	UVERBS_METHOD_QUERY_PORT,
+	UVERBS_METHOD_GET_CONTEXT,
 };
 
 enum uverbs_attrs_invoke_write_cmd_attr_ids {
@@ -81,6 +82,10 @@ enum uverbs_attrs_query_port_cmd_attr_ids {
 	UVERBS_ATTR_QUERY_PORT_RESP,
 };
 
+enum uverbs_attrs_get_context_attr_ids {
+	UVERBS_ATTR_GET_CONTEXT_NUM_COMP_VECTORS,
+};
+
 enum uverbs_attrs_create_cq_cmd_attr_ids {
 	UVERBS_ATTR_CREATE_CQ_HANDLE,
 	UVERBS_ATTR_CREATE_CQ_CQE,
-- 
1.8.3.1


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

* [PATCH rdma-next 05/10] RDMA/uverbs: Verify MR access flags
  2020-01-08 18:05 [PATCH rdma-next 00/10] Relaxed ordering memory regions Yishai Hadas
                   ` (3 preceding siblings ...)
  2020-01-08 18:05 ` [PATCH rdma-next 04/10] RDMA/uverbs: Add ioctl command to get a device context Yishai Hadas
@ 2020-01-08 18:05 ` Yishai Hadas
  2020-01-08 18:05 ` [PATCH rdma-next 06/10] RDMA/core: Add optional access flags range Yishai Hadas
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Yishai Hadas @ 2020-01-08 18:05 UTC (permalink / raw)
  To: linux-rdma, jgg, dledford; +Cc: saeedm, yishaih, maorg, michaelgur, netdev

From: Michael Guralnik <michaelgur@mellanox.com>

Verify that MR access flags that are passed from user are all supported
ones, otherwise an error is returned.

Fixes: 4fca03778351 ("IB/uverbs: Move ib_access_flags and ib_read_coun..")
Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
---
 include/rdma/ib_verbs.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 08cc7dc..a104e1c 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -4305,6 +4305,9 @@ static inline int ib_check_mr_access(int flags)
 	    !(flags & IB_ACCESS_LOCAL_WRITE))
 		return -EINVAL;
 
+	if (flags & ~IB_ACCESS_SUPPORTED)
+		return -EINVAL;
+
 	return 0;
 }
 
-- 
1.8.3.1


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

* [PATCH rdma-next 06/10] RDMA/core: Add optional access flags range
  2020-01-08 18:05 [PATCH rdma-next 00/10] Relaxed ordering memory regions Yishai Hadas
                   ` (4 preceding siblings ...)
  2020-01-08 18:05 ` [PATCH rdma-next 05/10] RDMA/uverbs: Verify MR access flags Yishai Hadas
@ 2020-01-08 18:05 ` Yishai Hadas
  2020-01-08 18:05 ` [PATCH rdma-next 07/10] RDMA/efa: Allow passing of optional access flags for MR registration Yishai Hadas
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 19+ messages in thread
From: Yishai Hadas @ 2020-01-08 18:05 UTC (permalink / raw)
  To: linux-rdma, jgg, dledford; +Cc: saeedm, yishaih, maorg, michaelgur, netdev

From: Michael Guralnik <michaelgur@mellanox.com>

Define a range of access flags that are defined to be optional, both
uverbs and drivers should enable getting them and use if they are
applicable

This will be used, for example, for the relaxed ordering access flag
which unsupporting drivers can ignore.

Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
---
 include/rdma/ib_verbs.h                 | 4 +++-
 include/uapi/rdma/ib_user_ioctl_verbs.h | 7 +++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index a104e1c..ffb358f 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1419,7 +1419,9 @@ enum ib_access_flags {
 	IB_ACCESS_ON_DEMAND = IB_UVERBS_ACCESS_ON_DEMAND,
 	IB_ACCESS_HUGETLB = IB_UVERBS_ACCESS_HUGETLB,
 
-	IB_ACCESS_SUPPORTED = ((IB_ACCESS_HUGETLB << 1) - 1)
+	IB_ACCESS_OPTIONAL = IB_UVERBS_ACCESS_OPTIONAL_RANGE,
+	IB_ACCESS_SUPPORTED =
+		((IB_ACCESS_HUGETLB << 1) - 1) | IB_ACCESS_OPTIONAL,
 };
 
 /*
diff --git a/include/uapi/rdma/ib_user_ioctl_verbs.h b/include/uapi/rdma/ib_user_ioctl_verbs.h
index 9019b2d..76dbbd9 100644
--- a/include/uapi/rdma/ib_user_ioctl_verbs.h
+++ b/include/uapi/rdma/ib_user_ioctl_verbs.h
@@ -41,6 +41,9 @@
 #define RDMA_UAPI_PTR(_type, _name)	__aligned_u64 _name
 #endif
 
+#define IB_UVERBS_ACCESS_OPTIONAL_FIRST (1 << 20)
+#define IB_UVERBS_ACCESS_OPTIONAL_LAST (1 << 29)
+
 enum ib_uverbs_access_flags {
 	IB_UVERBS_ACCESS_LOCAL_WRITE = 1 << 0,
 	IB_UVERBS_ACCESS_REMOTE_WRITE = 1 << 1,
@@ -50,6 +53,10 @@ enum ib_uverbs_access_flags {
 	IB_UVERBS_ACCESS_ZERO_BASED = 1 << 5,
 	IB_UVERBS_ACCESS_ON_DEMAND = 1 << 6,
 	IB_UVERBS_ACCESS_HUGETLB = 1 << 7,
+
+	IB_UVERBS_ACCESS_OPTIONAL_RANGE =
+		((IB_UVERBS_ACCESS_OPTIONAL_LAST << 1) - 1) &
+		~(IB_UVERBS_ACCESS_OPTIONAL_FIRST - 1)
 };
 
 enum ib_uverbs_query_port_cap_flags {
-- 
1.8.3.1


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

* [PATCH rdma-next 07/10] RDMA/efa: Allow passing of optional access flags for MR registration
  2020-01-08 18:05 [PATCH rdma-next 00/10] Relaxed ordering memory regions Yishai Hadas
                   ` (5 preceding siblings ...)
  2020-01-08 18:05 ` [PATCH rdma-next 06/10] RDMA/core: Add optional access flags range Yishai Hadas
@ 2020-01-08 18:05 ` Yishai Hadas
  2020-01-21 16:37   ` Gal Pressman
  2020-01-08 18:05 ` [PATCH rdma-next 08/10] RDMA/uverbs: Add new relaxed ordering memory region access flag Yishai Hadas
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 19+ messages in thread
From: Yishai Hadas @ 2020-01-08 18:05 UTC (permalink / raw)
  To: linux-rdma, jgg, dledford; +Cc: saeedm, yishaih, maorg, michaelgur, netdev

From: Michael Guralnik <michaelgur@mellanox.com>

As part of adding a range of optional access flags that drivers need to
be able to accept, mask this range inside efa driver.
This will prevent the driver from failing when an access flag from
that range is passed.

Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
---
 drivers/infiniband/hw/efa/efa_verbs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/hw/efa/efa_verbs.c b/drivers/infiniband/hw/efa/efa_verbs.c
index 50c2257..b6b936c 100644
--- a/drivers/infiniband/hw/efa/efa_verbs.c
+++ b/drivers/infiniband/hw/efa/efa_verbs.c
@@ -1370,6 +1370,7 @@ struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start, u64 length,
 		IB_ACCESS_LOCAL_WRITE |
 		(is_rdma_read_cap(dev) ? IB_ACCESS_REMOTE_READ : 0);
 
+	access_flags &= ~IB_UVERBS_ACCESS_OPTIONAL_RANGE;
 	if (access_flags & ~supp_access_flags) {
 		ibdev_dbg(&dev->ibdev,
 			  "Unsupported access flags[%#x], supported[%#x]\n",
-- 
1.8.3.1


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

* [PATCH rdma-next 08/10] RDMA/uverbs: Add new relaxed ordering memory region access flag
  2020-01-08 18:05 [PATCH rdma-next 00/10] Relaxed ordering memory regions Yishai Hadas
                   ` (6 preceding siblings ...)
  2020-01-08 18:05 ` [PATCH rdma-next 07/10] RDMA/efa: Allow passing of optional access flags for MR registration Yishai Hadas
@ 2020-01-08 18:05 ` Yishai Hadas
  2020-01-09  9:38   ` Sergei Shtylyov
  2020-01-15 18:05   ` Jason Gunthorpe
  2020-01-08 18:05 ` [PATCH rdma-next 09/10] RDMA/core: Add the core support field to METHOD_GET_CONTEXT Yishai Hadas
                   ` (2 subsequent siblings)
  10 siblings, 2 replies; 19+ messages in thread
From: Yishai Hadas @ 2020-01-08 18:05 UTC (permalink / raw)
  To: linux-rdma, jgg, dledford; +Cc: saeedm, yishaih, maorg, michaelgur, netdev

From: Michael Guralnik <michaelgur@mellanox.com>

Adding new relaxed ordering access flag for memory regions.
Using memory regions with relaxed ordeing set can enhance performance.

This access flag is handled in a best-effort manner, drivers should
ignore if they don't support setting relaxed ordering.

Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
---
 include/rdma/ib_verbs.h                 | 1 +
 include/uapi/rdma/ib_user_ioctl_verbs.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index ffb358f..2b3c16f 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1418,6 +1418,7 @@ enum ib_access_flags {
 	IB_ZERO_BASED = IB_UVERBS_ACCESS_ZERO_BASED,
 	IB_ACCESS_ON_DEMAND = IB_UVERBS_ACCESS_ON_DEMAND,
 	IB_ACCESS_HUGETLB = IB_UVERBS_ACCESS_HUGETLB,
+	IB_ACCESS_RELAXED_ORDERING = IB_UVERBS_ACCESS_RELAXED_ORDERING,
 
 	IB_ACCESS_OPTIONAL = IB_UVERBS_ACCESS_OPTIONAL_RANGE,
 	IB_ACCESS_SUPPORTED =
diff --git a/include/uapi/rdma/ib_user_ioctl_verbs.h b/include/uapi/rdma/ib_user_ioctl_verbs.h
index 76dbbd9..2a165f4 100644
--- a/include/uapi/rdma/ib_user_ioctl_verbs.h
+++ b/include/uapi/rdma/ib_user_ioctl_verbs.h
@@ -54,6 +54,7 @@ enum ib_uverbs_access_flags {
 	IB_UVERBS_ACCESS_ON_DEMAND = 1 << 6,
 	IB_UVERBS_ACCESS_HUGETLB = 1 << 7,
 
+	IB_UVERBS_ACCESS_RELAXED_ORDERING = IB_UVERBS_ACCESS_OPTIONAL_FIRST,
 	IB_UVERBS_ACCESS_OPTIONAL_RANGE =
 		((IB_UVERBS_ACCESS_OPTIONAL_LAST << 1) - 1) &
 		~(IB_UVERBS_ACCESS_OPTIONAL_FIRST - 1)
-- 
1.8.3.1


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

* [PATCH rdma-next 09/10] RDMA/core: Add the core support field to METHOD_GET_CONTEXT
  2020-01-08 18:05 [PATCH rdma-next 00/10] Relaxed ordering memory regions Yishai Hadas
                   ` (7 preceding siblings ...)
  2020-01-08 18:05 ` [PATCH rdma-next 08/10] RDMA/uverbs: Add new relaxed ordering memory region access flag Yishai Hadas
@ 2020-01-08 18:05 ` Yishai Hadas
  2020-01-08 18:05 ` [PATCH rdma-next 10/10] RDMA/mlx5: Set relaxed ordering when requested Yishai Hadas
  2020-01-15 18:08 ` [PATCH rdma-next 00/10] Relaxed ordering memory regions Jason Gunthorpe
  10 siblings, 0 replies; 19+ messages in thread
From: Yishai Hadas @ 2020-01-08 18:05 UTC (permalink / raw)
  To: linux-rdma, jgg, dledford; +Cc: saeedm, yishaih, maorg, michaelgur, netdev

From: Michael Guralnik <michaelgur@mellanox.com>

Add the core support field to METHOD_GET_CONTEXT, this field should
represent capabilities that are not device-specific.

Return support for optional access flags for memory regions. User-space
will use this capability to mask the optional access flags for
unsupporting kernels.

Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
---
 drivers/infiniband/core/uverbs_std_types_device.c | 8 ++++++++
 include/uapi/rdma/ib_user_ioctl_cmds.h            | 1 +
 include/uapi/rdma/ib_user_ioctl_verbs.h           | 4 ++++
 3 files changed, 13 insertions(+)

diff --git a/drivers/infiniband/core/uverbs_std_types_device.c b/drivers/infiniband/core/uverbs_std_types_device.c
index 2c59435..ae4a59d 100644
--- a/drivers/infiniband/core/uverbs_std_types_device.c
+++ b/drivers/infiniband/core/uverbs_std_types_device.c
@@ -204,6 +204,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_GET_CONTEXT)(
 	struct uverbs_attr_bundle *attrs)
 {
 	u32 num_comp = attrs->ufile->device->num_comp_vectors;
+	u64 core_support = IB_UVERBS_CORE_SUPPORT_OPTIONAL_MR_ACCESS;
 	int ret;
 
 	ret = uverbs_copy_to(attrs, UVERBS_ATTR_GET_CONTEXT_NUM_COMP_VECTORS,
@@ -211,6 +212,11 @@ static int UVERBS_HANDLER(UVERBS_METHOD_GET_CONTEXT)(
 	if (IS_UVERBS_COPY_ERR(ret))
 		return ret;
 
+	ret = uverbs_copy_to(attrs, UVERBS_ATTR_GET_CONTEXT_CORE_SUPPORT,
+			     &core_support, sizeof(core_support));
+	if (IS_UVERBS_COPY_ERR(ret))
+		return ret;
+
 	ret = ib_alloc_ucontext(attrs);
 	if (ret)
 		return ret;
@@ -227,6 +233,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_GET_CONTEXT)(
 	UVERBS_METHOD_GET_CONTEXT,
 	UVERBS_ATTR_PTR_OUT(UVERBS_ATTR_GET_CONTEXT_NUM_COMP_VECTORS,
 			    UVERBS_ATTR_TYPE(u32), UA_OPTIONAL),
+	UVERBS_ATTR_PTR_OUT(UVERBS_ATTR_GET_CONTEXT_CORE_SUPPORT,
+			    UVERBS_ATTR_TYPE(u64), UA_OPTIONAL),
 	UVERBS_ATTR_UHW());
 
 DECLARE_UVERBS_NAMED_METHOD(
diff --git a/include/uapi/rdma/ib_user_ioctl_cmds.h b/include/uapi/rdma/ib_user_ioctl_cmds.h
index da6c63c..d4ddbe4 100644
--- a/include/uapi/rdma/ib_user_ioctl_cmds.h
+++ b/include/uapi/rdma/ib_user_ioctl_cmds.h
@@ -84,6 +84,7 @@ enum uverbs_attrs_query_port_cmd_attr_ids {
 
 enum uverbs_attrs_get_context_attr_ids {
 	UVERBS_ATTR_GET_CONTEXT_NUM_COMP_VECTORS,
+	UVERBS_ATTR_GET_CONTEXT_CORE_SUPPORT,
 };
 
 enum uverbs_attrs_create_cq_cmd_attr_ids {
diff --git a/include/uapi/rdma/ib_user_ioctl_verbs.h b/include/uapi/rdma/ib_user_ioctl_verbs.h
index 2a165f4..a640bb8 100644
--- a/include/uapi/rdma/ib_user_ioctl_verbs.h
+++ b/include/uapi/rdma/ib_user_ioctl_verbs.h
@@ -44,6 +44,10 @@
 #define IB_UVERBS_ACCESS_OPTIONAL_FIRST (1 << 20)
 #define IB_UVERBS_ACCESS_OPTIONAL_LAST (1 << 29)
 
+enum ib_uverbs_core_support {
+	IB_UVERBS_CORE_SUPPORT_OPTIONAL_MR_ACCESS = 1 << 0,
+};
+
 enum ib_uverbs_access_flags {
 	IB_UVERBS_ACCESS_LOCAL_WRITE = 1 << 0,
 	IB_UVERBS_ACCESS_REMOTE_WRITE = 1 << 1,
-- 
1.8.3.1


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

* [PATCH rdma-next 10/10] RDMA/mlx5: Set relaxed ordering when requested
  2020-01-08 18:05 [PATCH rdma-next 00/10] Relaxed ordering memory regions Yishai Hadas
                   ` (8 preceding siblings ...)
  2020-01-08 18:05 ` [PATCH rdma-next 09/10] RDMA/core: Add the core support field to METHOD_GET_CONTEXT Yishai Hadas
@ 2020-01-08 18:05 ` Yishai Hadas
  2020-01-15 18:08 ` [PATCH rdma-next 00/10] Relaxed ordering memory regions Jason Gunthorpe
  10 siblings, 0 replies; 19+ messages in thread
From: Yishai Hadas @ 2020-01-08 18:05 UTC (permalink / raw)
  To: linux-rdma, jgg, dledford; +Cc: saeedm, yishaih, maorg, michaelgur, netdev

From: Michael Guralnik <michaelgur@mellanox.com>

Enable relaxed ordering in mkey context when requested.
As relaxed ordering is not currently supported in UMR, disable UMR usage
for relaxed ordering MRs.

Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
---
 drivers/infiniband/hw/mlx5/mlx5_ib.h |  5 ++++-
 drivers/infiniband/hw/mlx5/mr.c      | 19 +++++++++++++++++--
 drivers/infiniband/hw/mlx5/odp.c     |  2 +-
 drivers/infiniband/hw/mlx5/qp.c      |  2 +-
 4 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index b06f32f..3f0a55c 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -1507,7 +1507,7 @@ int bfregn_to_uar_index(struct mlx5_ib_dev *dev,
 u16 mlx5_ib_get_counters_id(struct mlx5_ib_dev *dev, u8 port_num);
 
 static inline bool mlx5_ib_can_use_umr(struct mlx5_ib_dev *dev,
-				       bool do_modify_atomic)
+				       bool do_modify_atomic, int access_flags)
 {
 	if (MLX5_CAP_GEN(dev->mdev, umr_modify_entity_size_disabled))
 		return false;
@@ -1517,6 +1517,9 @@ static inline bool mlx5_ib_can_use_umr(struct mlx5_ib_dev *dev,
 	    MLX5_CAP_GEN(dev->mdev, umr_modify_atomic_disabled))
 		return false;
 
+	if (access_flags & IB_ACCESS_RELAXED_ORDERING)
+		return false;
+
 	return true;
 }
 
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index ea8bfc3..75b825a 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -661,12 +661,21 @@ int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev)
 static void set_mkc_access_pd_addr_fields(void *mkc, int acc, u64 start_addr,
 					  struct ib_pd *pd)
 {
+	struct mlx5_ib_dev *dev = to_mdev(pd->device);
+
 	MLX5_SET(mkc, mkc, a, !!(acc & IB_ACCESS_REMOTE_ATOMIC));
 	MLX5_SET(mkc, mkc, rw, !!(acc & IB_ACCESS_REMOTE_WRITE));
 	MLX5_SET(mkc, mkc, rr, !!(acc & IB_ACCESS_REMOTE_READ));
 	MLX5_SET(mkc, mkc, lw, !!(acc & IB_ACCESS_LOCAL_WRITE));
 	MLX5_SET(mkc, mkc, lr, 1);
 
+	if (MLX5_CAP_GEN(dev->mdev, relaxed_ordering_write))
+		MLX5_SET(mkc, mkc, relaxed_ordering_write,
+			 !!(acc & IB_ACCESS_RELAXED_ORDERING));
+	if (MLX5_CAP_GEN(dev->mdev, relaxed_ordering_read))
+		MLX5_SET(mkc, mkc, relaxed_ordering_read,
+			 !!(acc & IB_ACCESS_RELAXED_ORDERING));
+
 	MLX5_SET(mkc, mkc, pd, to_mpd(pd)->pdn);
 	MLX5_SET(mkc, mkc, qpn, 0xffffff);
 	MLX5_SET64(mkc, mkc, start_addr, start_addr);
@@ -1075,6 +1084,12 @@ static struct mlx5_ib_mr *reg_create(struct ib_mr *ibmr, struct ib_pd *pd,
 	mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
 	MLX5_SET(mkc, mkc, free, !populate);
 	MLX5_SET(mkc, mkc, access_mode_1_0, MLX5_MKC_ACCESS_MODE_MTT);
+	if (MLX5_CAP_GEN(dev->mdev, relaxed_ordering_write))
+		MLX5_SET(mkc, mkc, relaxed_ordering_write,
+			 !!(access_flags & IB_ACCESS_RELAXED_ORDERING));
+	if (MLX5_CAP_GEN(dev->mdev, relaxed_ordering_read))
+		MLX5_SET(mkc, mkc, relaxed_ordering_read,
+			 !!(access_flags & IB_ACCESS_RELAXED_ORDERING));
 	MLX5_SET(mkc, mkc, a, !!(access_flags & IB_ACCESS_REMOTE_ATOMIC));
 	MLX5_SET(mkc, mkc, rw, !!(access_flags & IB_ACCESS_REMOTE_WRITE));
 	MLX5_SET(mkc, mkc, rr, !!(access_flags & IB_ACCESS_REMOTE_READ));
@@ -1263,7 +1278,7 @@ struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
 	if (err < 0)
 		return ERR_PTR(err);
 
-	use_umr = mlx5_ib_can_use_umr(dev, true);
+	use_umr = mlx5_ib_can_use_umr(dev, true, access_flags);
 
 	if (order <= mr_cache_max_order(dev) && use_umr) {
 		mr = alloc_mr_from_cache(pd, umem, virt_addr, length, ncont,
@@ -1431,7 +1446,7 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
 			goto err;
 	}
 
-	if (!mlx5_ib_can_use_umr(dev, true) ||
+	if (!mlx5_ib_can_use_umr(dev, true, access_flags) ||
 	    (flags & IB_MR_REREG_TRANS && !use_umr_mtt_update(mr, addr, len))) {
 		/*
 		 * UMR can't be used - MKey needs to be replaced.
diff --git a/drivers/infiniband/hw/mlx5/odp.c b/drivers/infiniband/hw/mlx5/odp.c
index f924250..bed81dc 100644
--- a/drivers/infiniband/hw/mlx5/odp.c
+++ b/drivers/infiniband/hw/mlx5/odp.c
@@ -342,7 +342,7 @@ void mlx5_ib_internal_fill_odp_caps(struct mlx5_ib_dev *dev)
 	memset(caps, 0, sizeof(*caps));
 
 	if (!MLX5_CAP_GEN(dev->mdev, pg) ||
-	    !mlx5_ib_can_use_umr(dev, true))
+	    !mlx5_ib_can_use_umr(dev, true, 0))
 		return;
 
 	caps->general_caps = IB_ODP_SUPPORT;
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 7e51870..76e30ad 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -4823,7 +4823,7 @@ static int set_reg_wr(struct mlx5_ib_qp *qp,
 	bool atomic = wr->access & IB_ACCESS_REMOTE_ATOMIC;
 	u8 flags = 0;
 
-	if (!mlx5_ib_can_use_umr(dev, atomic)) {
+	if (!mlx5_ib_can_use_umr(dev, atomic, wr->access)) {
 		mlx5_ib_warn(to_mdev(qp->ibqp.device),
 			     "Fast update of %s for MR is disabled\n",
 			     (MLX5_CAP_GEN(dev->mdev,
-- 
1.8.3.1


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

* Re: [PATCH rdma-next 08/10] RDMA/uverbs: Add new relaxed ordering memory region access flag
  2020-01-08 18:05 ` [PATCH rdma-next 08/10] RDMA/uverbs: Add new relaxed ordering memory region access flag Yishai Hadas
@ 2020-01-09  9:38   ` Sergei Shtylyov
  2020-01-15 18:05   ` Jason Gunthorpe
  1 sibling, 0 replies; 19+ messages in thread
From: Sergei Shtylyov @ 2020-01-09  9:38 UTC (permalink / raw)
  To: Yishai Hadas, linux-rdma, jgg, dledford; +Cc: saeedm, maorg, michaelgur, netdev

On 08.01.2020 21:05, Yishai Hadas wrote:

> From: Michael Guralnik <michaelgur@mellanox.com>
> 
> Adding new relaxed ordering access flag for memory regions.
> Using memory regions with relaxed ordeing set can enhance performance.

   Ordering. :-)

> This access flag is handled in a best-effort manner, drivers should
> ignore if they don't support setting relaxed ordering.
> 
> Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
> Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
[...]

MBR, Sergei

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

* Re: [PATCH rdma-next 08/10] RDMA/uverbs: Add new relaxed ordering memory region access flag
  2020-01-08 18:05 ` [PATCH rdma-next 08/10] RDMA/uverbs: Add new relaxed ordering memory region access flag Yishai Hadas
  2020-01-09  9:38   ` Sergei Shtylyov
@ 2020-01-15 18:05   ` Jason Gunthorpe
  1 sibling, 0 replies; 19+ messages in thread
From: Jason Gunthorpe @ 2020-01-15 18:05 UTC (permalink / raw)
  To: Yishai Hadas; +Cc: linux-rdma, dledford, saeedm, maorg, michaelgur, netdev

On Wed, Jan 08, 2020 at 08:05:38PM +0200, Yishai Hadas wrote:
> From: Michael Guralnik <michaelgur@mellanox.com>
> 
> Adding new relaxed ordering access flag for memory regions.
> Using memory regions with relaxed ordeing set can enhance performance.
> 
> This access flag is handled in a best-effort manner, drivers should
> ignore if they don't support setting relaxed ordering.
> 
> Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
> Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
>  include/rdma/ib_verbs.h                 | 1 +
>  include/uapi/rdma/ib_user_ioctl_verbs.h | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index ffb358f..2b3c16f 100644
> +++ b/include/rdma/ib_verbs.h
> @@ -1418,6 +1418,7 @@ enum ib_access_flags {
>  	IB_ZERO_BASED = IB_UVERBS_ACCESS_ZERO_BASED,
>  	IB_ACCESS_ON_DEMAND = IB_UVERBS_ACCESS_ON_DEMAND,
>  	IB_ACCESS_HUGETLB = IB_UVERBS_ACCESS_HUGETLB,
> +	IB_ACCESS_RELAXED_ORDERING = IB_UVERBS_ACCESS_RELAXED_ORDERING,
>  
>  	IB_ACCESS_OPTIONAL = IB_UVERBS_ACCESS_OPTIONAL_RANGE,
>  	IB_ACCESS_SUPPORTED =
> diff --git a/include/uapi/rdma/ib_user_ioctl_verbs.h b/include/uapi/rdma/ib_user_ioctl_verbs.h
> index 76dbbd9..2a165f4 100644
> +++ b/include/uapi/rdma/ib_user_ioctl_verbs.h
> @@ -54,6 +54,7 @@ enum ib_uverbs_access_flags {
>  	IB_UVERBS_ACCESS_ON_DEMAND = 1 << 6,
>  	IB_UVERBS_ACCESS_HUGETLB = 1 << 7,
>  
> +	IB_UVERBS_ACCESS_RELAXED_ORDERING = IB_UVERBS_ACCESS_OPTIONAL_FIRST,
>  	IB_UVERBS_ACCESS_OPTIONAL_RANGE =
>  		((IB_UVERBS_ACCESS_OPTIONAL_LAST << 1) - 1) &
>  		~(IB_UVERBS_ACCESS_OPTIONAL_FIRST - 1)

I would like to see a followup patch to add the DMA_ATTR_WEAK_ORDERING
setting to ib_umem_get when RELAXED_ORDERING is set.

Jason

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

* Re: [PATCH rdma-next 00/10] Relaxed ordering memory regions
  2020-01-08 18:05 [PATCH rdma-next 00/10] Relaxed ordering memory regions Yishai Hadas
                   ` (9 preceding siblings ...)
  2020-01-08 18:05 ` [PATCH rdma-next 10/10] RDMA/mlx5: Set relaxed ordering when requested Yishai Hadas
@ 2020-01-15 18:08 ` Jason Gunthorpe
  2020-01-16  9:20   ` Leon Romanovsky
  10 siblings, 1 reply; 19+ messages in thread
From: Jason Gunthorpe @ 2020-01-15 18:08 UTC (permalink / raw)
  To: Yishai Hadas; +Cc: linux-rdma, dledford, saeedm, maorg, michaelgur, netdev

On Wed, Jan 08, 2020 at 08:05:30PM +0200, Yishai Hadas wrote:
> This series adds an ioctl command to allocate an async event file followed by a
> new ioctl command to get a device context.
> 
> The get device context command enables reading some core generic capabilities
> such as supporting an optional MR access flags by IB core and its related
> drivers.
> 
> Once the above is enabled, a new optional MR access flag named
> IB_UVERBS_ACCESS_RELAXED_ORDERING is added and is used by mlx5 driver.
> 
> This optional flag allows creation of relaxed ordering memory regions.  Access
> through such MRs can improve performance by allowing the system to reorder
> certain accesses.
> 
> As relaxed ordering is an optimization, drivers that do not support it can
> simply ignore it.
> 
> Note: This series relies on the 'Refactoring FD usage' series [1] that was sent
> to rdma-next.
> [1] https://patchwork.kernel.org/project/linux-rdma/list/?series=225541
> 
> Yishai
> 
> Jason Gunthorpe (3):
>   RDMA/core: Add UVERBS_METHOD_ASYNC_EVENT_ALLOC
>   RDMA/core: Remove ucontext_lock from the uverbs_destry_ufile_hw() path
>   RDMA/uverbs: Add ioctl command to get a device context
> 
> Michael Guralnik (7):
>   net/mlx5: Expose relaxed ordering bits
>   RDMA/uverbs: Verify MR access flags
>   RDMA/core: Add optional access flags range
>   RDMA/efa: Allow passing of optional access flags for MR registration
>   RDMA/uverbs: Add new relaxed ordering memory region access flag
>   RDMA/core: Add the core support field to METHOD_GET_CONTEXT
>   RDMA/mlx5: Set relaxed ordering when requested

This looks OK, can you update the shared branch please

Thanks,
Jason

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

* Re: [PATCH rdma-next 00/10] Relaxed ordering memory regions
  2020-01-15 18:08 ` [PATCH rdma-next 00/10] Relaxed ordering memory regions Jason Gunthorpe
@ 2020-01-16  9:20   ` Leon Romanovsky
  2020-01-16 20:11     ` Jason Gunthorpe
  0 siblings, 1 reply; 19+ messages in thread
From: Leon Romanovsky @ 2020-01-16  9:20 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Yishai Hadas, linux-rdma, dledford, saeedm, maorg, michaelgur, netdev

On Wed, Jan 15, 2020 at 02:08:48PM -0400, Jason Gunthorpe wrote:
> On Wed, Jan 08, 2020 at 08:05:30PM +0200, Yishai Hadas wrote:
> > This series adds an ioctl command to allocate an async event file followed by a
> > new ioctl command to get a device context.
> >
> > The get device context command enables reading some core generic capabilities
> > such as supporting an optional MR access flags by IB core and its related
> > drivers.
> >
> > Once the above is enabled, a new optional MR access flag named
> > IB_UVERBS_ACCESS_RELAXED_ORDERING is added and is used by mlx5 driver.
> >
> > This optional flag allows creation of relaxed ordering memory regions.  Access
> > through such MRs can improve performance by allowing the system to reorder
> > certain accesses.
> >
> > As relaxed ordering is an optimization, drivers that do not support it can
> > simply ignore it.
> >
> > Note: This series relies on the 'Refactoring FD usage' series [1] that was sent
> > to rdma-next.
> > [1] https://patchwork.kernel.org/project/linux-rdma/list/?series=225541
> >
> > Yishai
> >
> > Jason Gunthorpe (3):
> >   RDMA/core: Add UVERBS_METHOD_ASYNC_EVENT_ALLOC
> >   RDMA/core: Remove ucontext_lock from the uverbs_destry_ufile_hw() path
> >   RDMA/uverbs: Add ioctl command to get a device context
> >
> > Michael Guralnik (7):
> >   net/mlx5: Expose relaxed ordering bits
> >   RDMA/uverbs: Verify MR access flags
> >   RDMA/core: Add optional access flags range
> >   RDMA/efa: Allow passing of optional access flags for MR registration
> >   RDMA/uverbs: Add new relaxed ordering memory region access flag
> >   RDMA/core: Add the core support field to METHOD_GET_CONTEXT
> >   RDMA/mlx5: Set relaxed ordering when requested
>
> This looks OK, can you update the shared branch please

Thanks, applied
f4db8e8b0dc3 net/mlx5: Expose relaxed ordering bits

>
> Thanks,
> Jason

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

* Re: [PATCH rdma-next 00/10] Relaxed ordering memory regions
  2020-01-16  9:20   ` Leon Romanovsky
@ 2020-01-16 20:11     ` Jason Gunthorpe
  0 siblings, 0 replies; 19+ messages in thread
From: Jason Gunthorpe @ 2020-01-16 20:11 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Yishai Hadas, linux-rdma, dledford, saeedm, maorg, michaelgur, netdev

On Thu, Jan 16, 2020 at 11:20:08AM +0200, Leon Romanovsky wrote:
> On Wed, Jan 15, 2020 at 02:08:48PM -0400, Jason Gunthorpe wrote:
> > On Wed, Jan 08, 2020 at 08:05:30PM +0200, Yishai Hadas wrote:
> > > This series adds an ioctl command to allocate an async event file followed by a
> > > new ioctl command to get a device context.
> > >
> > > The get device context command enables reading some core generic capabilities
> > > such as supporting an optional MR access flags by IB core and its related
> > > drivers.
> > >
> > > Once the above is enabled, a new optional MR access flag named
> > > IB_UVERBS_ACCESS_RELAXED_ORDERING is added and is used by mlx5 driver.
> > >
> > > This optional flag allows creation of relaxed ordering memory regions.  Access
> > > through such MRs can improve performance by allowing the system to reorder
> > > certain accesses.
> > >
> > > As relaxed ordering is an optimization, drivers that do not support it can
> > > simply ignore it.
> > >
> > > Note: This series relies on the 'Refactoring FD usage' series [1] that was sent
> > > to rdma-next.
> > > [1] https://patchwork.kernel.org/project/linux-rdma/list/?series=225541
> > >
> > > Yishai
> > >
> > > Jason Gunthorpe (3):
> > >   RDMA/core: Add UVERBS_METHOD_ASYNC_EVENT_ALLOC
> > >   RDMA/core: Remove ucontext_lock from the uverbs_destry_ufile_hw() path
> > >   RDMA/uverbs: Add ioctl command to get a device context
> > >
> > > Michael Guralnik (7):
> > >   net/mlx5: Expose relaxed ordering bits
> > >   RDMA/uverbs: Verify MR access flags
> > >   RDMA/core: Add optional access flags range
> > >   RDMA/efa: Allow passing of optional access flags for MR registration
> > >   RDMA/uverbs: Add new relaxed ordering memory region access flag
> > >   RDMA/core: Add the core support field to METHOD_GET_CONTEXT
> > >   RDMA/mlx5: Set relaxed ordering when requested
> >
> > This looks OK, can you update the shared branch please
> 
> Thanks, applied
> f4db8e8b0dc3 net/mlx5: Expose relaxed ordering bits

Okay, applied to for-next

Thanks,
Jason

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

* Re: [PATCH rdma-next 07/10] RDMA/efa: Allow passing of optional access flags for MR registration
  2020-01-08 18:05 ` [PATCH rdma-next 07/10] RDMA/efa: Allow passing of optional access flags for MR registration Yishai Hadas
@ 2020-01-21 16:37   ` Gal Pressman
  2020-01-21 16:57     ` Yishai Hadas
  0 siblings, 1 reply; 19+ messages in thread
From: Gal Pressman @ 2020-01-21 16:37 UTC (permalink / raw)
  To: Yishai Hadas; +Cc: linux-rdma, jgg, dledford, saeedm, maorg, michaelgur, netdev

On 08/01/2020 20:05, Yishai Hadas wrote:
> From: Michael Guralnik <michaelgur@mellanox.com>
> 
> As part of adding a range of optional access flags that drivers need to
> be able to accept, mask this range inside efa driver.
> This will prevent the driver from failing when an access flag from
> that range is passed.
> 
> Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
> Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
> ---
>  drivers/infiniband/hw/efa/efa_verbs.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/infiniband/hw/efa/efa_verbs.c b/drivers/infiniband/hw/efa/efa_verbs.c
> index 50c2257..b6b936c 100644
> --- a/drivers/infiniband/hw/efa/efa_verbs.c
> +++ b/drivers/infiniband/hw/efa/efa_verbs.c
> @@ -1370,6 +1370,7 @@ struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start, u64 length,
>  		IB_ACCESS_LOCAL_WRITE |
>  		(is_rdma_read_cap(dev) ? IB_ACCESS_REMOTE_READ : 0);
>  
> +	access_flags &= ~IB_UVERBS_ACCESS_OPTIONAL_RANGE;

Hi Yishai,
access_flags should be masked with IB_ACCESS_OPTIONAL instead of
IB_UVERBS_ACCESS_OPTIONAL_RANGE.

Also, could you please make sure to CC me to future EFA patches?

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

* Re: [PATCH rdma-next 07/10] RDMA/efa: Allow passing of optional access flags for MR registration
  2020-01-21 16:37   ` Gal Pressman
@ 2020-01-21 16:57     ` Yishai Hadas
  2020-01-22  7:51       ` Gal Pressman
  0 siblings, 1 reply; 19+ messages in thread
From: Yishai Hadas @ 2020-01-21 16:57 UTC (permalink / raw)
  To: Gal Pressman
  Cc: Yishai Hadas, linux-rdma, jgg, dledford, saeedm, maorg,
	michaelgur, netdev

On 1/21/2020 6:37 PM, Gal Pressman wrote:
> On 08/01/2020 20:05, Yishai Hadas wrote:
>> From: Michael Guralnik <michaelgur@mellanox.com>
>>
>> As part of adding a range of optional access flags that drivers need to
>> be able to accept, mask this range inside efa driver.
>> This will prevent the driver from failing when an access flag from
>> that range is passed.
>>
>> Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
>> Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
>> ---
>>   drivers/infiniband/hw/efa/efa_verbs.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/infiniband/hw/efa/efa_verbs.c b/drivers/infiniband/hw/efa/efa_verbs.c
>> index 50c2257..b6b936c 100644
>> --- a/drivers/infiniband/hw/efa/efa_verbs.c
>> +++ b/drivers/infiniband/hw/efa/efa_verbs.c
>> @@ -1370,6 +1370,7 @@ struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start, u64 length,
>>   		IB_ACCESS_LOCAL_WRITE |
>>   		(is_rdma_read_cap(dev) ? IB_ACCESS_REMOTE_READ : 0);
>>   
>> +	access_flags &= ~IB_UVERBS_ACCESS_OPTIONAL_RANGE;
> 
> Hi Yishai,
> access_flags should be masked with IB_ACCESS_OPTIONAL instead of
> IB_UVERBS_ACCESS_OPTIONAL_RANGE.
> 

You are talking from namespace point of view, right ? both have same value.

If it's important, can you send some patch to replace ?

> Also, could you please make sure to CC me to future EFA patches?
> 

Sure, thanks.

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

* Re: [PATCH rdma-next 07/10] RDMA/efa: Allow passing of optional access flags for MR registration
  2020-01-21 16:57     ` Yishai Hadas
@ 2020-01-22  7:51       ` Gal Pressman
  0 siblings, 0 replies; 19+ messages in thread
From: Gal Pressman @ 2020-01-22  7:51 UTC (permalink / raw)
  To: Yishai Hadas
  Cc: Yishai Hadas, linux-rdma, jgg, dledford, saeedm, maorg,
	michaelgur, netdev

On 21/01/2020 18:57, Yishai Hadas wrote:
> On 1/21/2020 6:37 PM, Gal Pressman wrote:
>> On 08/01/2020 20:05, Yishai Hadas wrote:
>>> From: Michael Guralnik <michaelgur@mellanox.com>
>>>
>>> As part of adding a range of optional access flags that drivers need to
>>> be able to accept, mask this range inside efa driver.
>>> This will prevent the driver from failing when an access flag from
>>> that range is passed.
>>>
>>> Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
>>> Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
>>> ---
>>>   drivers/infiniband/hw/efa/efa_verbs.c | 1 +
>>>   1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/infiniband/hw/efa/efa_verbs.c
>>> b/drivers/infiniband/hw/efa/efa_verbs.c
>>> index 50c2257..b6b936c 100644
>>> --- a/drivers/infiniband/hw/efa/efa_verbs.c
>>> +++ b/drivers/infiniband/hw/efa/efa_verbs.c
>>> @@ -1370,6 +1370,7 @@ struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start,
>>> u64 length,
>>>           IB_ACCESS_LOCAL_WRITE |
>>>           (is_rdma_read_cap(dev) ? IB_ACCESS_REMOTE_READ : 0);
>>>   +    access_flags &= ~IB_UVERBS_ACCESS_OPTIONAL_RANGE;
>>
>> Hi Yishai,
>> access_flags should be masked with IB_ACCESS_OPTIONAL instead of
>> IB_UVERBS_ACCESS_OPTIONAL_RANGE.
>>
> 
> You are talking from namespace point of view, right ? both have same value.
> 
> If it's important, can you send some patch to replace ?

I'll send a patch, thanks.

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

end of thread, other threads:[~2020-01-22  7:51 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-08 18:05 [PATCH rdma-next 00/10] Relaxed ordering memory regions Yishai Hadas
2020-01-08 18:05 ` [PATCH rdma-next 01/10] net/mlx5: Expose relaxed ordering bits Yishai Hadas
2020-01-08 18:05 ` [PATCH rdma-next 02/10] RDMA/core: Add UVERBS_METHOD_ASYNC_EVENT_ALLOC Yishai Hadas
2020-01-08 18:05 ` [PATCH rdma-next 03/10] RDMA/core: Remove ucontext_lock from the uverbs_destry_ufile_hw() path Yishai Hadas
2020-01-08 18:05 ` [PATCH rdma-next 04/10] RDMA/uverbs: Add ioctl command to get a device context Yishai Hadas
2020-01-08 18:05 ` [PATCH rdma-next 05/10] RDMA/uverbs: Verify MR access flags Yishai Hadas
2020-01-08 18:05 ` [PATCH rdma-next 06/10] RDMA/core: Add optional access flags range Yishai Hadas
2020-01-08 18:05 ` [PATCH rdma-next 07/10] RDMA/efa: Allow passing of optional access flags for MR registration Yishai Hadas
2020-01-21 16:37   ` Gal Pressman
2020-01-21 16:57     ` Yishai Hadas
2020-01-22  7:51       ` Gal Pressman
2020-01-08 18:05 ` [PATCH rdma-next 08/10] RDMA/uverbs: Add new relaxed ordering memory region access flag Yishai Hadas
2020-01-09  9:38   ` Sergei Shtylyov
2020-01-15 18:05   ` Jason Gunthorpe
2020-01-08 18:05 ` [PATCH rdma-next 09/10] RDMA/core: Add the core support field to METHOD_GET_CONTEXT Yishai Hadas
2020-01-08 18:05 ` [PATCH rdma-next 10/10] RDMA/mlx5: Set relaxed ordering when requested Yishai Hadas
2020-01-15 18:08 ` [PATCH rdma-next 00/10] Relaxed ordering memory regions Jason Gunthorpe
2020-01-16  9:20   ` Leon Romanovsky
2020-01-16 20:11     ` 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).