From d00a8fd09a8896ca643b39289962c26fd9bcc6d4 Mon Sep 17 00:00:00 2001 From: mkumbar Date: Wed, 29 Jun 2022 23:09:49 +0530 Subject: [PATCH] gpu: nvgpu: Disable TSG before unbinding channel Disable TSG before unbinding channel to fix the ap_systemsw nvgpu_ctxsw_trace_twod test failure with AELPG power feature enabled. Bug 3695626 Change-Id: I55939b6b352da5f3f38b31440366a17d89ff7c20 Signed-off-by: mkumbar Signed-off-by: Mahantesh Kumbar Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2740027 Reviewed-by: svcacv Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: Rajesh Devaraj Reviewed-by: Ankur Kishore GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/os/linux/ioctl_channel.c | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c index 5eeff9e52..0783e613f 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c @@ -1498,7 +1498,31 @@ long gk20a_channel_ioctl(struct file *filp, __func__, cmd); break; } + + /* Disable TSG and examine status before unbinding channel */ + err = nvgpu_channel_disable_tsg(ch->g, ch); + if (err) { + dev_err(dev, + "%s: failed to disable channel/TSG for ioctl cmd: 0x%x", + __func__, cmd); + + gk20a_idle(ch->g); + + break; + } + err = nvgpu_preempt_channel(ch->g, ch); + if (err) + dev_err(dev, + "%s: failed to preempt channel for ioctl cmd: 0x%x", + __func__, cmd); + + err = nvgpu_channel_enable_tsg(ch->g, ch); + if (err) + dev_err(dev, + "%s: failed to re-enable channel/TSG for ioctl cmd: 0x%x", + __func__, cmd); + gk20a_idle(ch->g); break; case NVGPU_IOCTL_CHANNEL_RESCHEDULE_RUNLIST: