From d16c164863511289bbbc41129bd2a25d68ba7188 Mon Sep 17 00:00:00 2001 From: Shashank Singh Date: Wed, 10 Apr 2019 23:09:03 +0530 Subject: [PATCH] gpu: nvgpu: move os_channel close after unbind Move os_channel close after tsg unbind which internally sets syncpoint to a safe value. Otherwise it causes syncpoint wait in syncpt waiter thread to block indefinitely if signaler is killed. Bug 200509048 Change-Id: Ifcb3c2efcabd94c0a4f7da3975db316926003cb5 Signed-off-by: Shashank Singh Reviewed-on: https://git-master.nvidia.com/r/2094476 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/fifo/channel.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/nvgpu/common/fifo/channel.c b/drivers/gpu/nvgpu/common/fifo/channel.c index 66ae722b0..a53b3b33d 100644 --- a/drivers/gpu/nvgpu/common/fifo/channel.c +++ b/drivers/gpu/nvgpu/common/fifo/channel.c @@ -321,10 +321,6 @@ static void gk20a_free_channel(struct channel_gk20a *ch, bool force) trace_gk20a_free_channel(ch->chid); - if (g->os_channel.close != NULL) { - g->os_channel.close(ch, force); - } - /* * Disable channel/TSG and unbind here. This should not be executed if * HW access is not available during shutdown/removal path as it will @@ -353,6 +349,18 @@ static void gk20a_free_channel(struct channel_gk20a *ch, bool force) */ } } + + /* + * OS channel close may require that syncpoint should be set to some + * safe value before it is called. nvgpu_tsg_unbind_channel(above) is + * internally doing that by calling nvgpu_nvhost_syncpt_set_safe_state + * deep down in the stack. Otherwise os_channel close may block if the + * app is killed abruptly (which was going to do the syncpoint signal). + */ + if (g->os_channel.close != NULL) { + g->os_channel.close(ch, force); + } + /* wait until there's only our ref to the channel */ if (!force) { gk20a_wait_until_counter_is_N(