diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/vm.c | 6 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/semaphore.c | 21 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/semaphore.h | 4 |
3 files changed, 15 insertions, 16 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c index f57b1c9c..13fd641e 100644 --- a/drivers/gpu/nvgpu/common/mm/vm.c +++ b/drivers/gpu/nvgpu/common/mm/vm.c | |||
@@ -230,9 +230,9 @@ static int nvgpu_init_sema_pool(struct vm_gk20a *vm) | |||
230 | if (!sema_sea) | 230 | if (!sema_sea) |
231 | return -ENOMEM; | 231 | return -ENOMEM; |
232 | 232 | ||
233 | vm->sema_pool = nvgpu_semaphore_pool_alloc(sema_sea); | 233 | err = nvgpu_semaphore_pool_alloc(sema_sea, &vm->sema_pool); |
234 | if (!vm->sema_pool) | 234 | if (err) |
235 | return -ENOMEM; | 235 | return err; |
236 | 236 | ||
237 | /* | 237 | /* |
238 | * Allocate a chunk of GPU VA space for mapping the semaphores. We will | 238 | * Allocate a chunk of GPU VA space for mapping the semaphores. We will |
diff --git a/drivers/gpu/nvgpu/common/semaphore.c b/drivers/gpu/nvgpu/common/semaphore.c index b2238bb7..fe4131c3 100644 --- a/drivers/gpu/nvgpu/common/semaphore.c +++ b/drivers/gpu/nvgpu/common/semaphore.c | |||
@@ -146,29 +146,27 @@ static int __semaphore_bitmap_alloc(unsigned long *bitmap, unsigned long len) | |||
146 | /* | 146 | /* |
147 | * Allocate a pool from the sea. | 147 | * Allocate a pool from the sea. |
148 | */ | 148 | */ |
149 | struct nvgpu_semaphore_pool *nvgpu_semaphore_pool_alloc( | 149 | int nvgpu_semaphore_pool_alloc(struct nvgpu_semaphore_sea *sea, |
150 | struct nvgpu_semaphore_sea *sea) | 150 | struct nvgpu_semaphore_pool **pool) |
151 | { | 151 | { |
152 | struct nvgpu_semaphore_pool *p; | 152 | struct nvgpu_semaphore_pool *p; |
153 | unsigned long page_idx; | 153 | unsigned long page_idx; |
154 | int ret, err = 0; | 154 | int ret; |
155 | 155 | ||
156 | p = nvgpu_kzalloc(sea->gk20a, sizeof(*p)); | 156 | p = nvgpu_kzalloc(sea->gk20a, sizeof(*p)); |
157 | if (!p) | 157 | if (!p) |
158 | return ERR_PTR(-ENOMEM); | 158 | return -ENOMEM; |
159 | 159 | ||
160 | __lock_sema_sea(sea); | 160 | __lock_sema_sea(sea); |
161 | 161 | ||
162 | err = nvgpu_mutex_init(&p->pool_lock); | 162 | ret = nvgpu_mutex_init(&p->pool_lock); |
163 | if (err) | 163 | if (ret) |
164 | goto fail; | 164 | goto fail; |
165 | 165 | ||
166 | ret = __semaphore_bitmap_alloc(sea->pools_alloced, | 166 | ret = __semaphore_bitmap_alloc(sea->pools_alloced, |
167 | SEMAPHORE_POOL_COUNT); | 167 | SEMAPHORE_POOL_COUNT); |
168 | if (ret < 0) { | 168 | if (ret < 0) |
169 | err = ret; | ||
170 | goto fail_alloc; | 169 | goto fail_alloc; |
171 | } | ||
172 | 170 | ||
173 | page_idx = (unsigned long)ret; | 171 | page_idx = (unsigned long)ret; |
174 | 172 | ||
@@ -184,7 +182,8 @@ struct nvgpu_semaphore_pool *nvgpu_semaphore_pool_alloc( | |||
184 | gpu_sema_dbg(sea->gk20a, | 182 | gpu_sema_dbg(sea->gk20a, |
185 | "Allocated semaphore pool: page-idx=%d", p->page_idx); | 183 | "Allocated semaphore pool: page-idx=%d", p->page_idx); |
186 | 184 | ||
187 | return p; | 185 | *pool = p; |
186 | return 0; | ||
188 | 187 | ||
189 | fail_alloc: | 188 | fail_alloc: |
190 | nvgpu_mutex_destroy(&p->pool_lock); | 189 | nvgpu_mutex_destroy(&p->pool_lock); |
@@ -192,7 +191,7 @@ fail: | |||
192 | __unlock_sema_sea(sea); | 191 | __unlock_sema_sea(sea); |
193 | nvgpu_kfree(sea->gk20a, p); | 192 | nvgpu_kfree(sea->gk20a, p); |
194 | gpu_sema_dbg(sea->gk20a, "Failed to allocate semaphore pool!"); | 193 | gpu_sema_dbg(sea->gk20a, "Failed to allocate semaphore pool!"); |
195 | return ERR_PTR(err); | 194 | return ret; |
196 | } | 195 | } |
197 | 196 | ||
198 | /* | 197 | /* |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/semaphore.h b/drivers/gpu/nvgpu/include/nvgpu/semaphore.h index e66b2188..771cc7e1 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/semaphore.h +++ b/drivers/gpu/nvgpu/include/nvgpu/semaphore.h | |||
@@ -173,8 +173,8 @@ struct nvgpu_semaphore_sea *nvgpu_semaphore_get_sea(struct gk20a *g); | |||
173 | /* | 173 | /* |
174 | * Semaphore pool functions. | 174 | * Semaphore pool functions. |
175 | */ | 175 | */ |
176 | struct nvgpu_semaphore_pool *nvgpu_semaphore_pool_alloc( | 176 | int nvgpu_semaphore_pool_alloc(struct nvgpu_semaphore_sea *sea, |
177 | struct nvgpu_semaphore_sea *sea); | 177 | struct nvgpu_semaphore_pool **pool); |
178 | int nvgpu_semaphore_pool_map(struct nvgpu_semaphore_pool *pool, | 178 | int nvgpu_semaphore_pool_map(struct nvgpu_semaphore_pool *pool, |
179 | struct vm_gk20a *vm); | 179 | struct vm_gk20a *vm); |
180 | void nvgpu_semaphore_pool_unmap(struct nvgpu_semaphore_pool *pool, | 180 | void nvgpu_semaphore_pool_unmap(struct nvgpu_semaphore_pool *pool, |