Skip to content

Commit 04ea87d

Browse files
rleongregkh
authored andcommitted
RDMA/umem: Use consistent DMA attributes when unmapping entries
[ Upstream commit 179b320 ] 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: f03d9fa ("RDMA/core: Add weak ordering dma attr to dma mapping") Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d2b29f3 commit 04ea87d

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/infiniband/core/umem.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int d
5555

5656
if (dirty)
5757
ib_dma_unmap_sgtable_attrs(dev, &umem->sgt_append.sgt,
58-
DMA_BIDIRECTIONAL,
59-
DMA_ATTR_REQUIRE_COHERENT);
58+
DMA_BIDIRECTIONAL, umem->dma_attrs);
6059

6160
for_each_sgtable_sg(&umem->sgt_append.sgt, sg, i) {
6261
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,
170169
unsigned long lock_limit;
171170
unsigned long new_pinned;
172171
unsigned long cur_base;
173-
unsigned long dma_attr = DMA_ATTR_REQUIRE_COHERENT;
174172
struct mm_struct *mm;
175173
unsigned long npages;
176174
int pinned, ret;
@@ -203,6 +201,10 @@ struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr,
203201
umem->iova = addr;
204202
umem->writable = ib_access_writable(access);
205203
umem->owning_mm = mm = current->mm;
204+
umem->dma_attrs = DMA_ATTR_REQUIRE_COHERENT;
205+
if (access & IB_ACCESS_RELAXED_ORDERING)
206+
umem->dma_attrs |= DMA_ATTR_WEAK_ORDERING;
207+
206208
mmgrab(mm);
207209

208210
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,
255257
}
256258
}
257259

258-
if (access & IB_ACCESS_RELAXED_ORDERING)
259-
dma_attr |= DMA_ATTR_WEAK_ORDERING;
260-
261260
ret = ib_dma_map_sgtable_attrs(device, &umem->sgt_append.sgt,
262-
DMA_BIDIRECTIONAL, dma_attr);
261+
DMA_BIDIRECTIONAL, umem->dma_attrs);
263262
if (ret)
264263
goto umem_release;
265264
goto out;

include/rdma/ib_umem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct ib_umem {
2222
u64 iova;
2323
size_t length;
2424
unsigned long address;
25+
unsigned long dma_attrs;
2526
u32 writable : 1;
2627
u32 is_odp : 1;
2728
u32 is_dmabuf : 1;

0 commit comments

Comments
 (0)