tests: Add gem_ctx_params
PATCH 1/2 tests: Add gem_ctx_params
Add gem_ctx_params to check context parameters ioctl test for set and getting ban periods.
Cc Chris Wilson <[email protected]>
Signed-off-by Mika Kuoppala <[email protected]>
--- tests/Makefile.sources | 1 + tests/gem_ctx_params.c | 211 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 212 insertions(+) create mode 100644 tests/gem_ctx_params.c
tests/Makefile.sources +1 -0
@@ -25,6 +25,7 @@ TESTS_progs_M = \ gem_cs_tlb \ gem_ctx_bad_exec \ gem_ctx_exec \ + gem_ctx_params \ gem_dummy_reloc_loop \ gem_evict_alignment \ gem_evict_everything \
tests/gem_ctx_params.c new file +211 -0
211 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 tests/gem_reset_stats: add tests for ban period ioctl
Test parameter set/get for ban periods.
Test actual impact on banning.
Signed-off-by Mika Kuoppala <[email protected]>
--- tests/gem_reset_stats.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-)
tests/gem_reset_stats.c +100 -1
@@ -52,6 +52,8 @@#define RS_BATCH_PENDING (1 << 1)#define RS_UNKNOWN (1 << 2) +IGT_TEST_DESCRIPTION ("Checks for RESET_STATS_IOCTL, context banning and reset recovery" ); +static uint32_t devid;static bool hw_contexts;
@@ -1047,6 +1049,98 @@ static void defer_hangcheck(int ring_num)close (fd); } +static bool was_banned_in_period (int fd,int ctx,int seconds) +{ +int h1,h2,h3,h4; +bool banned; + + h1 =inject_hang_no_ban_error (fd, ctx); +igt_assert (h1 >=0 ); + +sleep (seconds); + + h2 =exec_valid (fd, ctx); +igt_assert (h2 >=0 ); + + h3 =inject_hang_no_ban_error (fd, ctx); +igt_assert (h3 >=0 ); + +gem_sync (fd, h3); + + h4 =exec_valid (fd, ctx); + banned = (h4 == -EIO ); + +gem_close (fd, h1); +gem_close (fd, h2); +gem_close (fd, h3); +if (h4 >=0 ) +gem_close (fd, h4); + +return banned; +} + +static int get_ban_period (int fd,uint32_t ctx) +{ +struct local_i915_gem_context_param p; + + p.param =LOCAL_CONTEXT_PARAM_BAN_PERIOD ; + p.size =rand (); + p.context = ctx; + p.value = ((uint64_t )rand () <<32 ) |rand (); + +igt_assert (gem_context_get_param (fd, &p) ==0 ); + +return p.value; +} + +static void set_ban_period (int fd,uint32_t ctx,int period) +{ +struct local_i915_gem_context_param p; + + p.param =LOCAL_CONTEXT_PARAM_BAN_PERIOD ; + p.size =0 ; + p.context = ctx; + p.value = period; +igt_assert (gem_context_set_param (fd, &p) ==0 ); +} + +static void test_ban_period (bool new_ctx) +{ +int fd, period; +uint32_t ctx; + + fd =drm_open_any (); + +igt_require (gem_context_has_param (fd,LOCAL_CONTEXT_PARAM_BAN_PERIOD )); + +if (new_ctx) + ctx =context_create (fd); +else + ctx =0 ; + + period =get_ban_period (fd, ctx); +igt_assert (period >2 ); + + period +=2 ; + +set_ban_period (fd, ctx, period); + +igt_assert (was_banned_in_period (fd, ctx, period +2 ) == false); + +set_ban_period (fd, ctx,0 ); + +igt_assert (was_banned_in_period (fd, ctx,0 ) == false); + +/* We just hanged, wait for a while */ +sleep (period +2 ); + +set_ban_period (fd, ctx, period); + +igt_assert (was_banned_in_period (fd, ctx, period /4 ) == true); + +close (fd); +} +static bool gem_has_hw_contexts (int fd) {struct local_drm_i915_gem_context_create create;
@@ -1111,7 +1205,7 @@ static void check_gpu_ok(void)#define RING_HAS_CONTEXTS (current_ring->contexts(current_ring))#define RUN_TEST (...) do { check_gpu_ok(); __VA_ARGS__; check_gpu_ok(); } while (0) -#define RUN_CTX_TEST (...) do { igt_skip_on(RING_HAS_CONTEXTS == false); RUN_TEST(__VA_ARGS__); } while (0) +#define RUN_CTX_TEST (...) do { igt_require(RING_HAS_CONTEXTS); RUN_TEST(__VA_ARGS__); } while (0) igt_main {
@@ -1191,5 +1285,10 @@ igt_main igt_subtest_f("defer-hangcheck-%s", name)RUN_TEST (defer_hangcheck (i)); + igt_subtest_f("ban-period-%s", name) +RUN_TEST (test_ban_period (false)); + + igt_subtest_f("ban-period-ctx-%s", name) +RUN_CTX_TEST (test_ban_period (true)); } }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx