From 89ec2afbd4538fe5036bef7affed5871d45ec734 Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Wed, 28 Apr 2021 20:23:41 +0530 Subject: [PATCH] gpu: nvgpu: fix tsg unbind failure paths nvgpu_tsg_unbind_channel_common failure handling missed channel.clear & nvgpu_tsg_set_mmu_debug_mode calls. Bug 200711183 Change-Id: I19fd53be55db9df725b7cf467b2673e4cd29deb5 Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2521972 Tested-by: mobile promotions Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Antony Clince Alex Reviewed-by: Vijayakumar Subbu Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/fifo/tsg.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/gpu/nvgpu/common/fifo/tsg.c b/drivers/gpu/nvgpu/common/fifo/tsg.c index 3ab9a379a..9c40687e1 100644 --- a/drivers/gpu/nvgpu/common/fifo/tsg.c +++ b/drivers/gpu/nvgpu/common/fifo/tsg.c @@ -311,11 +311,27 @@ fail: ch->chid, tsg->tsgid); nvgpu_tsg_abort(g, tsg, true); + + if (g->ops.channel.clear != NULL) { + g->ops.channel.clear(ch); + } + /* If channel unbind fails, channel is still part of runlist */ if (nvgpu_channel_update_runlist(ch, false) != 0) { nvgpu_err(g, "remove ch %u from runlist failed", ch->chid); } +#ifdef CONFIG_NVGPU_DEBUGGER + while (ch->mmu_debug_mode_refcnt > 0U) { + err = nvgpu_tsg_set_mmu_debug_mode(ch, false); + if (err != 0) { + nvgpu_err(g, "disable mmu debug mode failed ch:%u", + ch->chid); + break; + } + } +#endif + nvgpu_rwsem_down_write(&tsg->ch_list_lock); nvgpu_list_del(&ch->ch_entry); ch->tsgid = NVGPU_INVALID_TSG_ID;