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 <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/497903
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
This commit is contained in:
Deepak Nibade
2014-09-11 20:01:23 +05:30
committed by Dan Willemsen
parent 27b94dfafd
commit f9cb1a93d1
2 changed files with 22 additions and 3 deletions

View File

@@ -1779,7 +1779,7 @@ static int gk20a_fifo_update_runlist_locked(struct gk20a *g, u32 runlist_id,
if (test_and_set_bit(hw_chid,
runlist->active_channels) == 1)
return 0;
if (tsg && ++tsg->num_active_channels > 0)
if (tsg && ++tsg->num_active_channels)
set_bit(f->channel[hw_chid].tsgid,
runlist->active_tsgs);
} else {

View File

@@ -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);