RDMA/odp: Do not leak dma maps when working with huge pages
authorJason Gunthorpe <jgg@mellanox.com>
Fri, 14 Jun 2019 00:46:45 +0000 (21:46 -0300)
committerDoug Ledford <dledford@redhat.com>
Fri, 21 Jun 2019 01:52:47 +0000 (21:52 -0400)
The ib_dma_unmap_page() must match the length of the ib_dma_map_page(),
which is based on odp_shift. Otherwise iommu resources under this API
will not be properly freed.

Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/umem_odp.c

index eb9939d528187b3000dba1032124acb66641eaf9..2a75c6f8d8270e5ca07610684fbe9e5156f72708 100644 (file)
@@ -730,7 +730,8 @@ void ib_umem_odp_unmap_dma_pages(struct ib_umem_odp *umem_odp, u64 virt,
 
                        WARN_ON(!dma_addr);
 
-                       ib_dma_unmap_page(dev, dma_addr, PAGE_SIZE,
+                       ib_dma_unmap_page(dev, dma_addr,
+                                         BIT(umem_odp->page_shift),
                                          DMA_BIDIRECTIONAL);
                        if (dma & ODP_WRITE_ALLOWED_BIT) {
                                struct page *head_page = compound_head(page);