diff options
author | Deepak Nibade <dnibade@nvidia.com> | 2017-03-08 05:00:40 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-03-14 14:46:53 -0400 |
commit | 9efadcdfc07572d789f8f2581af70d03cf5cbde4 (patch) | |
tree | 752b27e9526f6ef125007c5629c547a48b260b90 | |
parent | bba49e6ee12a17cdff174aabe348424de57ec5f3 (diff) |
gpu: nvgpu: check return value of mutex_init for semaphores
- check return value of nvgpu_mutex_init for semaphores
- add corresponding nvgpu_mutex_destroy calls
Jira NVGPU-13
Change-Id: I5404dbd29e3fce29f1a445eb2e6ce8e1d1b616c4
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1317138
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: Navneet Kumar <navneetk@nvidia.com>
-rw-r--r-- | drivers/gpu/nvgpu/common/semaphore.c | 30 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/mm_gk20a.c | 1 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/semaphore.h | 1 |
3 files changed, 27 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/common/semaphore.c b/drivers/gpu/nvgpu/common/semaphore.c index 919f26ec..e4099bd1 100644 --- a/drivers/gpu/nvgpu/common/semaphore.c +++ b/drivers/gpu/nvgpu/common/semaphore.c | |||
@@ -64,6 +64,16 @@ out: | |||
64 | return ret; | 64 | return ret; |
65 | } | 65 | } |
66 | 66 | ||
67 | void gk20a_semaphore_sea_destroy(struct gk20a *g) | ||
68 | { | ||
69 | if (!g->sema_sea) | ||
70 | return; | ||
71 | |||
72 | nvgpu_mutex_destroy(&g->sema_sea->sea_lock); | ||
73 | kfree(g->sema_sea); | ||
74 | g->sema_sea = NULL; | ||
75 | } | ||
76 | |||
67 | /* | 77 | /* |
68 | * Create the semaphore sea. Only create it once - subsequent calls to this will | 78 | * Create the semaphore sea. Only create it once - subsequent calls to this will |
69 | * return the originally created sea pointer. | 79 | * return the originally created sea pointer. |
@@ -81,15 +91,18 @@ struct nvgpu_semaphore_sea *nvgpu_semaphore_sea_create(struct gk20a *g) | |||
81 | g->sema_sea->page_count = 0; | 91 | g->sema_sea->page_count = 0; |
82 | g->sema_sea->gk20a = g; | 92 | g->sema_sea->gk20a = g; |
83 | INIT_LIST_HEAD(&g->sema_sea->pool_list); | 93 | INIT_LIST_HEAD(&g->sema_sea->pool_list); |
84 | nvgpu_mutex_init(&g->sema_sea->sea_lock); | 94 | if (nvgpu_mutex_init(&g->sema_sea->sea_lock)) |
95 | goto cleanup_free; | ||
85 | 96 | ||
86 | if (__nvgpu_semaphore_sea_grow(g->sema_sea)) | 97 | if (__nvgpu_semaphore_sea_grow(g->sema_sea)) |
87 | goto cleanup; | 98 | goto cleanup_destroy; |
88 | 99 | ||
89 | gpu_sema_dbg("Created semaphore sea!"); | 100 | gpu_sema_dbg("Created semaphore sea!"); |
90 | return g->sema_sea; | 101 | return g->sema_sea; |
91 | 102 | ||
92 | cleanup: | 103 | cleanup_destroy: |
104 | nvgpu_mutex_destroy(&g->sema_sea->sea_lock); | ||
105 | cleanup_free: | ||
93 | kfree(g->sema_sea); | 106 | kfree(g->sema_sea); |
94 | g->sema_sea = NULL; | 107 | g->sema_sea = NULL; |
95 | gpu_sema_dbg("Failed to creat semaphore sea!"); | 108 | gpu_sema_dbg("Failed to creat semaphore sea!"); |
@@ -124,10 +137,14 @@ struct nvgpu_semaphore_pool *nvgpu_semaphore_pool_alloc( | |||
124 | 137 | ||
125 | __lock_sema_sea(sea); | 138 | __lock_sema_sea(sea); |
126 | 139 | ||
140 | err = nvgpu_mutex_init(&p->pool_lock); | ||
141 | if (err) | ||
142 | goto fail; | ||
143 | |||
127 | ret = __semaphore_bitmap_alloc(sea->pools_alloced, SEMAPHORE_POOL_COUNT); | 144 | ret = __semaphore_bitmap_alloc(sea->pools_alloced, SEMAPHORE_POOL_COUNT); |
128 | if (ret < 0) { | 145 | if (ret < 0) { |
129 | err = ret; | 146 | err = ret; |
130 | goto fail; | 147 | goto fail_alloc; |
131 | } | 148 | } |
132 | 149 | ||
133 | page_idx = (unsigned long)ret; | 150 | page_idx = (unsigned long)ret; |
@@ -138,7 +155,6 @@ struct nvgpu_semaphore_pool *nvgpu_semaphore_pool_alloc( | |||
138 | p->sema_sea = sea; | 155 | p->sema_sea = sea; |
139 | INIT_LIST_HEAD(&p->hw_semas); | 156 | INIT_LIST_HEAD(&p->hw_semas); |
140 | kref_init(&p->ref); | 157 | kref_init(&p->ref); |
141 | nvgpu_mutex_init(&p->pool_lock); | ||
142 | 158 | ||
143 | sea->page_count++; | 159 | sea->page_count++; |
144 | list_add(&p->pool_list_entry, &sea->pool_list); | 160 | list_add(&p->pool_list_entry, &sea->pool_list); |
@@ -148,6 +164,8 @@ struct nvgpu_semaphore_pool *nvgpu_semaphore_pool_alloc( | |||
148 | 164 | ||
149 | return p; | 165 | return p; |
150 | 166 | ||
167 | fail_alloc: | ||
168 | nvgpu_mutex_destroy(&p->pool_lock); | ||
151 | fail: | 169 | fail: |
152 | __unlock_sema_sea(sea); | 170 | __unlock_sema_sea(sea); |
153 | kfree(p); | 171 | kfree(p); |
@@ -309,6 +327,8 @@ static void nvgpu_semaphore_pool_free(struct kref *ref) | |||
309 | list_for_each_entry_safe(hw_sema, tmp, &p->hw_semas, hw_sema_list) | 327 | list_for_each_entry_safe(hw_sema, tmp, &p->hw_semas, hw_sema_list) |
310 | kfree(hw_sema); | 328 | kfree(hw_sema); |
311 | 329 | ||
330 | nvgpu_mutex_destroy(&p->pool_lock); | ||
331 | |||
312 | gpu_sema_dbg("Freed semaphore pool! (idx=%d)", p->page_idx); | 332 | gpu_sema_dbg("Freed semaphore pool! (idx=%d)", p->page_idx); |
313 | kfree(p); | 333 | kfree(p); |
314 | } | 334 | } |
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c index 2ff54653..a857390b 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c | |||
@@ -832,6 +832,7 @@ static void gk20a_remove_mm_support(struct mm_gk20a *mm) | |||
832 | gk20a_free_inst_block(gk20a_from_mm(mm), &mm->hwpm.inst_block); | 832 | gk20a_free_inst_block(gk20a_from_mm(mm), &mm->hwpm.inst_block); |
833 | gk20a_vm_remove_support_nofree(&mm->cde.vm); | 833 | gk20a_vm_remove_support_nofree(&mm->cde.vm); |
834 | 834 | ||
835 | gk20a_semaphore_sea_destroy(g); | ||
835 | gk20a_vidmem_destroy(g); | 836 | gk20a_vidmem_destroy(g); |
836 | } | 837 | } |
837 | 838 | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/semaphore.h b/drivers/gpu/nvgpu/include/nvgpu/semaphore.h index 6f479383..6c9b8118 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/semaphore.h +++ b/drivers/gpu/nvgpu/include/nvgpu/semaphore.h | |||
@@ -150,6 +150,7 @@ struct nvgpu_semaphore_sea { | |||
150 | * Semaphore sea functions. | 150 | * Semaphore sea functions. |
151 | */ | 151 | */ |
152 | struct nvgpu_semaphore_sea *nvgpu_semaphore_sea_create(struct gk20a *gk20a); | 152 | struct nvgpu_semaphore_sea *nvgpu_semaphore_sea_create(struct gk20a *gk20a); |
153 | void gk20a_semaphore_sea_destroy(struct gk20a *g); | ||
153 | int nvgpu_semaphore_sea_map(struct nvgpu_semaphore_pool *sea, | 154 | int nvgpu_semaphore_sea_map(struct nvgpu_semaphore_pool *sea, |
154 | struct vm_gk20a *vm); | 155 | struct vm_gk20a *vm); |
155 | void nvgpu_semaphore_sea_unmap(struct nvgpu_semaphore_pool *sea, | 156 | void nvgpu_semaphore_sea_unmap(struct nvgpu_semaphore_pool *sea, |