summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2018-08-22 18:06:23 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-09-20 18:14:47 -0400
commitc1b66bc6a93eeecec1aea0e5bdf93397d0458823 (patch)
treec12bc035809bf17e22335c7f9b55d3b47948f425 /drivers
parentcdbe89a2729d242a17d3779a44e40998bd4e06f0 (diff)
gpu: nvgpu: Fix some dma.[ch] MISRA violations
This doesn't correspond to a specific rule; it just cleans up the violations introduced by http://git-master/r/1799807. JIRA NVGPU-990 Change-Id: Ia20af754da9ad60f81d58ba00bf781a8c441827b Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1804887 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/nvgpu/common/mm/dma.c23
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/dma.h6
2 files changed, 19 insertions, 10 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/dma.c b/drivers/gpu/nvgpu/common/mm/dma.c
index f7331f8e..60fe3658 100644
--- a/drivers/gpu/nvgpu/common/mm/dma.c
+++ b/drivers/gpu/nvgpu/common/mm/dma.c
@@ -50,8 +50,10 @@ int nvgpu_dma_alloc_flags(struct gk20a *g, unsigned long flags, size_t size,
50 NVGPU_DMA_NO_KERNEL_MAPPING, 50 NVGPU_DMA_NO_KERNEL_MAPPING,
51 size, mem); 51 size, mem);
52 52
53 if (!err) 53 if (!err) {
54 return 0; 54 return 0;
55 }
56
55 /* 57 /*
56 * Fall back to sysmem (which may then also fail) in case 58 * Fall back to sysmem (which may then also fail) in case
57 * vidmem is exhausted. 59 * vidmem is exhausted.
@@ -105,8 +107,10 @@ int nvgpu_dma_alloc_map_flags(struct vm_gk20a *vm, unsigned long flags,
105 flags | NVGPU_DMA_NO_KERNEL_MAPPING, 107 flags | NVGPU_DMA_NO_KERNEL_MAPPING,
106 size, mem); 108 size, mem);
107 109
108 if (!err) 110 if (!err) {
109 return 0; 111 return 0;
112 }
113
110 /* 114 /*
111 * Fall back to sysmem (which may then also fail) in case 115 * Fall back to sysmem (which may then also fail) in case
112 * vidmem is exhausted. 116 * vidmem is exhausted.
@@ -127,8 +131,9 @@ int nvgpu_dma_alloc_map_flags_sys(struct vm_gk20a *vm, unsigned long flags,
127{ 131{
128 int err = nvgpu_dma_alloc_flags_sys(vm->mm->g, flags, size, mem); 132 int err = nvgpu_dma_alloc_flags_sys(vm->mm->g, flags, size, mem);
129 133
130 if (err) 134 if (err) {
131 return err; 135 return err;
136 }
132 137
133 mem->gpu_va = nvgpu_gmmu_map(vm, mem, size, 0, 138 mem->gpu_va = nvgpu_gmmu_map(vm, mem, size, 0,
134 gk20a_mem_flag_none, false, 139 gk20a_mem_flag_none, false,
@@ -157,8 +162,9 @@ int nvgpu_dma_alloc_map_flags_vid(struct vm_gk20a *vm, unsigned long flags,
157{ 162{
158 int err = nvgpu_dma_alloc_flags_vid(vm->mm->g, flags, size, mem); 163 int err = nvgpu_dma_alloc_flags_vid(vm->mm->g, flags, size, mem);
159 164
160 if (err) 165 if (err) {
161 return err; 166 return err;
167 }
162 168
163 mem->gpu_va = nvgpu_gmmu_map(vm, mem, size, 0, 169 mem->gpu_va = nvgpu_gmmu_map(vm, mem, size, 0,
164 gk20a_mem_flag_none, false, 170 gk20a_mem_flag_none, false,
@@ -179,9 +185,11 @@ void nvgpu_dma_free(struct gk20a *g, struct nvgpu_mem *mem)
179{ 185{
180 switch (mem->aperture) { 186 switch (mem->aperture) {
181 case APERTURE_SYSMEM: 187 case APERTURE_SYSMEM:
182 return nvgpu_dma_free_sys(g, mem); 188 nvgpu_dma_free_sys(g, mem);
189 break;
183 case APERTURE_VIDMEM: 190 case APERTURE_VIDMEM:
184 return nvgpu_dma_free_vid(g, mem); 191 nvgpu_dma_free_vid(g, mem);
192 break;
185 default: 193 default:
186 break; /* like free() on "null" memory */ 194 break; /* like free() on "null" memory */
187 } 195 }
@@ -189,8 +197,9 @@ void nvgpu_dma_free(struct gk20a *g, struct nvgpu_mem *mem)
189 197
190void nvgpu_dma_unmap_free(struct vm_gk20a *vm, struct nvgpu_mem *mem) 198void nvgpu_dma_unmap_free(struct vm_gk20a *vm, struct nvgpu_mem *mem)
191{ 199{
192 if (mem->gpu_va) 200 if (mem->gpu_va) {
193 nvgpu_gmmu_unmap(vm, mem, mem->gpu_va); 201 nvgpu_gmmu_unmap(vm, mem, mem->gpu_va);
202 }
194 mem->gpu_va = 0; 203 mem->gpu_va = 0;
195 204
196 nvgpu_dma_free(vm->mm->g, mem); 205 nvgpu_dma_free(vm->mm->g, mem);
diff --git a/drivers/gpu/nvgpu/include/nvgpu/dma.h b/drivers/gpu/nvgpu/include/nvgpu/dma.h
index 6a13e577..cbb829b6 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/dma.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/dma.h
@@ -37,18 +37,18 @@ struct nvgpu_mem;
37 * Don't create a virtual kernel mapping for the buffer but only allocate it; 37 * Don't create a virtual kernel mapping for the buffer but only allocate it;
38 * this may save some resources. The buffer can be mapped later explicitly. 38 * this may save some resources. The buffer can be mapped later explicitly.
39 */ 39 */
40#define NVGPU_DMA_NO_KERNEL_MAPPING (1 << 0) 40#define NVGPU_DMA_NO_KERNEL_MAPPING BIT32(0)
41 41
42/* 42/*
43 * Don't allow building the buffer from individual pages but require a 43 * Don't allow building the buffer from individual pages but require a
44 * physically contiguous block. 44 * physically contiguous block.
45 */ 45 */
46#define NVGPU_DMA_FORCE_CONTIGUOUS (1 << 1) 46#define NVGPU_DMA_FORCE_CONTIGUOUS BIT32(1)
47 47
48/* 48/*
49 * Make the mapping read-only. 49 * Make the mapping read-only.
50 */ 50 */
51#define NVGPU_DMA_READ_ONLY (1 << 2) 51#define NVGPU_DMA_READ_ONLY BIT32(2)
52 52
53/** 53/**
54 * nvgpu_iommuable - Check if GPU is behind IOMMU 54 * nvgpu_iommuable - Check if GPU is behind IOMMU