RDMA/umem: Use consistent DMA attributes when unmapping entries
The DMA API expects that mapping and unmapping use the same DMA
attributes. The RDMA umem code did not meet this requirement, so fix
the mismatch.
Fixes: f03d9fadfe ("RDMA/core: Add weak ordering dma attr to dma mapping")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
master
parent
e6fd249178
commit
179b320958
|
|
@ -55,8 +55,7 @@ static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int d
|
||||||
|
|
||||||
if (dirty)
|
if (dirty)
|
||||||
ib_dma_unmap_sgtable_attrs(dev, &umem->sgt_append.sgt,
|
ib_dma_unmap_sgtable_attrs(dev, &umem->sgt_append.sgt,
|
||||||
DMA_BIDIRECTIONAL,
|
DMA_BIDIRECTIONAL, umem->dma_attrs);
|
||||||
DMA_ATTR_REQUIRE_COHERENT);
|
|
||||||
|
|
||||||
for_each_sgtable_sg(&umem->sgt_append.sgt, sg, i) {
|
for_each_sgtable_sg(&umem->sgt_append.sgt, sg, i) {
|
||||||
unpin_user_page_range_dirty_lock(sg_page(sg),
|
unpin_user_page_range_dirty_lock(sg_page(sg),
|
||||||
|
|
@ -170,7 +169,6 @@ struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr,
|
||||||
unsigned long lock_limit;
|
unsigned long lock_limit;
|
||||||
unsigned long new_pinned;
|
unsigned long new_pinned;
|
||||||
unsigned long cur_base;
|
unsigned long cur_base;
|
||||||
unsigned long dma_attr = DMA_ATTR_REQUIRE_COHERENT;
|
|
||||||
struct mm_struct *mm;
|
struct mm_struct *mm;
|
||||||
unsigned long npages;
|
unsigned long npages;
|
||||||
int pinned, ret;
|
int pinned, ret;
|
||||||
|
|
@ -203,6 +201,10 @@ struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr,
|
||||||
umem->iova = addr;
|
umem->iova = addr;
|
||||||
umem->writable = ib_access_writable(access);
|
umem->writable = ib_access_writable(access);
|
||||||
umem->owning_mm = mm = current->mm;
|
umem->owning_mm = mm = current->mm;
|
||||||
|
umem->dma_attrs = DMA_ATTR_REQUIRE_COHERENT;
|
||||||
|
if (access & IB_ACCESS_RELAXED_ORDERING)
|
||||||
|
umem->dma_attrs |= DMA_ATTR_WEAK_ORDERING;
|
||||||
|
|
||||||
mmgrab(mm);
|
mmgrab(mm);
|
||||||
|
|
||||||
page_list = (struct page **) __get_free_page(GFP_KERNEL);
|
page_list = (struct page **) __get_free_page(GFP_KERNEL);
|
||||||
|
|
@ -255,11 +257,8 @@ struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (access & IB_ACCESS_RELAXED_ORDERING)
|
|
||||||
dma_attr |= DMA_ATTR_WEAK_ORDERING;
|
|
||||||
|
|
||||||
ret = ib_dma_map_sgtable_attrs(device, &umem->sgt_append.sgt,
|
ret = ib_dma_map_sgtable_attrs(device, &umem->sgt_append.sgt,
|
||||||
DMA_BIDIRECTIONAL, dma_attr);
|
DMA_BIDIRECTIONAL, umem->dma_attrs);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto umem_release;
|
goto umem_release;
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ struct ib_umem {
|
||||||
u64 iova;
|
u64 iova;
|
||||||
size_t length;
|
size_t length;
|
||||||
unsigned long address;
|
unsigned long address;
|
||||||
|
unsigned long dma_attrs;
|
||||||
u32 writable : 1;
|
u32 writable : 1;
|
||||||
u32 is_odp : 1;
|
u32 is_odp : 1;
|
||||||
u32 is_dmabuf : 1;
|
u32 is_dmabuf : 1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue