From f64b5e20b0b9da6ef84b7c893f2adff2e6db9aa7 Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Thu, 21 Oct 2021 11:20:26 +0530 Subject: [PATCH] gpu: nvgpu: add unit test for gk20a_tsg_unbind_channel_check_hw_next false branch when NEXT bit is not set is not covered. Add unit test for same. JIRA NVGPU-7211 Change-Id: I57725e35971605bf8144e7eaac618f44a38e5b31 Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2614209 (cherry picked from commit 2064209f92700dc859d7398e061b3d7dc2725521) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2623628 Reviewed-by: Vaibhav Kachore Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- userspace/units/fifo/tsg/nvgpu-tsg.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/userspace/units/fifo/tsg/nvgpu-tsg.c b/userspace/units/fifo/tsg/nvgpu-tsg.c index 3be647044..731c4546c 100644 --- a/userspace/units/fifo/tsg/nvgpu-tsg.c +++ b/userspace/units/fifo/tsg/nvgpu-tsg.c @@ -765,12 +765,14 @@ done: } #define F_TSG_UNBIND_CHANNEL_CHECK_HW_NEXT BIT(0) -#define F_TSG_UNBIND_CHANNEL_CHECK_HW_CTX_RELOAD BIT(1) -#define F_TSG_UNBIND_CHANNEL_CHECK_HW_ENG_FAULTED BIT(2) -#define F_TSG_UNBIND_CHANNEL_CHECK_HW_LAST BIT(3) +#define F_TSG_UNBIND_CHANNEL_CHECK_HW_NEXT_CLR BIT(1) +#define F_TSG_UNBIND_CHANNEL_CHECK_HW_CTX_RELOAD BIT(2) +#define F_TSG_UNBIND_CHANNEL_CHECK_HW_ENG_FAULTED BIT(3) +#define F_TSG_UNBIND_CHANNEL_CHECK_HW_LAST BIT(4) static const char *f_tsg_unbind_channel_check_hw[] = { "next", + "next clear", "ctx_reload", "eng_faulted", }; @@ -781,6 +783,12 @@ static void stub_channel_read_state_NEXT(struct gk20a *g, state->next = true; } +static void stub_channel_read_state_NEXT_CLR(struct gk20a *g, + struct nvgpu_channel *ch, struct nvgpu_channel_hw_state *state) +{ + state->next = false; +} + int test_tsg_unbind_channel_check_hw_state(struct unit_module *m, struct gk20a *g, void *args) { @@ -814,9 +822,15 @@ int test_tsg_unbind_channel_check_hw_state(struct unit_module *m, unit_verbose(m, "%s branches=%s\n", __func__, branches_str(branches, f_tsg_unbind_channel_check_hw)); - g->ops.channel.read_state = - branches & F_TSG_UNBIND_CHANNEL_CHECK_HW_NEXT ? - stub_channel_read_state_NEXT : gops.channel.read_state; + if (branches & F_TSG_UNBIND_CHANNEL_CHECK_HW_NEXT) { + g->ops.channel.read_state = + stub_channel_read_state_NEXT; + } else if (branches & F_TSG_UNBIND_CHANNEL_CHECK_HW_NEXT_CLR) { + g->ops.channel.read_state = + stub_channel_read_state_NEXT_CLR; + } else { + g->ops.channel.read_state = gops.channel.read_state; + } g->ops.tsg.unbind_channel_check_ctx_reload = branches & F_TSG_UNBIND_CHANNEL_CHECK_HW_CTX_RELOAD ?