From 33f475d6d871a0edfa7e02da9ba1706bfb362192 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Tue, 26 Sep 2017 06:38:19 -0700 Subject: gpu: nvgpu: kill TSG if channel has NEXT set while closing Currently if channel has NEXT bit set while closing the channel we just print an error and continue channel unbind sequence from TSG But since channel with NEXT set is active killing it can potentially corrupt the TSG context and cause unpredictable errors on remaining channels/TSG Hence fix this by killing whole TSG context if channel being closed has NEXT bit set if gk20a_fifo_tsg_unbind_channel() API returns error, kill the TSG otherwise continue with channel unbind sequence Bug 200327095 Change-Id: I2abf1a3db8ba6f105b6ca86e78006c7b2a7726cc Signed-off-by: Deepak Nibade Reviewed-on: https://git-master.nvidia.com/r/1568566 Reviewed-by: svc-mobile-coverity Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Konsta Holtta Reviewed-by: Vijayakumar Subbu --- drivers/gpu/nvgpu/gk20a/tsg_gk20a.c | 14 ++++++++++++-- 1 file changed, 12 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 e285f96c..6c1c2955 100644 --- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c @@ -150,8 +150,18 @@ int gk20a_tsg_unbind_channel(struct channel_gk20a *ch) int err; err = gk20a_fifo_tsg_unbind_channel(ch); - if (err) - return err; + if (err) { + nvgpu_err(g, "Channel %d unbind failed, tearing down TSG %d", + ch->chid, tsg->tsgid); + + gk20a_fifo_abort_tsg(ch->g, ch->tsgid, true); + /* If channel unbind fails, channel is still part of runlist */ + channel_gk20a_update_runlist(ch, false); + + down_write(&tsg->ch_list_lock); + nvgpu_list_del(&ch->ch_entry); + up_write(&tsg->ch_list_lock); + } nvgpu_ref_put(&tsg->refcount, gk20a_tsg_release); ch->tsgid = NVGPU_INVALID_TSG_ID; -- cgit v1.2.2