summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/dma.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/dma.c')
-rw-r--r--drivers/gpu/nvgpu/common/linux/dma.c34
1 files changed, 3 insertions, 31 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/dma.c b/drivers/gpu/nvgpu/common/linux/dma.c
index 81aebb7d..c13dae8b 100644
--- a/drivers/gpu/nvgpu/common/linux/dma.c
+++ b/drivers/gpu/nvgpu/common/linux/dma.c
@@ -222,16 +222,6 @@ int nvgpu_dma_alloc_flags_sys(struct gk20a *g, unsigned long flags,
222 void *alloc_ret; 222 void *alloc_ret;
223 223
224 /* 224 /*
225 * WAR for IO coherent chips: the DMA API does not seem to generate
226 * mappings that work correctly. Unclear why - Bug ID: 2040115.
227 *
228 * Basically we just tell the DMA API not to map with NO_KERNEL_MAPPING
229 * and then make a vmap() ourselves.
230 */
231 if (nvgpu_is_enabled(g, NVGPU_USE_COHERENT_SYSMEM))
232 flags |= NVGPU_DMA_NO_KERNEL_MAPPING;
233
234 /*
235 * Before the debug print so we see this in the total. But during 225 * Before the debug print so we see this in the total. But during
236 * cleanup in the fail path this has to be subtracted. 226 * cleanup in the fail path this has to be subtracted.
237 */ 227 */
@@ -265,17 +255,7 @@ int nvgpu_dma_alloc_flags_sys(struct gk20a *g, unsigned long flags,
265 iova, size, flags); 255 iova, size, flags);
266 } 256 }
267 if (err) 257 if (err)
268 goto fail_free_dma; 258 goto fail_free;
269
270 if (nvgpu_is_enabled(g, NVGPU_USE_COHERENT_SYSMEM)) {
271 mem->cpu_va = vmap(mem->priv.pages,
272 size >> PAGE_SHIFT,
273 0, PAGE_KERNEL);
274 if (!mem->cpu_va) {
275 err = -ENOMEM;
276 goto fail_free_sgt;
277 }
278 }
279 259
280 mem->aligned_size = size; 260 mem->aligned_size = size;
281 mem->aperture = APERTURE_SYSMEM; 261 mem->aperture = APERTURE_SYSMEM;
@@ -285,14 +265,12 @@ int nvgpu_dma_alloc_flags_sys(struct gk20a *g, unsigned long flags,
285 265
286 return 0; 266 return 0;
287 267
288fail_free_sgt: 268fail_free:
289 nvgpu_free_sgtable(g, &mem->priv.sgt); 269 g->dma_memory_used -= mem->aligned_size;
290fail_free_dma:
291 dma_free_attrs(d, size, alloc_ret, iova, NVGPU_DMA_ATTR(dma_attrs)); 270 dma_free_attrs(d, size, alloc_ret, iova, NVGPU_DMA_ATTR(dma_attrs));
292 mem->cpu_va = NULL; 271 mem->cpu_va = NULL;
293 mem->priv.sgt = NULL; 272 mem->priv.sgt = NULL;
294 mem->size = 0; 273 mem->size = 0;
295 g->dma_memory_used -= mem->aligned_size;
296 return err; 274 return err;
297} 275}
298 276
@@ -488,12 +466,6 @@ static void nvgpu_dma_free_sys(struct gk20a *g, struct nvgpu_mem *mem)
488 if (!(mem->mem_flags & NVGPU_MEM_FLAG_SHADOW_COPY) && 466 if (!(mem->mem_flags & NVGPU_MEM_FLAG_SHADOW_COPY) &&
489 !(mem->mem_flags & __NVGPU_MEM_FLAG_NO_DMA) && 467 !(mem->mem_flags & __NVGPU_MEM_FLAG_NO_DMA) &&
490 (mem->cpu_va || mem->priv.pages)) { 468 (mem->cpu_va || mem->priv.pages)) {
491 /*
492 * Free side of WAR for bug 2040115.
493 */
494 if (nvgpu_is_enabled(g, NVGPU_USE_COHERENT_SYSMEM))
495 vunmap(mem->cpu_va);
496
497 if (mem->priv.flags) { 469 if (mem->priv.flags) {
498 NVGPU_DEFINE_DMA_ATTRS(dma_attrs); 470 NVGPU_DEFINE_DMA_ATTRS(dma_attrs);
499 471