Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH rdma-next v2 0/3] Rewrite mlx3 mkeys logic
@ 2024-04-03 10:35 Leon Romanovsky
  2024-04-03 10:35 ` [PATCH rdma-next v2 1/3] RDMA/mlx5: Uncacheable mkey has neither rb_key or cache_ent Leon Romanovsky
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Leon Romanovsky @ 2024-04-03 10:35 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Leon Romanovsky, linux-rdma, Michael Guralnik, Or Har-Toov

From: Leon Romanovsky <leonro@nvidia.com>

This is rewrote version of [1].

[1] https://lore.kernel.org/all/cover.1706433934.git.leon@kernel.org

Thanks

Or Har-Toov (3):
  RDMA/mlx5: Uncacheable mkey has neither rb_key or cache_ent
  RDMA/mlx5: Change check for cacheable mkeys
  RDMA/mlx5: Adding remote atomic access flag to updatable flags

 drivers/infiniband/hw/mlx5/mlx5_ib.h |  3 ++-
 drivers/infiniband/hw/mlx5/mr.c      | 35 +++++++++++++++++++---------
 2 files changed, 26 insertions(+), 12 deletions(-)

-- 
2.44.0


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

* [PATCH rdma-next v2 1/3] RDMA/mlx5: Uncacheable mkey has neither rb_key or cache_ent
  2024-04-03 10:35 [PATCH rdma-next v2 0/3] Rewrite mlx3 mkeys logic Leon Romanovsky
@ 2024-04-03 10:35 ` Leon Romanovsky
  2024-04-03 10:36 ` [PATCH rdma-next v2 2/3] RDMA/mlx5: Change check for cacheable mkeys Leon Romanovsky
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2024-04-03 10:35 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Or Har-Toov, linux-rdma, Michael Guralnik

From: Or Har-Toov <ohartoov@nvidia.com>

As some mkeys can't be modified with UMR due to some UMR limitations,
like the size of translation that can be updated, not all user mkeys can
be cached.

Fixes: dd1b913fb0d0 ("RDMA/mlx5: Cache all user cacheable mkeys on dereg MR flow")
Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/mlx5/mlx5_ib.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index a8de35c07c9e..e74f04865062 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -643,7 +643,7 @@ struct mlx5_ib_mkey {
 	unsigned int ndescs;
 	struct wait_queue_head wait;
 	refcount_t usecount;
-	/* User Mkey must hold either a rb_key or a cache_ent. */
+	/* Cacheable user Mkey must hold either a rb_key or a cache_ent. */
 	struct mlx5r_cache_rb_key rb_key;
 	struct mlx5_cache_ent *cache_ent;
 };
-- 
2.44.0


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

* [PATCH rdma-next v2 2/3] RDMA/mlx5: Change check for cacheable mkeys
  2024-04-03 10:35 [PATCH rdma-next v2 0/3] Rewrite mlx3 mkeys logic Leon Romanovsky
  2024-04-03 10:35 ` [PATCH rdma-next v2 1/3] RDMA/mlx5: Uncacheable mkey has neither rb_key or cache_ent Leon Romanovsky
@ 2024-04-03 10:36 ` Leon Romanovsky
  2024-04-03 10:36 ` [PATCH rdma-next v2 3/3] RDMA/mlx5: Adding remote atomic access flag to updatable flags Leon Romanovsky
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2024-04-03 10:36 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Or Har-Toov, linux-rdma, Michael Guralnik

From: Or Har-Toov <ohartoov@nvidia.com>

umem can be NULL for user application mkeys in some cases. Therefore
umem can't be used for checking if the mkey is cacheable and it is
changed for checking a flag that indicates it. Also make sure that
all mkeys which are not returned to the cache will be destroyed.

Fixes: dd1b913fb0d0 ("RDMA/mlx5: Cache all user cacheable mkeys on dereg MR flow")
Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/mlx5/mlx5_ib.h |  1 +
 drivers/infiniband/hw/mlx5/mr.c      | 32 +++++++++++++++++++---------
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index e74f04865062..f255a12e26a0 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -646,6 +646,7 @@ struct mlx5_ib_mkey {
 	/* Cacheable user Mkey must hold either a rb_key or a cache_ent. */
 	struct mlx5r_cache_rb_key rb_key;
 	struct mlx5_cache_ent *cache_ent;
+	u8 cacheable : 1;
 };
 
 #define MLX5_IB_MTT_PRESENT (MLX5_IB_MTT_READ | MLX5_IB_MTT_WRITE)
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index a8ee2ca1f4a1..7f7b1f59b5f0 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -1158,6 +1158,7 @@ static struct mlx5_ib_mr *alloc_cacheable_mr(struct ib_pd *pd,
 		if (IS_ERR(mr))
 			return mr;
 		mr->mmkey.rb_key = rb_key;
+		mr->mmkey.cacheable = true;
 		return mr;
 	}
 
@@ -1168,6 +1169,7 @@ static struct mlx5_ib_mr *alloc_cacheable_mr(struct ib_pd *pd,
 	mr->ibmr.pd = pd;
 	mr->umem = umem;
 	mr->page_shift = order_base_2(page_size);
+	mr->mmkey.cacheable = true;
 	set_mr_fields(dev, mr, umem->length, access_flags, iova);
 
 	return mr;
@@ -1835,6 +1837,23 @@ static int cache_ent_find_and_store(struct mlx5_ib_dev *dev,
 	return ret;
 }
 
+static int mlx5_revoke_mr(struct mlx5_ib_mr *mr)
+{
+	struct mlx5_ib_dev *dev = to_mdev(mr->ibmr.device);
+	struct mlx5_cache_ent *ent = mr->mmkey.cache_ent;
+
+	if (mr->mmkey.cacheable && !mlx5r_umr_revoke_mr(mr) && !cache_ent_find_and_store(dev, mr))
+		return 0;
+
+	if (ent) {
+		spin_lock_irq(&ent->mkeys_queue.lock);
+		ent->in_use--;
+		mr->mmkey.cache_ent = NULL;
+		spin_unlock_irq(&ent->mkeys_queue.lock);
+	}
+	return destroy_mkey(dev, mr);
+}
+
 int mlx5_ib_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
 {
 	struct mlx5_ib_mr *mr = to_mmr(ibmr);
@@ -1880,16 +1899,9 @@ int mlx5_ib_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
 	}
 
 	/* Stop DMA */
-	if (mr->umem && mlx5r_umr_can_load_pas(dev, mr->umem->length))
-		if (mlx5r_umr_revoke_mr(mr) ||
-		    cache_ent_find_and_store(dev, mr))
-			mr->mmkey.cache_ent = NULL;
-
-	if (!mr->mmkey.cache_ent) {
-		rc = destroy_mkey(to_mdev(mr->ibmr.device), mr);
-		if (rc)
-			return rc;
-	}
+	rc = mlx5_revoke_mr(mr);
+	if (rc)
+		return rc;
 
 	if (mr->umem) {
 		bool is_odp = is_odp_mr(mr);
-- 
2.44.0


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

* [PATCH rdma-next v2 3/3] RDMA/mlx5: Adding remote atomic access flag to updatable flags
  2024-04-03 10:35 [PATCH rdma-next v2 0/3] Rewrite mlx3 mkeys logic Leon Romanovsky
  2024-04-03 10:35 ` [PATCH rdma-next v2 1/3] RDMA/mlx5: Uncacheable mkey has neither rb_key or cache_ent Leon Romanovsky
  2024-04-03 10:36 ` [PATCH rdma-next v2 2/3] RDMA/mlx5: Change check for cacheable mkeys Leon Romanovsky
@ 2024-04-03 10:36 ` Leon Romanovsky
  2024-04-03 10:44 ` [PATCH rdma-next v2 0/3] Rewrite mlx3 mkeys logic Leon Romanovsky
  2024-04-08 10:35 ` Leon Romanovsky
  4 siblings, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2024-04-03 10:36 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Or Har-Toov, linux-rdma, Michael Guralnik

From: Or Har-Toov <ohartoov@nvidia.com>

Currently IB_ACCESS_REMOTE_ATOMIC is blocked from being updated via UMR
although in some cases it should be possible. These cases are checked in
mlx5r_umr_can_reconfig function.

Fixes: ef3642c4f54d ("RDMA/mlx5: Fix error unwinds for rereg_mr")
Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/mlx5/mr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index 7f7b1f59b5f0..ecc111ed5d86 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -1572,7 +1572,8 @@ static bool can_use_umr_rereg_access(struct mlx5_ib_dev *dev,
 	unsigned int diffs = current_access_flags ^ target_access_flags;
 
 	if (diffs & ~(IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE |
-		      IB_ACCESS_REMOTE_READ | IB_ACCESS_RELAXED_ORDERING))
+		      IB_ACCESS_REMOTE_READ | IB_ACCESS_RELAXED_ORDERING |
+		      IB_ACCESS_REMOTE_ATOMIC))
 		return false;
 	return mlx5r_umr_can_reconfig(dev, current_access_flags,
 				      target_access_flags);
-- 
2.44.0


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

* Re: [PATCH rdma-next v2 0/3] Rewrite mlx3 mkeys logic
  2024-04-03 10:35 [PATCH rdma-next v2 0/3] Rewrite mlx3 mkeys logic Leon Romanovsky
                   ` (2 preceding siblings ...)
  2024-04-03 10:36 ` [PATCH rdma-next v2 3/3] RDMA/mlx5: Adding remote atomic access flag to updatable flags Leon Romanovsky
@ 2024-04-03 10:44 ` Leon Romanovsky
  2024-04-08 10:35 ` Leon Romanovsky
  4 siblings, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2024-04-03 10:44 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: linux-rdma, Michael Guralnik, Or Har-Toov

There is a type in subject, it should be mlx5.

Thanks

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

* Re: [PATCH rdma-next v2 0/3] Rewrite mlx3 mkeys logic
  2024-04-03 10:35 [PATCH rdma-next v2 0/3] Rewrite mlx3 mkeys logic Leon Romanovsky
                   ` (3 preceding siblings ...)
  2024-04-03 10:44 ` [PATCH rdma-next v2 0/3] Rewrite mlx3 mkeys logic Leon Romanovsky
@ 2024-04-08 10:35 ` Leon Romanovsky
  4 siblings, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2024-04-08 10:35 UTC (permalink / raw)
  To: Jason Gunthorpe, Leon Romanovsky
  Cc: linux-rdma, Michael Guralnik, Or Har-Toov, Leon Romanovsky


On Wed, 03 Apr 2024 13:35:58 +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> This is rewrote version of [1].
> 
> [1] https://lore.kernel.org/all/cover.1706433934.git.leon@kernel.org
> 
> Thanks
> 
> [...]

Applied, thanks!

[1/3] RDMA/mlx5: Uncacheable mkey has neither rb_key or cache_ent
      https://git.kernel.org/rdma/rdma/c/0611a8e8b475fc
[2/3] RDMA/mlx5: Change check for cacheable mkeys
      https://git.kernel.org/rdma/rdma/c/8c1185fef68cc6
[3/3] RDMA/mlx5: Adding remote atomic access flag to updatable flags
      https://git.kernel.org/rdma/rdma/c/2ca7e93bc963d9

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>


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

end of thread, other threads:[~2024-04-08 10:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-03 10:35 [PATCH rdma-next v2 0/3] Rewrite mlx3 mkeys logic Leon Romanovsky
2024-04-03 10:35 ` [PATCH rdma-next v2 1/3] RDMA/mlx5: Uncacheable mkey has neither rb_key or cache_ent Leon Romanovsky
2024-04-03 10:36 ` [PATCH rdma-next v2 2/3] RDMA/mlx5: Change check for cacheable mkeys Leon Romanovsky
2024-04-03 10:36 ` [PATCH rdma-next v2 3/3] RDMA/mlx5: Adding remote atomic access flag to updatable flags Leon Romanovsky
2024-04-03 10:44 ` [PATCH rdma-next v2 0/3] Rewrite mlx3 mkeys logic Leon Romanovsky
2024-04-08 10:35 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox