summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-10-09 20:08:42 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2020-10-10 10:02:25 +0100
commitf7d1ac8c479f7049bdd900df8d17c2fa6efdcaf6 (patch)
tree9b0db412c1650dbc8c09de08273b8c69d4d326a7
parent3844f333747a9ac64c7ed72ee68d837708eb1ad8 (diff)
i915/gem_ctx_persistence: Verify userptr vs context cleanup
Verify that the wait for userptr cleanup is after we have cancelled the non-persistent hanging context. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Jon Bloomfield <jon.bloomfield@intel.com> Acked-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
-rw-r--r--tests/i915/gem_ctx_persistence.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/i915/gem_ctx_persistence.c b/tests/i915/gem_ctx_persistence.c
index 09814f24..174af836 100644
--- a/tests/i915/gem_ctx_persistence.c
+++ b/tests/i915/gem_ctx_persistence.c
@@ -735,6 +735,50 @@ static void test_process(int i915)
gem_quiescent_gpu(i915);
}
+static void test_userptr(int i915)
+{
+ int fence, sv[2];
+
+ cleanup(i915);
+
+ /*
+ * When a process dies early, do the userptr or the contexts get cleaned
+ * up first? Since we only cancel the outstanding work along with the
+ * context, but wait on userptr cleanup for oustanding work, if
+ * the userptr is before the context, we end up in a scenario where
+ * we wait forever for the non-peristent context.
+ */
+
+ igt_require(socketpair(AF_UNIX, SOCK_DGRAM, 0, sv) == 0);
+
+ igt_fork(child, 1) {
+ igt_spin_t *spin;
+
+ i915 = gem_reopen_driver(i915);
+ gem_quiescent_gpu(i915);
+
+ gem_context_set_persistence(i915, 0, false);
+ spin = igt_spin_new(i915, .flags = IGT_SPIN_FENCE_OUT | IGT_SPIN_USERPTR);
+ sendfd(sv[0], spin->out_fence);
+
+ igt_list_del(&spin->link); /* prevent autocleanup */
+ }
+ close(sv[0]);
+ igt_waitchildren();
+ flush_delayed_fput(i915);
+
+ fence = recvfd(sv[1]);
+ close(sv[1]);
+
+ igt_assert_eq(wait_for_status(fence, reset_timeout_ms), -EIO);
+ close(fence);
+
+ /* We have to manually clean up the orphaned spinner */
+ igt_drop_caches_set(i915, DROP_RESET_ACTIVE);
+
+ gem_quiescent_gpu(i915);
+}
+
static void test_process_mixed(int pfd, unsigned int engine)
{
int fence[2], sv[2];
@@ -1287,6 +1331,9 @@ igt_main
igt_subtest("processes")
test_processes(i915);
+ igt_subtest("userptr")
+ test_userptr(i915);
+
igt_subtest("hostile")
test_nohangcheck_hostile(i915);
igt_subtest("hang")