summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/mm
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2018-09-05 18:28:05 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-09-12 20:48:11 -0400
commit338500c8e2ee342612d7bc4eb1cd87850228d4e2 (patch)
tree55f607de797b24577fb03158c33738322b54e100 /drivers/gpu/nvgpu/common/mm
parent19434a22454778a14cd918ad6a0ec061634a1fc2 (diff)
gpu: nvgpu: Fix MISRA 21.2 violations (public allocator APIs)
MISRA 21.2 states that we may not use reserved identifiers; since all identifiers beginning with '_' are reserved by libc, the usage of '__' as a prefix is disallowed. This fixes places in the public allocator APIs. This consists of the various init routines which are used to create an allocator and the debug macro used within the allocator code. The buddy allocator was handled by collapsing the internal '__' prepended version with the non-prefixed version. The only required change was in the page_allocator code which now had to pass in a NULL vm pointer (since the VM is not needed for managing VIDMEM). JIRA NVGPU-1029 Change-Id: I484a144e61789bf594c525c1ca307b96d120830f Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1813578 Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/mm')
-rw-r--r--drivers/gpu/nvgpu/common/mm/bitmap_allocator.c6
-rw-r--r--drivers/gpu/nvgpu/common/mm/buddy_allocator.c18
-rw-r--r--drivers/gpu/nvgpu/common/mm/lockless_allocator.c2
-rw-r--r--drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c6
-rw-r--r--drivers/gpu/nvgpu/common/mm/page_allocator.c7
-rw-r--r--drivers/gpu/nvgpu/common/mm/vm.c46
6 files changed, 39 insertions, 46 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c b/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c
index 1edfda51..6b9db23c 100644
--- a/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c
+++ b/drivers/gpu/nvgpu/common/mm/bitmap_allocator.c
@@ -174,7 +174,7 @@ static struct nvgpu_bitmap_alloc *find_alloc_metadata(
174/* 174/*
175 * Tree of alloc meta data stores the address of the alloc not the bit offset. 175 * Tree of alloc meta data stores the address of the alloc not the bit offset.
176 */ 176 */
177static int __nvgpu_bitmap_store_alloc(struct nvgpu_bitmap_allocator *a, 177static int nvgpu_bitmap_store_alloc(struct nvgpu_bitmap_allocator *a,
178 u64 addr, u64 len) 178 u64 addr, u64 len)
179{ 179{
180 struct nvgpu_bitmap_alloc *alloc = 180 struct nvgpu_bitmap_alloc *alloc =
@@ -244,7 +244,7 @@ static u64 nvgpu_bitmap_alloc(struct nvgpu_allocator *na, u64 len)
244 * data it needs around to successfully free this allocation. 244 * data it needs around to successfully free this allocation.
245 */ 245 */
246 if (!(a->flags & GPU_ALLOC_NO_ALLOC_PAGE) && 246 if (!(a->flags & GPU_ALLOC_NO_ALLOC_PAGE) &&
247 __nvgpu_bitmap_store_alloc(a, addr, blks * a->blk_size)) { 247 nvgpu_bitmap_store_alloc(a, addr, blks * a->blk_size)) {
248 goto fail_reset_bitmap; 248 goto fail_reset_bitmap;
249 } 249 }
250 250
@@ -401,7 +401,7 @@ int nvgpu_bitmap_allocator_init(struct gk20a *g, struct nvgpu_allocator *na,
401 return -ENOMEM; 401 return -ENOMEM;
402 } 402 }
403 403
404 err = __nvgpu_alloc_common_init(na, g, name, a, false, &bitmap_ops); 404 err = nvgpu_alloc_common_init(na, g, name, a, false, &bitmap_ops);
405 if (err) { 405 if (err) {
406 goto fail; 406 goto fail;
407 } 407 }
diff --git a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c
index b29045ba..3b8d9939 100644
--- a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c
+++ b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c
@@ -1281,10 +1281,10 @@ static const struct nvgpu_allocator_ops buddy_ops = {
1281 * will try and pick a reasonable max order. 1281 * will try and pick a reasonable max order.
1282 * @flags: Extra flags necessary. See GPU_BALLOC_*. 1282 * @flags: Extra flags necessary. See GPU_BALLOC_*.
1283 */ 1283 */
1284int __nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, 1284int nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *na,
1285 struct vm_gk20a *vm, const char *name, 1285 struct vm_gk20a *vm, const char *name,
1286 u64 base, u64 size, u64 blk_size, 1286 u64 base, u64 size, u64 blk_size,
1287 u64 max_order, u64 flags) 1287 u64 max_order, u64 flags)
1288{ 1288{
1289 int err; 1289 int err;
1290 u64 pde_size; 1290 u64 pde_size;
@@ -1312,7 +1312,7 @@ int __nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *na,
1312 return -ENOMEM; 1312 return -ENOMEM;
1313 } 1313 }
1314 1314
1315 err = __nvgpu_alloc_common_init(na, g, name, a, false, &buddy_ops); 1315 err = nvgpu_alloc_common_init(na, g, name, a, false, &buddy_ops);
1316 if (err) { 1316 if (err) {
1317 goto fail; 1317 goto fail;
1318 } 1318 }
@@ -1396,11 +1396,3 @@ fail:
1396 nvgpu_kfree(g, a); 1396 nvgpu_kfree(g, a);
1397 return err; 1397 return err;
1398} 1398}
1399
1400int nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *na,
1401 const char *name, u64 base, u64 size,
1402 u64 blk_size, u64 flags)
1403{
1404 return __nvgpu_buddy_allocator_init(g, na, NULL, name,
1405 base, size, blk_size, 0, 0);
1406}
diff --git a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c
index eec661bc..79bf4cd6 100644
--- a/drivers/gpu/nvgpu/common/mm/lockless_allocator.c
+++ b/drivers/gpu/nvgpu/common/mm/lockless_allocator.c
@@ -187,7 +187,7 @@ int nvgpu_lockless_allocator_init(struct gk20a *g, struct nvgpu_allocator *na,
187 return -ENOMEM; 187 return -ENOMEM;
188 } 188 }
189 189
190 err = __nvgpu_alloc_common_init(na, g, name, a, false, &pool_ops); 190 err = nvgpu_alloc_common_init(na, g, name, a, false, &pool_ops);
191 if (err) { 191 if (err) {
192 goto fail; 192 goto fail;
193 } 193 }
diff --git a/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c b/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c
index ec0aa888..bf624162 100644
--- a/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c
+++ b/drivers/gpu/nvgpu/common/mm/nvgpu_allocator.c
@@ -145,9 +145,9 @@ void nvgpu_alloc_print_stats(struct nvgpu_allocator *na,
145/* 145/*
146 * Handle the common init stuff for a nvgpu_allocator. 146 * Handle the common init stuff for a nvgpu_allocator.
147 */ 147 */
148int __nvgpu_alloc_common_init(struct nvgpu_allocator *a, struct gk20a *g, 148int nvgpu_alloc_common_init(struct nvgpu_allocator *a, struct gk20a *g,
149 const char *name, void *priv, bool dbg, 149 const char *name, void *priv, bool dbg,
150 const struct nvgpu_allocator_ops *ops) 150 const struct nvgpu_allocator_ops *ops)
151{ 151{
152 int err; 152 int err;
153 153
diff --git a/drivers/gpu/nvgpu/common/mm/page_allocator.c b/drivers/gpu/nvgpu/common/mm/page_allocator.c
index e559cb60..c8bc17c7 100644
--- a/drivers/gpu/nvgpu/common/mm/page_allocator.c
+++ b/drivers/gpu/nvgpu/common/mm/page_allocator.c
@@ -1022,7 +1022,7 @@ int nvgpu_page_allocator_init(struct gk20a *g, struct nvgpu_allocator *na,
1022 return -ENOMEM; 1022 return -ENOMEM;
1023 } 1023 }
1024 1024
1025 err = __nvgpu_alloc_common_init(na, g, name, a, false, &page_ops); 1025 err = nvgpu_alloc_common_init(na, g, name, a, false, &page_ops);
1026 if (err) { 1026 if (err) {
1027 goto fail; 1027 goto fail;
1028 } 1028 }
@@ -1053,8 +1053,9 @@ int nvgpu_page_allocator_init(struct gk20a *g, struct nvgpu_allocator *na,
1053 1053
1054 snprintf(buddy_name, sizeof(buddy_name), "%s-src", name); 1054 snprintf(buddy_name, sizeof(buddy_name), "%s-src", name);
1055 1055
1056 err = nvgpu_buddy_allocator_init(g, &a->source_allocator, buddy_name, 1056 err = nvgpu_buddy_allocator_init(g, &a->source_allocator, NULL,
1057 base, length, blk_size, 0); 1057 buddy_name, base, length, blk_size,
1058 0ULL, 0ULL);
1058 if (err) { 1059 if (err) {
1059 goto fail; 1060 goto fail;
1060 } 1061 }
diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c
index 57d9afb5..b2b83767 100644
--- a/drivers/gpu/nvgpu/common/mm/vm.c
+++ b/drivers/gpu/nvgpu/common/mm/vm.c
@@ -420,14 +420,14 @@ int __nvgpu_vm_init(struct mm_gk20a *mm,
420 */ 420 */
421 if (user_vma_start < user_vma_limit) { 421 if (user_vma_start < user_vma_limit) {
422 snprintf(alloc_name, sizeof(alloc_name), "gk20a_%s", name); 422 snprintf(alloc_name, sizeof(alloc_name), "gk20a_%s", name);
423 err = __nvgpu_buddy_allocator_init(g, &vm->user, 423 err = nvgpu_buddy_allocator_init(g, &vm->user,
424 vm, alloc_name, 424 vm, alloc_name,
425 user_vma_start, 425 user_vma_start,
426 user_vma_limit - 426 user_vma_limit -
427 user_vma_start, 427 user_vma_start,
428 SZ_4K, 428 SZ_4K,
429 GPU_BALLOC_MAX_ORDER, 429 GPU_BALLOC_MAX_ORDER,
430 GPU_ALLOC_GVA_SPACE); 430 GPU_ALLOC_GVA_SPACE);
431 if (err) { 431 if (err) {
432 goto clean_up_page_tables; 432 goto clean_up_page_tables;
433 } 433 }
@@ -446,14 +446,14 @@ int __nvgpu_vm_init(struct mm_gk20a *mm,
446 */ 446 */
447 if (user_lp_vma_start < user_lp_vma_limit) { 447 if (user_lp_vma_start < user_lp_vma_limit) {
448 snprintf(alloc_name, sizeof(alloc_name), "gk20a_%s_lp", name); 448 snprintf(alloc_name, sizeof(alloc_name), "gk20a_%s_lp", name);
449 err = __nvgpu_buddy_allocator_init(g, &vm->user_lp, 449 err = nvgpu_buddy_allocator_init(g, &vm->user_lp,
450 vm, alloc_name, 450 vm, alloc_name,
451 user_lp_vma_start, 451 user_lp_vma_start,
452 user_lp_vma_limit - 452 user_lp_vma_limit -
453 user_lp_vma_start, 453 user_lp_vma_start,
454 vm->big_page_size, 454 vm->big_page_size,
455 GPU_BALLOC_MAX_ORDER, 455 GPU_BALLOC_MAX_ORDER,
456 GPU_ALLOC_GVA_SPACE); 456 GPU_ALLOC_GVA_SPACE);
457 if (err) { 457 if (err) {
458 goto clean_up_allocators; 458 goto clean_up_allocators;
459 } 459 }
@@ -463,13 +463,13 @@ int __nvgpu_vm_init(struct mm_gk20a *mm,
463 * Kernel VMA. Must always exist for an address space. 463 * Kernel VMA. Must always exist for an address space.
464 */ 464 */
465 snprintf(alloc_name, sizeof(alloc_name), "gk20a_%s-sys", name); 465 snprintf(alloc_name, sizeof(alloc_name), "gk20a_%s-sys", name);
466 err = __nvgpu_buddy_allocator_init(g, &vm->kernel, 466 err = nvgpu_buddy_allocator_init(g, &vm->kernel,
467 vm, alloc_name, 467 vm, alloc_name,
468 kernel_vma_start, 468 kernel_vma_start,
469 kernel_vma_limit - kernel_vma_start, 469 kernel_vma_limit - kernel_vma_start,
470 SZ_4K, 470 SZ_4K,
471 GPU_BALLOC_MAX_ORDER, 471 GPU_BALLOC_MAX_ORDER,
472 kernel_vma_flags); 472 kernel_vma_flags);
473 if (err) { 473 if (err) {
474 goto clean_up_allocators; 474 goto clean_up_allocators;
475 } 475 }