diff options
Diffstat (limited to 'drivers/infiniband/core/umem.c')
-rw-r--r-- | drivers/infiniband/core/umem.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c index c68746ce6624..224ad274ea0b 100644 --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c | |||
@@ -94,6 +94,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, | |||
94 | unsigned long dma_attrs = 0; | 94 | unsigned long dma_attrs = 0; |
95 | struct scatterlist *sg, *sg_list_start; | 95 | struct scatterlist *sg, *sg_list_start; |
96 | int need_release = 0; | 96 | int need_release = 0; |
97 | unsigned int gup_flags = FOLL_WRITE; | ||
97 | 98 | ||
98 | if (dmasync) | 99 | if (dmasync) |
99 | dma_attrs |= DMA_ATTR_WRITE_BARRIER; | 100 | dma_attrs |= DMA_ATTR_WRITE_BARRIER; |
@@ -183,6 +184,9 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, | |||
183 | if (ret) | 184 | if (ret) |
184 | goto out; | 185 | goto out; |
185 | 186 | ||
187 | if (!umem->writable) | ||
188 | gup_flags |= FOLL_FORCE; | ||
189 | |||
186 | need_release = 1; | 190 | need_release = 1; |
187 | sg_list_start = umem->sg_head.sgl; | 191 | sg_list_start = umem->sg_head.sgl; |
188 | 192 | ||
@@ -190,7 +194,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, | |||
190 | ret = get_user_pages(cur_base, | 194 | ret = get_user_pages(cur_base, |
191 | min_t(unsigned long, npages, | 195 | min_t(unsigned long, npages, |
192 | PAGE_SIZE / sizeof (struct page *)), | 196 | PAGE_SIZE / sizeof (struct page *)), |
193 | 1, !umem->writable, page_list, vma_list); | 197 | gup_flags, page_list, vma_list); |
194 | 198 | ||
195 | if (ret < 0) | 199 | if (ret < 0) |
196 | goto out; | 200 | goto out; |