diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/semaphore.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/semaphore.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/gpu/nvgpu/common/semaphore.c b/drivers/gpu/nvgpu/common/semaphore.c index dfed3588..b2238bb7 100644 --- a/drivers/gpu/nvgpu/common/semaphore.c +++ b/drivers/gpu/nvgpu/common/semaphore.c | |||
@@ -376,10 +376,10 @@ static int __nvgpu_init_hw_sema(struct channel_gk20a *ch) | |||
376 | 376 | ||
377 | ch->hw_sema = hw_sema; | 377 | ch->hw_sema = hw_sema; |
378 | hw_sema->ch = ch; | 378 | hw_sema->ch = ch; |
379 | hw_sema->p = p; | 379 | hw_sema->location.pool = p; |
380 | hw_sema->idx = hw_sema_idx; | 380 | hw_sema->location.offset = SEMAPHORE_SIZE * hw_sema_idx; |
381 | hw_sema->offset = SEMAPHORE_SIZE * hw_sema_idx; | 381 | current_value = nvgpu_mem_rd(ch->g, &p->rw_mem, |
382 | current_value = nvgpu_mem_rd(ch->g, &p->rw_mem, hw_sema->offset); | 382 | hw_sema->location.offset); |
383 | nvgpu_atomic_set(&hw_sema->next_value, current_value); | 383 | nvgpu_atomic_set(&hw_sema->next_value, current_value); |
384 | 384 | ||
385 | nvgpu_mutex_release(&p->pool_lock); | 385 | nvgpu_mutex_release(&p->pool_lock); |
@@ -399,15 +399,16 @@ fail: | |||
399 | void nvgpu_semaphore_free_hw_sema(struct channel_gk20a *ch) | 399 | void nvgpu_semaphore_free_hw_sema(struct channel_gk20a *ch) |
400 | { | 400 | { |
401 | struct nvgpu_semaphore_pool *p = ch->vm->sema_pool; | 401 | struct nvgpu_semaphore_pool *p = ch->vm->sema_pool; |
402 | struct nvgpu_semaphore_int *hw_sema = ch->hw_sema; | ||
403 | int idx = hw_sema->location.offset / SEMAPHORE_SIZE; | ||
402 | 404 | ||
403 | BUG_ON(!p); | 405 | BUG_ON(!p); |
404 | 406 | ||
405 | nvgpu_mutex_acquire(&p->pool_lock); | 407 | nvgpu_mutex_acquire(&p->pool_lock); |
406 | 408 | ||
407 | clear_bit(ch->hw_sema->idx, p->semas_alloced); | 409 | clear_bit(idx, p->semas_alloced); |
408 | 410 | ||
409 | /* Make sure that when the ch is re-opened it will get a new HW sema. */ | 411 | nvgpu_kfree(ch->g, hw_sema); |
410 | nvgpu_kfree(ch->g, ch->hw_sema); | ||
411 | ch->hw_sema = NULL; | 412 | ch->hw_sema = NULL; |
412 | 413 | ||
413 | nvgpu_mutex_release(&p->pool_lock); | 414 | nvgpu_mutex_release(&p->pool_lock); |
@@ -435,14 +436,15 @@ struct nvgpu_semaphore *nvgpu_semaphore_alloc(struct channel_gk20a *ch) | |||
435 | return NULL; | 436 | return NULL; |
436 | 437 | ||
437 | nvgpu_ref_init(&s->ref); | 438 | nvgpu_ref_init(&s->ref); |
438 | s->hw_sema = ch->hw_sema; | 439 | s->g = ch->g; |
440 | s->location = ch->hw_sema->location; | ||
439 | nvgpu_atomic_set(&s->value, 0); | 441 | nvgpu_atomic_set(&s->value, 0); |
440 | 442 | ||
441 | /* | 443 | /* |
442 | * Take a ref on the pool so that we can keep this pool alive for | 444 | * Take a ref on the pool so that we can keep this pool alive for |
443 | * as long as this semaphore is alive. | 445 | * as long as this semaphore is alive. |
444 | */ | 446 | */ |
445 | nvgpu_semaphore_pool_get(s->hw_sema->p); | 447 | nvgpu_semaphore_pool_get(s->location.pool); |
446 | 448 | ||
447 | gpu_sema_dbg(ch->g, "Allocated semaphore (c=%d)", ch->chid); | 449 | gpu_sema_dbg(ch->g, "Allocated semaphore (c=%d)", ch->chid); |
448 | 450 | ||
@@ -454,9 +456,9 @@ static void nvgpu_semaphore_free(struct nvgpu_ref *ref) | |||
454 | struct nvgpu_semaphore *s = | 456 | struct nvgpu_semaphore *s = |
455 | container_of(ref, struct nvgpu_semaphore, ref); | 457 | container_of(ref, struct nvgpu_semaphore, ref); |
456 | 458 | ||
457 | nvgpu_semaphore_pool_put(s->hw_sema->p); | 459 | nvgpu_semaphore_pool_put(s->location.pool); |
458 | 460 | ||
459 | nvgpu_kfree(s->hw_sema->ch->g, s); | 461 | nvgpu_kfree(s->g, s); |
460 | } | 462 | } |
461 | 463 | ||
462 | void nvgpu_semaphore_put(struct nvgpu_semaphore *s) | 464 | void nvgpu_semaphore_put(struct nvgpu_semaphore *s) |