]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
IB/mlx4: Fill in the access_flags if IB_MR_REREG_ACCESS is not specified
authorJason Gunthorpe <jgg@nvidia.com>
Fri, 5 Jun 2026 11:53:35 +0000 (08:53 -0300)
committerJason Gunthorpe <jgg@nvidia.com>
Tue, 9 Jun 2026 17:57:36 +0000 (14:57 -0300)
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")
Link: https://patch.msgid.link/r/0-v1-29ca7a402625+ddd6-mlx4_rereg_flags_jgg@nvidia.com
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/mlx4/mlx4_ib.h
drivers/infiniband/hw/mlx4/mr.c

index 598954dd0613d344cd66632858d68e28727544be..2b6cc011b25d6733acc75edb84bff1c052485e84 100644 (file)
@@ -136,6 +136,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;
index 027ffb6f79d32ced8759a0c02513f3015429260d..906f09a87704ed6408abf1757de65533b5bdbf0c 100644 (file)
@@ -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;
 
@@ -237,6 +238,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) {
@@ -278,8 +281,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);