summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLakshmanan M <lm@nvidia.com>2016-08-03 10:55:03 -0400
committerTerje Bergstrom <tbergstrom@nvidia.com>2016-08-10 16:37:47 -0400
commit394da0f2210ad298b3ecdfddc7ab0c57124cd7d0 (patch)
tree3cd29ce0f360951236c8644599ece3da97f83d48 /drivers
parent59a115f3fe6076de4c9af69de836cc82d6430544 (diff)
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 <lm@nvidia.com> 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 <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/nvgpu/gk20a/channel_gk20a.c7
-rw-r--r--drivers/gpu/nvgpu/gk20a/semaphore_gk20a.c25
-rw-r--r--drivers/gpu/nvgpu/gk20a/semaphore_gk20a.h3
3 files changed, 29 insertions, 6 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
index 85b77199..eae2bdae 100644
--- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
@@ -978,6 +978,10 @@ unbind:
978 g->ops.fifo.unbind_channel(ch); 978 g->ops.fifo.unbind_channel(ch);
979 g->ops.fifo.free_inst(g, ch); 979 g->ops.fifo.free_inst(g, ch);
980 980
981 /* free the channel used semaphore index */
982 if (ch->hw_sema)
983 gk20a_semaphore_free_hw_sema(ch);
984
981 ch->vpr = false; 985 ch->vpr = false;
982 ch->vm = NULL; 986 ch->vm = NULL;
983 987
@@ -1006,9 +1010,6 @@ unbind:
1006 1010
1007 mutex_unlock(&g->dbg_sessions_lock); 1011 mutex_unlock(&g->dbg_sessions_lock);
1008 1012
1009 /* Make sure that when the ch is re-opened it will get a new HW sema. */
1010 ch->hw_sema = NULL;
1011
1012 /* make sure we catch accesses of unopened channels in case 1013 /* make sure we catch accesses of unopened channels in case
1013 * there's non-refcounted channel pointers hanging around */ 1014 * there's non-refcounted channel pointers hanging around */
1014 ch->g = NULL; 1015 ch->g = NULL;
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);
diff --git a/drivers/gpu/nvgpu/gk20a/semaphore_gk20a.h b/drivers/gpu/nvgpu/gk20a/semaphore_gk20a.h
index 58081b56..29a01ab8 100644
--- a/drivers/gpu/nvgpu/gk20a/semaphore_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/semaphore_gk20a.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License, 5 * under the terms and conditions of the GNU General Public License,
@@ -174,6 +174,7 @@ void gk20a_semaphore_pool_put(struct gk20a_semaphore_pool *p);
174struct gk20a_semaphore *gk20a_semaphore_alloc(struct channel_gk20a *ch); 174struct gk20a_semaphore *gk20a_semaphore_alloc(struct channel_gk20a *ch);
175void gk20a_semaphore_put(struct gk20a_semaphore *s); 175void gk20a_semaphore_put(struct gk20a_semaphore *s);
176void gk20a_semaphore_get(struct gk20a_semaphore *s); 176void gk20a_semaphore_get(struct gk20a_semaphore *s);
177void gk20a_semaphore_free_hw_sema(struct channel_gk20a *ch);
177 178
178/* 179/*
179 * Return the address of a specific semaphore. 180 * Return the address of a specific semaphore.