From 708593430377c90edd002789513a6ae59f0c0985 Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Sun, 24 Jul 2022 07:26:26 +0530 Subject: [PATCH] gpu: nvgpu: update channel TSG unbind fail paths On tsg.unbind_channel hal failure, channel teardown was being done again that was done already as part of the function nvgpu_tsg_unbind_channel_common. Just abort the TSG and return err in that case. Also, decrement the TSG ch_count in the fail path. Bug 3677982 Change-Id: I466f2b2c693d43ed64dc531b08bf740bf00f28a6 Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2749970 Reviewed-by: svcacv Reviewed-by: Vaibhav Kachore --- drivers/gpu/nvgpu/common/fifo/tsg.c | 7 ++++--- drivers/gpu/nvgpu/include/nvgpu/tsg.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nvgpu/common/fifo/tsg.c b/drivers/gpu/nvgpu/common/fifo/tsg.c index 09e1cedb7..40e30191e 100644 --- a/drivers/gpu/nvgpu/common/fifo/tsg.c +++ b/drivers/gpu/nvgpu/common/fifo/tsg.c @@ -347,13 +347,13 @@ int nvgpu_tsg_unbind_channel(struct nvgpu_tsg *tsg, struct nvgpu_channel *ch, */ (void) nvgpu_channel_mark_error(g, ch); nvgpu_err(g, "unbind hal failed, err=%d", err); - goto fail; + nvgpu_tsg_abort(g, tsg, true); } } nvgpu_ref_put(&tsg->refcount, nvgpu_tsg_release); - return 0; + return err; fail_common: if (g->ops.tsg.unbind_channel != NULL) { @@ -362,7 +362,7 @@ fail_common: nvgpu_err(g, "unbind hal failed, err=%d", unbind_err); } } -fail: + nvgpu_err(g, "Channel %d unbind failed, tearing down TSG %d", ch->chid, tsg->tsgid); @@ -399,6 +399,7 @@ fail: nvgpu_rwsem_down_write(&tsg->ch_list_lock); nvgpu_list_del(&ch->ch_entry); ch->tsgid = NVGPU_INVALID_TSG_ID; + tsg->ch_count = nvgpu_safe_sub_u32(tsg->ch_count, 1U); nvgpu_rwsem_up_write(&tsg->ch_list_lock); nvgpu_ref_put(&tsg->refcount, nvgpu_tsg_release); diff --git a/drivers/gpu/nvgpu/include/nvgpu/tsg.h b/drivers/gpu/nvgpu/include/nvgpu/tsg.h index 8f8a6edf8..36f907cd7 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/tsg.h +++ b/drivers/gpu/nvgpu/include/nvgpu/tsg.h @@ -456,6 +456,7 @@ struct nvgpu_tsg *nvgpu_tsg_check_and_get_from_id(struct gk20a *g, u32 tsgid); * - Call #nvgpu_channel_update_runlist to remove the channel from the runlist. * - Acquire #nvgpu_tsg.ch_list_lock of the tsg and delete channel from * #nvgpu_tsg.ch_list. + * - Remove channel from TSG's channel list. * - Set #nvgpu_channel.tsgid to #NVGPU_INVALID_TSG_ID * - Release #nvgpu_tsg.ch_list_lock of the tsg. * Call non NULL HAL to unbind channel from the tsg. This HAL is vgpu specific