]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RDMA/mlx5: Set mkeys for dmabuf at PAGE_SIZE
authorChiara Meiohas <cmeiohas@nvidia.com>
Thu, 13 Jun 2024 18:01:42 +0000 (21:01 +0300)
committerLeon Romanovsky <leon@kernel.org>
Sun, 16 Jun 2024 15:39:29 +0000 (18:39 +0300)
Set the mkey for dmabuf at PAGE_SIZE to support any SGL
after a move operation.

ib_umem_find_best_pgsz returns 0 on error, so it is
incorrect to check the returned page_size against PAGE_SIZE

Fixes: 90da7dc8206a ("RDMA/mlx5: Support dma-buf based userspace memory region")
Signed-off-by: Chiara Meiohas <cmeiohas@nvidia.com>
Reviewed-by: Michael Guralnik <michaelgur@nvidia.com>
Link: https://lore.kernel.org/r/1e2289b9133e89f273a4e68d459057d032cbc2ce.1718301631.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/mlx5/mlx5_ib.h
drivers/infiniband/hw/mlx5/odp.c

index a29102caa1b7146cb94d56cf55c0bc2d094b1622..74a20df8b2923110c45237d34b495d0188e57431 100644 (file)
@@ -115,6 +115,19 @@ unsigned long __mlx5_umem_find_best_quantized_pgoff(
                __mlx5_bit_sz(typ, page_offset_fld), 0, scale,                 \
                page_offset_quantized)
 
+static inline unsigned long
+mlx5_umem_dmabuf_find_best_pgsz(struct ib_umem_dmabuf *umem_dmabuf)
+{
+       /*
+        * mkeys used for dmabuf are fixed at PAGE_SIZE because we must be able
+        * to hold any sgl after a move operation. Ideally the mkc page size
+        * could be changed at runtime to be optimal, but right now the driver
+        * cannot do that.
+        */
+       return ib_umem_find_best_pgsz(&umem_dmabuf->umem, PAGE_SIZE,
+                                     umem_dmabuf->umem.iova);
+}
+
 enum {
        MLX5_IB_MMAP_OFFSET_START = 9,
        MLX5_IB_MMAP_OFFSET_END = 255,
index 4a04cbc5b78a4a3cb220d49c5f0c9a713f61c18c..a524181f34df950f13a3f8e18f0eb6602d5bc11a 100644 (file)
@@ -705,10 +705,8 @@ static int pagefault_dmabuf_mr(struct mlx5_ib_mr *mr, size_t bcnt,
                return err;
        }
 
-       page_size = mlx5_umem_find_best_pgsz(&umem_dmabuf->umem, mkc,
-                                            log_page_size, 0,
-                                            umem_dmabuf->umem.iova);
-       if (unlikely(page_size < PAGE_SIZE)) {
+       page_size = mlx5_umem_dmabuf_find_best_pgsz(umem_dmabuf);
+       if (!page_size) {
                ib_umem_dmabuf_unmap_pages(umem_dmabuf);
                err = -EINVAL;
        } else {