From 8ca9f3a8cb73e6c6381ae4b9411393ed72efa528 Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Mon, 17 Dec 2018 15:47:48 +0200 Subject: [PATCH] gpu: nvgpu: unit: use args for runlist interleaving The interleaving tests (full and oversize) are very similar in code. Add common args struct for them and have just one function to process args. Jira NVGPU-1174 Change-Id: I535aeb020454d3f87ad1148560f29ca7fff4ae2d Signed-off-by: Konsta Holtta Reviewed-on: https://git-master.nvidia.com/r/1975380 GVS: Gerrit_Virtual_Submit Reviewed-by: Nicolas Benech Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- userspace/units/fifo/runlist/nvgpu-runlist.c | 79 +++++++------------- 1 file changed, 26 insertions(+), 53 deletions(-) diff --git a/userspace/units/fifo/runlist/nvgpu-runlist.c b/userspace/units/fifo/runlist/nvgpu-runlist.c index 6ffeef169..01f439df1 100644 --- a/userspace/units/fifo/runlist/nvgpu-runlist.c +++ b/userspace/units/fifo/runlist/nvgpu-runlist.c @@ -374,57 +374,29 @@ static int test_interleaving_gen_all(struct unit_module *m, struct gk20a *g, expected, ARRAY_SIZE(expected)); } -/* - * Test construction of all priority items. - */ -static int test_interleaving(struct unit_module *m, struct gk20a *g, void *args) -{ - return test_interleaving_gen_all(m, g, 0); -} +static struct interleave_test_args { + u32 sizelimit; +} interleave_tests[] = { +/* All priority items. */ + { 0 }, +/* Fail at level 2 immediately: space for just a tsg header, no ch entries. */ + { 1 }, +/* Insert both l2 entries, then fail at l1 level. */ + { 2 * 2 }, +/* Insert both l2 entries, one l1, and just one l2: fail at last l2. */ + { (2 + 1 + 1) * 2 }, +/* Stop at exactly the first l2 entry in the first l1-l0 transition. */ + { (2 + 1 + 2 + 1) * 2 }, +/* Stop at exactly the first l0 entry that doesn't fit. */ + { (2 + 1 + 2 + 1 + 2) * 2 }, +}; -/* - * Fail at level 2 immediately: space for just a tsg header. - */ -static int test_interleaving_oversize_tiny(struct unit_module *m, +static int test_interleaving_gen_all_run(struct unit_module *m, struct gk20a *g, void *args) { - return test_interleaving_gen_all(m, g, 1); -} + struct interleave_test_args *test_args = args; -/* - * Insert both l2 entries, then fail at l1 level. - */ -static int test_interleaving_oversize_l2(struct unit_module *m, - struct gk20a *g, void *args) -{ - return test_interleaving_gen_all(m, g, 2 * 2); -} - -/* - * Insert both l2 entries, one l1, and just one l2: fail at last l2. - */ -static int test_interleaving_oversize_l2_l1_l2(struct unit_module *m, - struct gk20a *g, void *args) -{ - return test_interleaving_gen_all(m, g, (2 + 1 + 1) * 2); -} - -/* - * Stop at exactly the first l2 entry in the first l1-l0 transition. - */ -static int test_interleaving_oversize_l2_l1_l2_l1(struct unit_module *m, - struct gk20a *g, void *args) -{ - return test_interleaving_gen_all(m, g, (2 + 1 + 2 + 1) * 2); -} - -/* - * Stop at exactly the first l0 entry that doesn't fit. - */ -static int test_interleaving_oversize_l2_l1_l2_l1_l2(struct unit_module *m, - struct gk20a *g, void *args) -{ - return test_interleaving_gen_all(m, g, (2 + 1 + 2 + 1 + 2) * 2); + return test_interleaving_gen_all(m, g, test_args->sizelimit); } /* @@ -526,18 +498,19 @@ struct unit_module_test nvgpu_runlist_tests[] = { UNIT_TEST(flat_oversize_two, test_flat_oversize_two, NULL), UNIT_TEST(flat_oversize_end, test_flat_oversize_end, NULL), - UNIT_TEST(interleaving, test_interleaving, NULL), + UNIT_TEST(interleaving, + test_interleaving_gen_all_run, &interleave_tests[0]), UNIT_TEST(interleaving_oversize_tiny, - test_interleaving_oversize_tiny, NULL), + test_interleaving_gen_all_run, &interleave_tests[1]), UNIT_TEST(interleaving_oversize_l2, - test_interleaving_oversize_l2, NULL), + test_interleaving_gen_all_run, &interleave_tests[2]), UNIT_TEST(interleaving_oversize_l2_l1_l2, - test_interleaving_oversize_l2_l1_l2, NULL), + test_interleaving_gen_all_run, &interleave_tests[3]), UNIT_TEST(interleaving_oversize_l2_l1_l2_l1, - test_interleaving_oversize_l2_l1_l2_l1, NULL), + test_interleaving_gen_all_run, &interleave_tests[4]), UNIT_TEST(interleaving_oversize_l2_l1_l2_l1_l2, - test_interleaving_oversize_l2_l1_l2_l1_l2, NULL), + test_interleaving_gen_all_run, &interleave_tests[5]), UNIT_TEST(interleaving_l0, test_interleaving_l0, NULL), UNIT_TEST(interleaving_l1, test_interleaving_l1, NULL),