From e00804594b83781bc9f7c17ac68cd9c5dd30953c Mon Sep 17 00:00:00 2001 From: Seema Khowala Date: Thu, 27 Dec 2018 19:23:06 -0800 Subject: gpu: nvgpu: remove gk20a_is_channel_marked_as_tsg Use tsg_gk20a_from_ch to get tsg pointer for tsgid of a channel. For invalid tsgid, tsg pointer will be NULL Bug 2092051 Bug 2429295 Bug 2484211 Change-Id: I82cd6a2dc5fab4acb147202af667ca97a2842a73 Signed-off-by: Seema Khowala Reviewed-on: https://git-master.nvidia.com/r/2006722 Signed-off-by: Debarshi Dutta (cherry picked from commit 13f37f9c70b9ae2e0d179830cded93a0a6f86494 in dev-kernel) Reviewed-on: https://git-master.nvidia.com/r/2025507 GVS: Gerrit_Virtual_Submit Reviewed-by: Bibek Basu Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/fifo/tsg.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'drivers/gpu/nvgpu/common/fifo/tsg.c') diff --git a/drivers/gpu/nvgpu/common/fifo/tsg.c b/drivers/gpu/nvgpu/common/fifo/tsg.c index 9790553f..e6dfbae6 100644 --- a/drivers/gpu/nvgpu/common/fifo/tsg.c +++ b/drivers/gpu/nvgpu/common/fifo/tsg.c @@ -28,11 +28,6 @@ #include #include -bool gk20a_is_channel_marked_as_tsg(struct channel_gk20a *ch) -{ - return !(ch->tsgid == NVGPU_INVALID_TSG_ID); -} - int gk20a_enable_tsg(struct tsg_gk20a *tsg) { struct gk20a *g = tsg->g; @@ -116,7 +111,7 @@ int gk20a_tsg_bind_channel(struct tsg_gk20a *tsg, nvgpu_log_fn(g, " "); /* check if channel is already bound to some TSG */ - if (gk20a_is_channel_marked_as_tsg(ch)) { + if (tsg_gk20a_from_ch(ch) != NULL) { return -EINVAL; } @@ -125,7 +120,6 @@ int gk20a_tsg_bind_channel(struct tsg_gk20a *tsg, return -EINVAL; } - ch->tsgid = tsg->tsgid; /* all the channel part of TSG should need to be same runlist_id */ if (tsg->runlist_id == FIFO_INVAL_TSG_ID) { @@ -139,6 +133,7 @@ int gk20a_tsg_bind_channel(struct tsg_gk20a *tsg, nvgpu_rwsem_down_write(&tsg->ch_list_lock); nvgpu_list_add_tail(&ch->ch_entry, &tsg->ch_list); + ch->tsgid = tsg->tsgid; nvgpu_rwsem_up_write(&tsg->ch_list_lock); nvgpu_ref_get(&tsg->refcount); @@ -172,14 +167,13 @@ int gk20a_tsg_unbind_channel(struct channel_gk20a *ch) nvgpu_rwsem_down_write(&tsg->ch_list_lock); nvgpu_list_del(&ch->ch_entry); + ch->tsgid = NVGPU_INVALID_TSG_ID; nvgpu_rwsem_up_write(&tsg->ch_list_lock); } + nvgpu_log(g, gpu_dbg_fn, "UNBIND tsg:%d channel:%d", + tsg->tsgid, ch->chid); nvgpu_ref_put(&tsg->refcount, gk20a_tsg_release); - ch->tsgid = NVGPU_INVALID_TSG_ID; - - nvgpu_log(g, gpu_dbg_fn, "UNBIND tsg:%d channel:%d\n", - tsg->tsgid, ch->chid); return 0; } @@ -395,13 +389,17 @@ void gk20a_tsg_release(struct nvgpu_ref *ref) struct tsg_gk20a *tsg_gk20a_from_ch(struct channel_gk20a *ch) { struct tsg_gk20a *tsg = NULL; + u32 tsgid = ch->tsgid; - if (gk20a_is_channel_marked_as_tsg(ch)) { + if (tsgid != NVGPU_INVALID_TSG_ID) { struct gk20a *g = ch->g; struct fifo_gk20a *f = &g->fifo; - tsg = &f->tsg[ch->tsgid]; - } + tsg = &f->tsg[tsgid]; + } else { + nvgpu_log(ch->g, gpu_dbg_fn, "tsgid is invalid for chid: %d", + ch->chid); + } return tsg; } -- cgit v1.2.2