From 394da0f2210ad298b3ecdfddc7ab0c57124cd7d0 Mon Sep 17 00:00:00 2001 From: Lakshmanan M Date: Wed, 3 Aug 2016 20:25:03 +0530 Subject: gpu: nvgpu: Free the channel used semaphore index Free the channel used semaphore index during gk20a_free_channel(). Bug 1793819 Change-Id: I4215d05f7f3ba0636e2abb1803011711c8a38301 Signed-off-by: Lakshmanan M Reviewed-on: http://git-master/r/1196877 (cherry picked from commit 2c5720de506caac29629f6a1c578e6da80b1a135) Reviewed-on: http://git-master/r/1198883 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/semaphore_gk20a.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/semaphore_gk20a.c') 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 @@ * * GK20A Semaphores * - * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -363,6 +363,27 @@ fail: return ret; } +/* + * Free the channel used semaphore index + */ +void gk20a_semaphore_free_hw_sema(struct channel_gk20a *ch) +{ + struct gk20a_semaphore_pool *p = ch->vm->sema_pool; + + BUG_ON(!p); + + mutex_lock(&p->pool_lock); + + clear_bit(ch->hw_sema->idx, p->semas_alloced); + + /* Make sure that when the ch is re-opened it will get a new HW sema. */ + list_del(&ch->hw_sema->hw_sema_list); + kfree(ch->hw_sema); + ch->hw_sema = NULL; + + mutex_unlock(&p->pool_lock); +} + /* * Allocate a semaphore from the passed pool. * @@ -377,7 +398,7 @@ struct gk20a_semaphore *gk20a_semaphore_alloc(struct channel_gk20a *ch) if (!ch->hw_sema) { ret = __gk20a_init_hw_sema(ch); if (ret) - return ERR_PTR(ret); + return NULL; } s = kzalloc(sizeof(*s), GFP_KERNEL); -- cgit v1.2.2