From 51d069e07b3f7697f06fa8947ee92a196356d8b3 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 2 Oct 2018 20:36:15 +0100 Subject: igt/gem_ctx_exec: Exercise I915_CONTEXT_PARAM_RECOVERABLE When RECOVERABLE is set, the kernel will attempt to automatically recover a context after a hang. But if it is unset, the kernel will ban the guilty context on a hang, preventing subsequent execution. v2: Create a has_recoverable_param() Signed-off-by: Chris Wilson Cc: Mika Kuoppala Reviewed-by: Mika Kuoppala --- tests/i915/gem_ctx_exec.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/i915/gem_ctx_exec.c b/tests/i915/gem_ctx_exec.c index 908b59af..78cfe66c 100644 --- a/tests/i915/gem_ctx_exec.c +++ b/tests/i915/gem_ctx_exec.c @@ -147,6 +147,51 @@ static void invalid_context(int fd, unsigned ring, uint32_t handle) igt_assert_eq(__gem_execbuf(fd, &execbuf), -ENOENT); } +static bool has_recoverable_param(int i915) +{ + struct drm_i915_gem_context_param param = { + .param = I915_CONTEXT_PARAM_RECOVERABLE + }; + + return __gem_context_get_param(i915, ¶m) == 0; +} + +static void norecovery(int i915) +{ + igt_require(has_recoverable_param(i915)); + + for (int pass = 1; pass >= 0; pass--) { + struct drm_i915_gem_context_param param = { + .ctx_id = gem_context_create(i915), + .param = I915_CONTEXT_PARAM_RECOVERABLE, + .value = pass, + }; + int expect = pass == 0 ? -EIO : 0; + igt_spin_t *spin; + + gem_context_set_param(i915, ¶m); + + param.value = !pass; + gem_context_get_param(i915, ¶m); + igt_assert_eq(param.value, pass); + + spin = __igt_spin_batch_new(i915, + .ctx = param.ctx_id, + .flags = IGT_SPIN_POLL_RUN); + igt_assert(spin->running); + + while (!READ_ONCE(*spin->running)) + ; + igt_force_gpu_reset(i915); + + igt_spin_batch_end(spin); + igt_assert_eq(__gem_execbuf(i915, &spin->execbuf), expect); + igt_spin_batch_free(i915, spin); + + gem_context_destroy(i915, param.ctx_id); + } +} + igt_main { const uint32_t batch[2] = { 0, MI_BATCH_BUFFER_END }; @@ -190,6 +235,9 @@ igt_main igt_subtest("eviction") big_exec(fd, handle, 0); + igt_subtest("basic-norecovery") + norecovery(fd); + igt_subtest("reset-pin-leak") { int i; -- cgit v1.2.3