diff mbox series

[i-g-t] i915/gem_spin_batch: Add test to resend spinner

Message ID 20190416142315.21254-1-mika.kuoppala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [i-g-t] i915/gem_spin_batch: Add test to resend spinner | expand

Commit Message

Mika Kuoppala April 16, 2019, 2:23 p.m. UTC
Add subtests to resend the same spinner to same context
and to other context.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 tests/i915/gem_spin_batch.c | 47 ++++++++++++++++++++++++++++++-------
 1 file changed, 38 insertions(+), 9 deletions(-)

Comments

Chris Wilson April 16, 2019, 2:32 p.m. UTC | #1
Quoting Mika Kuoppala (2019-04-16 15:23:15)
> Add subtests to resend the same spinner to same context
> and to other context.
> 
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

For completeness in creating concise examples of use elsewhere, feed the
gem_execbuf to the other engines.
-Chris
diff mbox series

Patch

diff --git a/tests/i915/gem_spin_batch.c b/tests/i915/gem_spin_batch.c
index 52410010..e18b85c9 100644
--- a/tests/i915/gem_spin_batch.c
+++ b/tests/i915/gem_spin_batch.c
@@ -66,6 +66,36 @@  static void spin(int fd, unsigned int engine, unsigned int timeout_sec)
 	assert_within_epsilon(timeout_100ms * loops, elapsed, MAX_ERROR);
 }
 
+#define RESUBMIT_OTHER_CTX (1 << 0)
+
+static void spin_resubmit(int fd, unsigned int engine, unsigned int flags)
+{
+	const uint32_t ctx0 = gem_context_create(fd);
+	const uint32_t ctx1 = (flags & RESUBMIT_OTHER_CTX) ?
+		gem_context_create(fd) : ctx0;
+	igt_spin_t *spin = __igt_spin_batch_new(fd, .ctx = ctx0, .engine = engine);
+
+	struct drm_i915_gem_execbuffer2 eb = {
+		.buffer_count = 1,
+		.buffers_ptr = to_user_pointer(&spin->obj[1]),
+		.rsvd1 = ctx1,
+		.flags = engine,
+	};
+
+	gem_execbuf(fd, &eb);
+
+	igt_spin_batch_end(spin);
+
+	gem_sync(fd, spin->obj[1].handle);
+
+	igt_spin_batch_free(fd, spin);
+
+	if (ctx1 != ctx0)
+		gem_context_destroy(fd, ctx1);
+
+	gem_context_destroy(fd, ctx0);
+}
+
 static void spin_exit_handler(int sig)
 {
 	igt_terminate_spin_batches();
@@ -96,22 +126,21 @@  igt_main
 		fd = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(fd);
 		igt_fork_hang_detector(fd);
-		intel_detect_and_clear_missed_interrupts(fd);
 	}
 
 	for (e = intel_execution_engines; e->name; e++) {
-		igt_subtest_f("basic-%s", e->name) {
-			intel_detect_and_clear_missed_interrupts(fd);
+		igt_subtest_f("basic-%s", e->name)
 			spin(fd, e->exec_id, 3);
-			igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0);
-		}
+
+		igt_subtest_f("resubmit-%s", e->name)
+			spin_resubmit(fd, e->exec_id, 0);
+
+		igt_subtest_f("resubmit-other-%s", e->name)
+			spin_resubmit(fd, e->exec_id, RESUBMIT_OTHER_CTX);
 	}
 
-	igt_subtest("spin-each") {
-		intel_detect_and_clear_missed_interrupts(fd);
+	igt_subtest("spin-each")
 		spin_on_all_engines(fd, 3);
-		igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0);
-	}
 
 	igt_fixture {
 		igt_stop_hang_detector();