From 4d101a63033a7a1cad5aa999d0c96b2f6d1f1735 Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Sun, 8 Nov 2020 22:16:44 +0530 Subject: [PATCH] gpu: nvgpu: do tsg unbind hw state check only for multi-channel TSG Host scheduler might be confused if more than one channels are present in TSG and one of the unbound channel has NEXT set. This is not so much of an issue if there is single channel in the TSG. So don't fail unbind in that case. ctx_reload and engine_faulted check can also be skipped for single channel TSG. Bug 3144960 Change-Id: I85eb9025ea53706ce8fda6d9b4bcf6a15a300d17 Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2442970 Reviewed-by: automaticguardword Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Deepak Nibade Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/fifo/tsg.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/common/fifo/tsg.c b/drivers/gpu/nvgpu/common/fifo/tsg.c index 25883e481..071f63b39 100644 --- a/drivers/gpu/nvgpu/common/fifo/tsg.c +++ b/drivers/gpu/nvgpu/common/fifo/tsg.c @@ -150,6 +150,22 @@ int nvgpu_tsg_bind_channel(struct nvgpu_tsg *tsg, struct nvgpu_channel *ch) return err; } +static bool nvgpu_tsg_is_multi_channel(struct nvgpu_tsg *tsg) +{ + bool ret = false; + + nvgpu_rwsem_down_read(&tsg->ch_list_lock); + if (nvgpu_list_first_entry(&tsg->ch_list, nvgpu_channel, + ch_entry) != + nvgpu_list_last_entry(&tsg->ch_list, nvgpu_channel, + ch_entry)) { + ret = true; + } + nvgpu_rwsem_up_read(&tsg->ch_list_lock); + + return ret; +} + static int nvgpu_tsg_unbind_channel_common(struct nvgpu_tsg *tsg, struct nvgpu_channel *ch) { @@ -170,7 +186,11 @@ static int nvgpu_tsg_unbind_channel_common(struct nvgpu_tsg *tsg, goto fail_enable_tsg; } - if (!tsg_timedout && + /* + * State validation is only necessary if there are multiple channels in + * the TSG. + */ + if (nvgpu_tsg_is_multi_channel(tsg) && !tsg_timedout && (g->ops.tsg.unbind_channel_check_hw_state != NULL)) { err = g->ops.tsg.unbind_channel_check_hw_state(tsg, ch); if (err != 0) {