]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RDMA/mlx5: Avoid direct access to DMA device pointer
authorLeon Romanovsky <leonro@nvidia.com>
Sun, 4 Jan 2026 13:51:36 +0000 (15:51 +0200)
committerLeon Romanovsky <leon@kernel.org>
Mon, 5 Jan 2026 09:02:51 +0000 (04:02 -0500)
The dma_device field is marked as internal and must not be accessed by
drivers or ULPs. Remove all direct mlx5 references to this field.

Link: https://patch.msgid.link/20260104-ib-core-misc-v1-4-00367f77f3a8@nvidia.com
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
drivers/infiniband/hw/mlx5/mr.c

index 325fa04cbe8ae36aeec0f5c9b91bf6530807ebdd..a7b37e3df072928e6c8dd88cf3060e0841e7cf1d 100644 (file)
@@ -1646,10 +1646,13 @@ reg_user_mr_dmabuf(struct ib_pd *pd, struct device *dma_device,
                                                 offset, length, fd,
                                                 access_flags,
                                                 &mlx5_ib_dmabuf_attach_ops);
-       else
+       else if (dma_device)
                umem_dmabuf = ib_umem_dmabuf_get_pinned_with_dma_device(&dev->ib_dev,
                                dma_device, offset, length,
                                fd, access_flags);
+       else
+               umem_dmabuf = ib_umem_dmabuf_get_pinned(
+                       &dev->ib_dev, offset, length, fd, access_flags);
 
        if (IS_ERR(umem_dmabuf)) {
                mlx5_ib_dbg(dev, "umem_dmabuf get failed (%pe)\n", umem_dmabuf);
@@ -1782,10 +1785,8 @@ struct ib_mr *mlx5_ib_reg_user_mr_dmabuf(struct ib_pd *pd, u64 offset,
                return reg_user_mr_dmabuf_by_data_direct(pd, offset, length, virt_addr,
                                                         fd, access_flags);
 
-       return reg_user_mr_dmabuf(pd, pd->device->dma_device,
-                                 offset, length, virt_addr,
-                                 fd, access_flags, MLX5_MKC_ACCESS_MODE_MTT,
-                                 dmah);
+       return reg_user_mr_dmabuf(pd, NULL, offset, length, virt_addr, fd,
+                                 access_flags, MLX5_MKC_ACCESS_MODE_MTT, dmah);
 }
 
 /*