All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] IB/mlx4: Fill in the access_flags if IB_MR_REREG_ACCESS is not specified
@ 2026-06-05 11:53 Jason Gunthorpe
  2026-06-09 19:00 ` Jason Gunthorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Jason Gunthorpe @ 2026-06-05 11:53 UTC (permalink / raw)
  To: Leon Romanovsky, linux-rdma, Yishai Hadas
  Cc: Matan Barak, Or Gerlitz, patches, Roland Dreier

Sashiko noticed mlx4 was using whatever random access flags were provided
when IB_MR_REREG_ACCESS is not used. Since IB_MR_REREG_TRANS needs
access_flags it used the random ones which means it doesn't work sensibly
if userspace provides only IB_MR_REREG_TRANS.

Keep track of the current access_flag of the MR and use it if the user
does not specify one.

Also fixup a little confusion around mmr.access, it is the HW access flags
so the convert_access() was missing. But nothing reads this by the time
rereg_mr can happen.

Fixes: 9376932d0c26 ("IB/mlx4_ib: Add support for user MR re-registration")
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/infiniband/hw/mlx4/mlx4_ib.h | 1 +
 drivers/infiniband/hw/mlx4/mr.c      | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

Sashiko also noticed the error unwinds are broken too, but properly fixing
that that requires switching to use the new mr replacement rereg flow which is
not worth doing for this ancient driver.

diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 5a799d6df93ebc..898c8363422abb 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -135,6 +135,7 @@ struct mlx4_ib_mr {
 	dma_addr_t		page_map;
 	u32			npages;
 	u32			max_pages;
+	int			access_flags;
 	struct mlx4_mr		mmr;
 	struct ib_umem	       *umem;
 	size_t			page_map_size;
diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
index 306704f54325cf..de076b176b0ec8 100644
--- a/drivers/infiniband/hw/mlx4/mr.c
+++ b/drivers/infiniband/hw/mlx4/mr.c
@@ -181,6 +181,7 @@ struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
 	if (err)
 		goto err_mr;
 
+	mr->access_flags = access_flags;
 	mr->ibmr.rkey = mr->ibmr.lkey = mr->mmr.key;
 	mr->ibmr.page_size = 1U << shift;
 
@@ -235,6 +236,8 @@ struct ib_mr *mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags, u64 start,
 
 		if (err)
 			goto release_mpt_entry;
+	} else {
+		mr_access_flags = mmr->access_flags;
 	}
 
 	if (flags & IB_MR_REREG_TRANS) {
@@ -276,8 +279,10 @@ struct ib_mr *mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags, u64 start,
 	 * return a failure. But dereg_mr will free the resources.
 	 */
 	err = mlx4_mr_hw_write_mpt(dev->dev, &mmr->mmr, pmpt_entry);
-	if (!err && flags & IB_MR_REREG_ACCESS)
-		mmr->mmr.access = mr_access_flags;
+	if (!err && flags & IB_MR_REREG_ACCESS) {
+		mmr->access_flags = mr_access_flags;
+		mmr->mmr.access = convert_access(mr_access_flags);
+	}
 
 release_mpt_entry:
 	mlx4_mr_hw_put_mpt(dev->dev, pmpt_entry);

base-commit: 8f064f2e2bd23f84dbfba26b83e08d5de7311d44
-- 
2.43.0


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

* Re: [PATCH] IB/mlx4: Fill in the access_flags if IB_MR_REREG_ACCESS is not specified
  2026-06-05 11:53 [PATCH] IB/mlx4: Fill in the access_flags if IB_MR_REREG_ACCESS is not specified Jason Gunthorpe
@ 2026-06-09 19:00 ` Jason Gunthorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2026-06-09 19:00 UTC (permalink / raw)
  To: Leon Romanovsky, linux-rdma, Yishai Hadas
  Cc: Matan Barak, Or Gerlitz, patches, Roland Dreier

On Fri, Jun 05, 2026 at 08:53:35AM -0300, Jason Gunthorpe wrote:
> Sashiko noticed mlx4 was using whatever random access flags were provided
> when IB_MR_REREG_ACCESS is not used. Since IB_MR_REREG_TRANS needs
> access_flags it used the random ones which means it doesn't work sensibly
> if userspace provides only IB_MR_REREG_TRANS.
> 
> Keep track of the current access_flag of the MR and use it if the user
> does not specify one.
> 
> Also fixup a little confusion around mmr.access, it is the HW access flags
> so the convert_access() was missing. But nothing reads this by the time
> rereg_mr can happen.
> 
> Fixes: 9376932d0c26 ("IB/mlx4_ib: Add support for user MR re-registration")
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
>  drivers/infiniband/hw/mlx4/mlx4_ib.h | 1 +
>  drivers/infiniband/hw/mlx4/mr.c      | 9 +++++++--
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> Sashiko also noticed the error unwinds are broken too, but properly fixing
> that that requires switching to use the new mr replacement rereg flow which is
> not worth doing for this ancient driver.

Applied to for-next

Jason

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

end of thread, other threads:[~2026-06-09 19:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-05 11:53 [PATCH] IB/mlx4: Fill in the access_flags if IB_MR_REREG_ACCESS is not specified Jason Gunthorpe
2026-06-09 19:00 ` Jason Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.