summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/semaphore_gk20a.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/semaphore_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/semaphore_gk20a.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/semaphore_gk20a.c b/drivers/gpu/nvgpu/gk20a/semaphore_gk20a.c
index d513fa84..396e7419 100644
--- a/drivers/gpu/nvgpu/gk20a/semaphore_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/semaphore_gk20a.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * GK20A Semaphores 4 * GK20A Semaphores
5 * 5 *
6 * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved. 6 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License, 9 * under the terms and conditions of the GNU General Public License,
@@ -364,6 +364,27 @@ fail:
364} 364}
365 365
366/* 366/*
367 * Free the channel used semaphore index
368 */
369void gk20a_semaphore_free_hw_sema(struct channel_gk20a *ch)
370{
371 struct gk20a_semaphore_pool *p = ch->vm->sema_pool;
372
373 BUG_ON(!p);
374
375 mutex_lock(&p->pool_lock);
376
377 clear_bit(ch->hw_sema->idx, p->semas_alloced);
378
379 /* Make sure that when the ch is re-opened it will get a new HW sema. */
380 list_del(&ch->hw_sema->hw_sema_list);
381 kfree(ch->hw_sema);
382 ch->hw_sema = NULL;
383
384 mutex_unlock(&p->pool_lock);
385}
386
387/*
367 * Allocate a semaphore from the passed pool. 388 * Allocate a semaphore from the passed pool.
368 * 389 *
369 * Since semaphores are ref-counted there's no explicit free for external code 390 * Since semaphores are ref-counted there's no explicit free for external code
@@ -377,7 +398,7 @@ struct gk20a_semaphore *gk20a_semaphore_alloc(struct channel_gk20a *ch)
377 if (!ch->hw_sema) { 398 if (!ch->hw_sema) {
378 ret = __gk20a_init_hw_sema(ch); 399 ret = __gk20a_init_hw_sema(ch);
379 if (ret) 400 if (ret)
380 return ERR_PTR(ret); 401 return NULL;
381 } 402 }
382 403
383 s = kzalloc(sizeof(*s), GFP_KERNEL); 404 s = kzalloc(sizeof(*s), GFP_KERNEL);