diff options
author | Nicolas Benech <nbenech@nvidia.com> | 2018-08-23 16:23:52 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-09-05 23:39:08 -0400 |
commit | 2eface802a4aea417206bcdda689a65cf47d300b (patch) | |
tree | 502af9d48004af4edf8f02a2a7cf751ef5a11325 /drivers/gpu/nvgpu/common/mm/vm.c | |
parent | b44c7fdb114a63ab98fffc0f246776b56399ff64 (diff) |
gpu: nvgpu: Fix mutex MISRA 17.7 violations
MISRA Rule-17.7 requires the return value of all functions to be used.
Fix is either to use the return value or change the function to return
void. This patch contains fix for calls to nvgpu_mutex_init and
improves related error handling.
JIRA NVGPU-677
Change-Id: I609fa138520cc7ccfdd5aa0e7fd28c8ca0b3a21c
Signed-off-by: Nicolas Benech <nbenech@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1805598
Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/mm/vm.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/vm.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c index b364f4d6..3cb8ed60 100644 --- a/drivers/gpu/nvgpu/common/mm/vm.c +++ b/drivers/gpu/nvgpu/common/mm/vm.c | |||
@@ -284,7 +284,7 @@ int __nvgpu_vm_init(struct mm_gk20a *mm, | |||
284 | bool userspace_managed, | 284 | bool userspace_managed, |
285 | char *name) | 285 | char *name) |
286 | { | 286 | { |
287 | int err; | 287 | int err = 0; |
288 | char alloc_name[32]; | 288 | char alloc_name[32]; |
289 | u64 kernel_vma_flags; | 289 | u64 kernel_vma_flags; |
290 | u64 user_vma_start, user_vma_limit; | 290 | u64 user_vma_start, user_vma_limit; |
@@ -476,8 +476,19 @@ int __nvgpu_vm_init(struct mm_gk20a *mm, | |||
476 | 476 | ||
477 | vm->mapped_buffers = NULL; | 477 | vm->mapped_buffers = NULL; |
478 | 478 | ||
479 | nvgpu_mutex_init(&vm->syncpt_ro_map_lock); | 479 | err = nvgpu_mutex_init(&vm->syncpt_ro_map_lock); |
480 | nvgpu_mutex_init(&vm->update_gmmu_lock); | 480 | if (err != 0) { |
481 | nvgpu_err(g, | ||
482 | "Error in syncpt_ro_map_lock mutex initialization"); | ||
483 | goto clean_up_allocators; | ||
484 | } | ||
485 | |||
486 | err = nvgpu_mutex_init(&vm->update_gmmu_lock); | ||
487 | if (err != 0) { | ||
488 | nvgpu_err(g, "Error in update_gmmu_lock mutex initialization"); | ||
489 | goto clean_up_ro_map_lock; | ||
490 | } | ||
491 | |||
481 | nvgpu_ref_init(&vm->ref); | 492 | nvgpu_ref_init(&vm->ref); |
482 | nvgpu_init_list_node(&vm->vm_area_list); | 493 | nvgpu_init_list_node(&vm->vm_area_list); |
483 | 494 | ||
@@ -489,12 +500,16 @@ int __nvgpu_vm_init(struct mm_gk20a *mm, | |||
489 | if (vm->va_limit > 4ULL * SZ_1G) { | 500 | if (vm->va_limit > 4ULL * SZ_1G) { |
490 | err = nvgpu_init_sema_pool(vm); | 501 | err = nvgpu_init_sema_pool(vm); |
491 | if (err) { | 502 | if (err) { |
492 | goto clean_up_allocators; | 503 | goto clean_up_gmmu_lock; |
493 | } | 504 | } |
494 | } | 505 | } |
495 | 506 | ||
496 | return 0; | 507 | return 0; |
497 | 508 | ||
509 | clean_up_gmmu_lock: | ||
510 | nvgpu_mutex_destroy(&vm->update_gmmu_lock); | ||
511 | clean_up_ro_map_lock: | ||
512 | nvgpu_mutex_destroy(&vm->syncpt_ro_map_lock); | ||
498 | clean_up_allocators: | 513 | clean_up_allocators: |
499 | if (nvgpu_alloc_initialized(&vm->kernel)) { | 514 | if (nvgpu_alloc_initialized(&vm->kernel)) { |
500 | nvgpu_alloc_destroy(&vm->kernel); | 515 | nvgpu_alloc_destroy(&vm->kernel); |