summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2018-02-14 13:58:24 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2018-02-27 19:03:52 -0500
commit3fdd8e38b280123fd13bcc4f3fd8928c15e94db6 (patch)
tree19334bacb71dbd7f3e08bbf7ba363193e8380851 /drivers/gpu/nvgpu/common/linux/nvgpu_mem.c
parent1170687c33f7506f39aaf47acee5430233e3d1a8 (diff)
gpu: nvgpu: Use our own vmap() for coherent DMA buffers
For some reason the GPU does not like the mappings created by the DMA API for coherent sysmem buffers. But a plain vmap() does seem to work. To work around this, when we are using coherent sysmem, force the NO_KERNEL_MAPPING flag to on and then make a vmap() in the nvgpu DMA API wrapper. The rest of the driver will be none the wiser but will work as expected. This problem is not understood yet but it is being tracked in bug 2040115. Once this bug is understood this WAR should either be determined as necessary or reverted with an appropriate fix. Bug 2040115 JIRA EVLR-2333 Change-Id: Idae7a0c92441f0309df572ac18697af49bb6ff2b Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1657568 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/nvgpu_mem.c')
-rw-r--r--drivers/gpu/nvgpu/common/linux/nvgpu_mem.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c b/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c
index c859520d..69897694 100644
--- a/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c
+++ b/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c
@@ -45,6 +45,14 @@ int nvgpu_mem_begin(struct gk20a *g, struct nvgpu_mem *mem)
45 return 0; 45 return 0;
46 46
47 /* 47 /*
48 * WAR for bug 2040115: we already will always have a coherent vmap()
49 * for all sysmem buffers. The prot settings are left alone since
50 * eventually this should be deleted.
51 */
52 if (nvgpu_is_enabled(g, NVGPU_USE_COHERENT_SYSMEM))
53 return 0;
54
55 /*
48 * A CPU mapping is implicitly made for all SYSMEM DMA allocations that 56 * A CPU mapping is implicitly made for all SYSMEM DMA allocations that
49 * don't have NVGPU_DMA_NO_KERNEL_MAPPING. Thus we don't need to make 57 * don't have NVGPU_DMA_NO_KERNEL_MAPPING. Thus we don't need to make
50 * another CPU mapping. 58 * another CPU mapping.
@@ -74,6 +82,13 @@ void nvgpu_mem_end(struct gk20a *g, struct nvgpu_mem *mem)
74 return; 82 return;
75 83
76 /* 84 /*
85 * WAR for bug 2040115: skip this since the map will be taken care of
86 * during the free in the DMA API.
87 */
88 if (nvgpu_is_enabled(g, NVGPU_USE_COHERENT_SYSMEM))
89 return;
90
91 /*
77 * Similar to nvgpu_mem_begin() we don't need to unmap the CPU mapping 92 * Similar to nvgpu_mem_begin() we don't need to unmap the CPU mapping
78 * already made by the DMA API. 93 * already made by the DMA API.
79 */ 94 */
@@ -393,8 +408,12 @@ int nvgpu_mem_create_from_mem(struct gk20a *g,
393 408
394 /* 409 /*
395 * Re-use the CPU mapping only if the mapping was made by the DMA API. 410 * Re-use the CPU mapping only if the mapping was made by the DMA API.
411 *
412 * Bug 2040115: the DMA API wrapper makes the mapping that we should
413 * re-use.
396 */ 414 */
397 if (!(src->priv.flags & NVGPU_DMA_NO_KERNEL_MAPPING)) 415 if (!(src->priv.flags & NVGPU_DMA_NO_KERNEL_MAPPING) ||
416 nvgpu_is_enabled(g, NVGPU_USE_COHERENT_SYSMEM))
398 dest->cpu_va = src->cpu_va + (PAGE_SIZE * start_page); 417 dest->cpu_va = src->cpu_va + (PAGE_SIZE * start_page);
399 418
400 dest->priv.pages = src->priv.pages + start_page; 419 dest->priv.pages = src->priv.pages + start_page;