RDMA/mlx5: Use rdma_user_map_io for mapping BAR pages [Linux 5.1]

RDMA/mlx5: Use rdma_user_map_io for mapping BAR pages [Linux 5.1]

This Linux kernel change "RDMA/mlx5: Use rdma_user_map_io for mapping BAR pages" is included in the Linux 5.1 release. This change is authored by Jason Gunthorpe <jgg [at] mellanox.com> on Tue Apr 16 14:07:26 2019 +0300. The commit for this change in Linux stable tree is d5e560d (patch).

RDMA/mlx5: Use rdma_user_map_io for mapping BAR pages

Since mlx5 supports device disassociate it must use this API for all
BAR page mmaps, otherwise the pages can remain mapped after the device
is unplugged causing a system crash.

Cc: stable@vger.kernel.org
Fixes: 5f9794dc94f5 ("RDMA/ucontext: Add a core API for mmaping driver IO memory")
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Reviewed-by: Haggai Eran <haggaie@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>

There are 8 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/infiniband/hw/mlx5/main.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 12a75df..d3dd290 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -2240,14 +2240,12 @@ static int mlx5_ib_mmap(struct ib_ucontext *ibcontext, struct vm_area_struct *vm
        if (PAGE_SIZE > 4096)
            return -EOPNOTSUPP;

-       vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
        pfn = (dev->mdev->iseg_base +
               offsetof(struct mlx5_init_seg, internal_timer_h)) >>
            PAGE_SHIFT;
-       if (io_remap_pfn_range(vma, vma->vm_start, pfn,
-                      PAGE_SIZE, vma->vm_page_prot))
-           return -EAGAIN;
-       break;
+       return rdma_user_mmap_io(&context->ibucontext, vma, pfn,
+                    PAGE_SIZE,
+                    pgprot_noncached(vma->vm_page_prot));
    case MLX5_IB_MMAP_CLOCK_INFO:
        return mlx5_ib_mmap_clock_info_page(dev, vma, context);

Leave a Reply

Your email address will not be published. Required fields are marked *