]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/mlx5: Create ODP EQ for non-pinned dmabuf MRs
authorJason Gunthorpe <jgg@nvidia.com>
Thu, 4 Jun 2026 01:27:41 +0000 (22:27 -0300)
committerJason Gunthorpe <jgg@nvidia.com>
Mon, 8 Jun 2026 17:32:42 +0000 (14:32 -0300)
DMABUF generally relies on the ODP EQ mechanism to safely implement the
move semantics. ODP requires a device-global one time startup of the ODP
machinery when the first MR is created, and this was missed on the DMABUF
path.

Call mlx5r_odp_create_eq() when creating a ODP'able DMABUF.

The core code prevents using IB_ACCESS_ON_DEMAND unless the driver
advertises IB_ODP_SUPPORT, so until now, mlx5r_odp_create_eq() cannot be
called unless the device has ODP support.

However, DMABUF has no such protection and a second bug was allowing
DMABUFs to be created on non-ODP capable HW. Add a guard at the start of
mlx5r_odp_create_eq(). This is necessary here anyhow as the
dev->odp_eq_mutex is not initialized without IB_ODP_SUPPORT.

Link: https://patch.msgid.link/r/2-v1-29ebd2c229b5+fd5-ib_mr_pd_jgg@nvidia.com
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/mlx5/mr.c
drivers/infiniband/hw/mlx5/odp.c

index 0fa0a57240c01d85650c0c5b21fa9038cdb92f85..e75a3aa3e2782a2f68860f6c57beeb17c95b0dbb 100644 (file)
@@ -956,6 +956,10 @@ reg_user_mr_dmabuf(struct ib_pd *pd, struct device *dma_device,
        atomic_add(ib_umem_num_pages(mr->umem), &dev->mdev->priv.reg_pages);
        umem_dmabuf->private = mr;
        if (!pinned_mode) {
+               err = mlx5r_odp_create_eq(dev, &dev->odp_pf_eq);
+               if (err)
+                       goto err_dereg_mr;
+
                err = mlx5r_store_odp_mkey(dev, &mr->mmkey);
                if (err)
                        goto err_dereg_mr;
index 1119ce163ea7835f4da271a3bea7bc73d44d07b6..10c11b72f412476e3d7fe656ad0131270d9c78b5 100644 (file)
@@ -1807,6 +1807,9 @@ int mlx5r_odp_create_eq(struct mlx5_ib_dev *dev, struct mlx5_ib_pf_eq *eq)
        struct mlx5_eq_param param = {};
        int err = 0;
 
+       if (!(dev->odp_caps.general_caps & IB_ODP_SUPPORT))
+               return -EOPNOTSUPP;
+
        mutex_lock(&dev->odp_eq_mutex);
        if (eq->core)
                goto unlock;