diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2020-02-24 21:53:03 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2020-02-25 18:25:02 +0000 |
commit | 412b54f3f2c6fe2f560d7506cf8b8817741786c8 (patch) | |
tree | 7d231d935104920389e9cc6885e8b71759a07d02 | |
parent | eb1d32e5ea97dc36a8ccfcef234f89428fe70244 (diff) |
i915/gem_ctx_persistence: Check precision of hostile cancellation
Check that if we have to remove a hostile request from a non-persistent
context, we do so without harming any other concurrent users.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
-rw-r--r-- | tests/i915/gem_ctx_persistence.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/i915/gem_ctx_persistence.c b/tests/i915/gem_ctx_persistence.c index 20007f5c..5e6e7f30 100644 --- a/tests/i915/gem_ctx_persistence.c +++ b/tests/i915/gem_ctx_persistence.c @@ -613,6 +613,71 @@ static void test_process_mixed(int pfd, unsigned int engine) gem_quiescent_gpu(pfd); } +static void +test_saturated_hostile(int i915, const struct intel_execution_engine2 *engine) +{ + const struct intel_execution_engine2 *other; + igt_spin_t *spin; + uint32_t ctx; + int fence = -1; + + /* + * Check that if we have to remove a hostile request from a + * non-persistent context, we do so without harming any other + * concurrent users. + * + * We only allow non-persistent contexts if we can perform a + * per-engine reset, that is removal of the hostile context without + * impacting other users on the system. [Consider the problem of + * allowing the user to create a context with which they can arbitrarily + * reset other users whenever they chose.] + */ + + __for_each_physical_engine(i915, other) { + if (other->flags == engine->flags) + continue; + + spin = igt_spin_new(i915, + .engine = other->flags, + .flags = (IGT_SPIN_NO_PREEMPTION | + IGT_SPIN_FENCE_OUT)); + + if (fence < 0) { + fence = spin->out_fence; + } else { + int tmp; + + tmp = sync_fence_merge(fence, spin->out_fence); + close(fence); + close(spin->out_fence); + + fence = tmp; + } + spin->out_fence = -1; + } + igt_require(fence != -1); + + ctx = gem_context_clone_with_engines(i915, 0); + gem_context_set_persistence(i915, ctx, false); + spin = igt_spin_new(i915, ctx, + .engine = engine->flags, + .flags = (IGT_SPIN_NO_PREEMPTION | + IGT_SPIN_POLL_RUN | + IGT_SPIN_FENCE_OUT)); + igt_spin_busywait_until_started(spin); + gem_context_destroy(i915, ctx); + + /* Hostile request requires a GPU reset to terminate */ + igt_assert_eq(sync_fence_wait(spin->out_fence, reset_timeout_ms), 0); + igt_assert_eq(sync_fence_status(spin->out_fence), -EIO); + + /* All other spinners should be left unharmed */ + gem_quiescent_gpu(i915); + igt_assert_eq(sync_fence_wait(fence, reset_timeout_ms), 0); + igt_assert_eq(sync_fence_status(fence), 1); + close(fence); +} + static void test_processes(int i915) { struct { @@ -1041,6 +1106,13 @@ igt_main } } + igt_subtest_with_dynamic_f("saturated-hostile") { + __for_each_physical_engine(i915, e) { + igt_dynamic_f("%s", e->name) + test_saturated_hostile(i915, e); + } + } + igt_subtest("smoketest") smoketest(i915); } |