From 06f554318ad4bafe23643161856fcaa5826ee99d Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Fri, 29 Jan 2021 15:27:50 -0600 Subject: [PATCH] userspace: Update unit tests to use new .id and .runlist fields Update the unit test code to reflect the following changes: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2470305 https://git-master.nvidia.com/r/c/linux-nvgpu/+/2470306 These adjust field names/types in struct nvgpu_runlist and struct nvgpu_tsg; no functional changes are made but these do affect the unit tests that rely on setting these private fields. JIRA NVGPU-6425 Change-Id: I1fc9d56e363d326f1e6901aaec710903894ac61d Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2477585 Tested-by: mobile promotions Reviewed-by: Tejal Kudav Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit --- libs/dgpu/libnvgpu-drv-dgpu_safe.export | 2 - libs/igpu/libnvgpu-drv-igpu_safe.export | 2 - userspace/required_tests.ini | 1 - .../fifo/preempt/gv11b/nvgpu-preempt-gv11b.c | 4 +- userspace/units/fifo/preempt/nvgpu-preempt.c | 2 +- .../units/fifo/tsg/gv11b/nvgpu-tsg-gv11b.c | 8 ++- userspace/units/fifo/tsg/nvgpu-tsg.c | 57 +------------------ userspace/units/fifo/tsg/nvgpu-tsg.h | 25 -------- 8 files changed, 11 insertions(+), 90 deletions(-) diff --git a/libs/dgpu/libnvgpu-drv-dgpu_safe.export b/libs/dgpu/libnvgpu-drv-dgpu_safe.export index 7dbb7b7ea..846646e05 100644 --- a/libs/dgpu/libnvgpu-drv-dgpu_safe.export +++ b/libs/dgpu/libnvgpu-drv-dgpu_safe.export @@ -689,8 +689,6 @@ nvgpu_tsg_check_and_get_from_id nvgpu_tsg_cleanup_sw nvgpu_tsg_default_timeslice_us nvgpu_tsg_disable -nvgpu_tsg_disable_sched -nvgpu_tsg_enable_sched nvgpu_tsg_from_ch nvgpu_tsg_get_from_id nvgpu_tsg_mark_error diff --git a/libs/igpu/libnvgpu-drv-igpu_safe.export b/libs/igpu/libnvgpu-drv-igpu_safe.export index d81fa9d44..6290c6efe 100644 --- a/libs/igpu/libnvgpu-drv-igpu_safe.export +++ b/libs/igpu/libnvgpu-drv-igpu_safe.export @@ -704,8 +704,6 @@ nvgpu_tsg_check_and_get_from_id nvgpu_tsg_cleanup_sw nvgpu_tsg_default_timeslice_us nvgpu_tsg_disable -nvgpu_tsg_disable_sched -nvgpu_tsg_enable_sched nvgpu_tsg_from_ch nvgpu_tsg_get_from_id nvgpu_tsg_mark_error diff --git a/userspace/required_tests.ini b/userspace/required_tests.ini index 97afdd9e5..fa515b2e6 100644 --- a/userspace/required_tests.ini +++ b/userspace/required_tests.ini @@ -772,7 +772,6 @@ test_tsg_abort.abort=0 test_tsg_bind_channel.bind_channel=2 test_tsg_check_and_get_from_id.get_from_id=0 test_tsg_enable.enable_disable=0 -test_tsg_enable_sched.enable_disable_sched=0 test_tsg_mark_error.mark_error=0 test_tsg_open.open=0 test_tsg_release.release=0 diff --git a/userspace/units/fifo/preempt/gv11b/nvgpu-preempt-gv11b.c b/userspace/units/fifo/preempt/gv11b/nvgpu-preempt-gv11b.c index 9fd6257c0..ba4f3bc77 100644 --- a/userspace/units/fifo/preempt/gv11b/nvgpu-preempt-gv11b.c +++ b/userspace/units/fifo/preempt/gv11b/nvgpu-preempt-gv11b.c @@ -261,8 +261,8 @@ int test_gv11b_fifo_preempt_tsg(struct unit_module *m, struct gk20a *g, unit_verbose(m, "%s branches=%s\n", __func__, branches_str(branches, f_preempt_tsg)); - tsg->runlist_id = branches & F_PREEMPT_TSG_RUNLIST_ID_INVALID ? - NVGPU_INVALID_RUNLIST_ID : 0U; + tsg->runlist = branches & F_PREEMPT_TSG_RUNLIST_ID_INVALID ? + NULL : &g->fifo.active_runlists[0]; g->ops.fifo.is_preempt_pending = branches & F_PREEMPT_TSG_PREEMPT_LOCKED_FAIL ? diff --git a/userspace/units/fifo/preempt/nvgpu-preempt.c b/userspace/units/fifo/preempt/nvgpu-preempt.c index a32f99bed..d77df7150 100644 --- a/userspace/units/fifo/preempt/nvgpu-preempt.c +++ b/userspace/units/fifo/preempt/nvgpu-preempt.c @@ -199,7 +199,7 @@ int test_preempt_poll_tsg_on_pbdma(struct unit_module *m, struct gk20a *g, tsg = nvgpu_tsg_open(g, getpid()); unit_assert(tsg != NULL, goto done); - tsg->runlist_id = 0; + tsg->runlist = &f->active_runlists[0]; for (branches = 0U; branches < F_PREEMPT_POLL_LAST; branches++) { diff --git a/userspace/units/fifo/tsg/gv11b/nvgpu-tsg-gv11b.c b/userspace/units/fifo/tsg/gv11b/nvgpu-tsg-gv11b.c index dcb3397b9..b4efdfb7a 100644 --- a/userspace/units/fifo/tsg/gv11b/nvgpu-tsg-gv11b.c +++ b/userspace/units/fifo/tsg/gv11b/nvgpu-tsg-gv11b.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -297,10 +297,12 @@ int test_gv11b_tsg_bind_channel_eng_method_buffers(struct unit_module *m, NULL : eng_method_buffers; if (branches & F_TSG_BIND_BUF_FAST_CE_RUNLIST_ID) { - tsg->runlist_id = nvgpu_engine_get_fast_ce_runlist_id(g); + tsg->runlist = g->fifo.runlists[ + nvgpu_engine_get_fast_ce_runlist_id(g)]; gpu_va = eng_method_buffers[ASYNC_CE_RUNQUE].gpu_va; } else { - tsg->runlist_id = nvgpu_engine_get_gr_runlist_id(g); + tsg->runlist = g->fifo.runlists[ + nvgpu_engine_get_gr_runlist_id(g)]; gpu_va = eng_method_buffers[GR_RUNQUE].gpu_va; } diff --git a/userspace/units/fifo/tsg/nvgpu-tsg.c b/userspace/units/fifo/tsg/nvgpu-tsg.c index 517246350..11e0468e2 100644 --- a/userspace/units/fifo/tsg/nvgpu-tsg.c +++ b/userspace/units/fifo/tsg/nvgpu-tsg.c @@ -286,7 +286,6 @@ static int stub_tsg_bind_channel(struct nvgpu_tsg *tsg, int test_tsg_bind_channel(struct unit_module *m, struct gk20a *g, void *args) { - struct nvgpu_fifo *f = &g->fifo; struct gpu_ops gops = g->ops; struct nvgpu_tsg *tsg = NULL; struct nvgpu_tsg tsg_save; @@ -339,12 +338,12 @@ int test_tsg_bind_channel(struct unit_module *m, } /* runlist id mismatch */ - tsg->runlist_id = + tsg->runlist = branches & F_TSG_BIND_CHANNEL_RL_MISMATCH ? - 0xffffffff : tsg_save.runlist_id; + NULL : tsg_save.runlist; /* ch already already active */ - runlist = &f->active_runlists[tsg->runlist_id]; + runlist = tsg->runlist; if (branches & F_TSG_BIND_CHANNEL_ACTIVE) { nvgpu_set_bit(ch->chid, runlist->active_channels); } else { @@ -1065,55 +1064,6 @@ done: return ret; } -static void stub_runlist_write_state(struct gk20a *g, - u32 runlists_mask, u32 runlist_state) -{ - stub[0].runlist_mask = runlists_mask; - stub[0].runlist_state = runlist_state; -} - -int test_tsg_enable_sched(struct unit_module *m, - struct gk20a *g, void *args) -{ - struct gpu_ops gops = g->ops; - struct nvgpu_tsg *tsg = NULL; - struct nvgpu_channel *ch = NULL; - int ret = UNIT_FAIL; - int err; - - g->ops.runlist.write_state = stub_runlist_write_state; - - tsg = nvgpu_tsg_open(g, getpid()); - unit_assert(tsg != NULL, goto done); - - ch = nvgpu_channel_open_new(g, ~0U, false, getpid(), getpid()); - unit_assert(ch != NULL, goto done); - - err = nvgpu_tsg_bind_channel(tsg, ch); - unit_assert(err == 0, goto done); - - memset(stub, 0, sizeof(stub)); - nvgpu_tsg_enable_sched(g, tsg); - unit_assert(stub[0].runlist_mask == BIT(tsg->runlist_id), goto done); - unit_assert(stub[0].runlist_state == RUNLIST_ENABLED, goto done); - - memset(stub, 0, sizeof(stub)); - nvgpu_tsg_disable_sched(g, tsg); - unit_assert(stub[0].runlist_mask == BIT(tsg->runlist_id), goto done); - unit_assert(stub[0].runlist_state == RUNLIST_DISABLED, goto done); - - ret = UNIT_SUCCESS; -done: - if (ch != NULL) { - nvgpu_channel_close(ch); - } - if (tsg != NULL) { - nvgpu_ref_put(&tsg->refcount, nvgpu_tsg_release); - } - g->ops = gops; - return ret; -} - int test_tsg_check_and_get_from_id(struct unit_module *m, struct gk20a *g, void *args) { @@ -1546,7 +1496,6 @@ struct unit_module_test nvgpu_tsg_tests[] = { UNIT_TEST(unbind_channel_check_ctx_reload, test_tsg_unbind_channel_check_ctx_reload, &unit_ctx, 0), UNIT_TEST(enable_disable, test_tsg_enable, &unit_ctx, 0), - UNIT_TEST(enable_disable_sched, test_tsg_enable_sched, &unit_ctx, 0), UNIT_TEST(abort, test_tsg_abort, &unit_ctx, 0), UNIT_TEST(mark_error, test_tsg_mark_error, &unit_ctx, 0), UNIT_TEST(set_ctx_mmu_error, test_tsg_set_ctx_mmu_error, &unit_ctx, 0), diff --git a/userspace/units/fifo/tsg/nvgpu-tsg.h b/userspace/units/fifo/tsg/nvgpu-tsg.h index 633ea42ed..14ac4ead8 100644 --- a/userspace/units/fifo/tsg/nvgpu-tsg.h +++ b/userspace/units/fifo/tsg/nvgpu-tsg.h @@ -275,31 +275,6 @@ int test_tsg_unbind_channel_check_ctx_reload(struct unit_module *m, int test_tsg_enable(struct unit_module *m, struct gk20a *g, void *args); -/** - * Test specification for: test_tsg_enable_sched - * - * Description: Enable/disable TSG scheduling - * - * Test Type: Feature - * - * Targets: nvgpu_tsg_enable_sched, nvgpu_tsg_disable_sched - * - * Input: test_fifo_init_support() run for this GPU - * - * Steps: - * - Create a TSG with a bound channel. - * - Use stub for g->ops.runlist.write_state to store runlist_mask - * and runlist_state. - * - Call nvgpu_tsg_enable_sched and check that runlist_mask matches - * TSG's runlist_id and runlist_state is RUNLIST_ENABLED. - * - Call nvgpu_tsg_diable_sched and check that runlist_mask matches - * TSG's runlist_id and runlist_state is RUNLIST_DISABLED. - * - * Output: Returns PASS if all branches gave expected results. FAIL otherwise. - */ -int test_tsg_enable_sched(struct unit_module *m, - struct gk20a *g, void *args); - /** * Test specification for: test_tsg_check_and_get_from_id *