diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/nvgpu_mem.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/nvgpu_mem.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c b/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c index 1dbbd1a0..2bf26602 100644 --- a/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c +++ b/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c | |||
@@ -60,6 +60,14 @@ int nvgpu_mem_begin(struct gk20a *g, struct nvgpu_mem *mem) | |||
60 | { | 60 | { |
61 | void *cpu_va; | 61 | void *cpu_va; |
62 | 62 | ||
63 | if (WARN_ON(mem->cpu_accessible)) { | ||
64 | nvgpu_warn(g, "nested"); | ||
65 | return -EBUSY; | ||
66 | } | ||
67 | |||
68 | /* flag that the intent is to allow CPU access to the memory. */ | ||
69 | mem->cpu_accessible = true; | ||
70 | |||
63 | if (mem->aperture != APERTURE_SYSMEM || g->mm.force_pramin) | 71 | if (mem->aperture != APERTURE_SYSMEM || g->mm.force_pramin) |
64 | return 0; | 72 | return 0; |
65 | 73 | ||
@@ -71,17 +79,14 @@ int nvgpu_mem_begin(struct gk20a *g, struct nvgpu_mem *mem) | |||
71 | if (!(mem->priv.flags & NVGPU_DMA_NO_KERNEL_MAPPING)) | 79 | if (!(mem->priv.flags & NVGPU_DMA_NO_KERNEL_MAPPING)) |
72 | return 0; | 80 | return 0; |
73 | 81 | ||
74 | if (WARN_ON(mem->cpu_va)) { | ||
75 | nvgpu_warn(g, "nested"); | ||
76 | return -EBUSY; | ||
77 | } | ||
78 | |||
79 | cpu_va = vmap(mem->priv.pages, | 82 | cpu_va = vmap(mem->priv.pages, |
80 | PAGE_ALIGN(mem->size) >> PAGE_SHIFT, | 83 | PAGE_ALIGN(mem->size) >> PAGE_SHIFT, |
81 | 0, pgprot_writecombine(PAGE_KERNEL)); | 84 | 0, pgprot_writecombine(PAGE_KERNEL)); |
82 | 85 | ||
83 | if (WARN_ON(!cpu_va)) | 86 | if (WARN_ON(!cpu_va)) { |
87 | mem->cpu_accessible = false; | ||
84 | return -ENOMEM; | 88 | return -ENOMEM; |
89 | } | ||
85 | 90 | ||
86 | mem->cpu_va = cpu_va; | 91 | mem->cpu_va = cpu_va; |
87 | return 0; | 92 | return 0; |
@@ -89,6 +94,8 @@ int nvgpu_mem_begin(struct gk20a *g, struct nvgpu_mem *mem) | |||
89 | 94 | ||
90 | void nvgpu_mem_end(struct gk20a *g, struct nvgpu_mem *mem) | 95 | void nvgpu_mem_end(struct gk20a *g, struct nvgpu_mem *mem) |
91 | { | 96 | { |
97 | mem->cpu_accessible = false; | ||
98 | |||
92 | if (mem->aperture != APERTURE_SYSMEM || g->mm.force_pramin) | 99 | if (mem->aperture != APERTURE_SYSMEM || g->mm.force_pramin) |
93 | return; | 100 | return; |
94 | 101 | ||