From f9cb1a93d1f861ffd56aa8cfc710dd2659934f8b Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Thu, 11 Sep 2014 20:01:23 +0530 Subject: gpu: nvgpu: do not bind already active channels to TSG If a channel is already scheduled as regular channel, we should not allow it to be marked as TSG since it will fail book keeping of number of active channels in a TSG This way we can force to bind the channels first and then only make them active Also, remove duplicate function declaration added during branch merge and one unnecessary comparison with zero Bug 1470692 Change-Id: I88f9678919e4b76de472c6dda21e4537520241c4 Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/497903 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/tsg_gk20a.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/tsg_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c index c84e8d0b..98e1ae2c 100644 --- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c @@ -27,13 +27,26 @@ static void gk20a_tsg_release(struct kref *ref); -static void gk20a_tsg_release(struct kref *ref); - bool gk20a_is_channel_marked_as_tsg(struct channel_gk20a *ch) { return !(ch->tsgid == NVGPU_INVALID_TSG_ID); } +static bool gk20a_is_channel_active(struct gk20a *g, struct channel_gk20a *ch) +{ + struct fifo_gk20a *f = &g->fifo; + struct fifo_runlist_info_gk20a *runlist; + int i; + + for (i = 0; i < f->max_runlists; ++i) { + runlist = &f->runlist_info[i]; + if (test_bit(ch->hw_chid, runlist->active_channels)) + return true; + } + + return false; +} + /* * API to mark channel as part of TSG * @@ -50,6 +63,12 @@ static int gk20a_tsg_bind_channel(struct tsg_gk20a *tsg, int ch_fd) return -EINVAL; } + /* channel cannot be bound to TSG if it is already active */ + if (gk20a_is_channel_active(tsg->g, ch)) { + fput(f); + return -EINVAL; + } + ch->tsgid = tsg->tsgid; mutex_lock(&tsg->ch_list_lock); -- cgit v1.2.2