[PATCH i-g-t 2/3] tests/gem_reset_stats: test no progress detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If seqno is not incrementing but head is moving,
we declare hang but much slower. Add test to check
that this mechanism is working properly.

Signed-off-by: Mika Kuoppala <mika.kuoppala@xxxxxxxxx>
---
 tests/gem_reset_stats.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c
index 2718a33..669a30a 100644
--- a/tests/gem_reset_stats.c
+++ b/tests/gem_reset_stats.c
@@ -711,6 +711,75 @@ static void defer_hangcheck(const struct intel_execution_engine *engine)
 	close(fd);
 }
 
+static void test_no_seqno_progress(const struct intel_execution_engine *engine,
+				   const bool use_ctx)
+{
+	struct drm_i915_gem_relocation_entry reloc;
+	struct drm_i915_gem_execbuffer2 eb;
+	struct drm_i915_gem_exec_object2 exec;
+	struct local_drm_i915_reset_stats before, after;
+	int len = 0, ctx, fd;
+	uint32_t batch[16*1024];
+	struct timespec ts_start;
+
+	fd = drm_open_driver(DRIVER_INTEL);
+
+	memset(&reloc, 0, sizeof(reloc));
+        memset(&exec, 0, sizeof(exec));
+        memset(&eb, 0, sizeof(eb));
+	memset(&batch, 0, sizeof(batch));
+
+	exec.handle = gem_create(fd, sizeof(batch));
+	exec.relocation_count = 1;
+        exec.relocs_ptr = (uintptr_t)&reloc;
+
+	igt_assert((int)exec.handle > 0);
+
+	if (use_ctx)
+		ctx = gem_context_create(fd);
+	else
+		ctx = 0;
+
+	len = 2;
+	if (intel_gen(intel_get_drm_devid(fd)) >= 8)
+		len++;
+
+	batch[sizeof(batch)/sizeof(uint32_t) - len] = MI_BATCH_BUFFER_START | (len - 2);
+        gem_write(fd, exec.handle, 0, batch, sizeof(batch));
+
+        reloc.offset = sizeof(batch) - ((len-1) * 4);
+        reloc.delta = 0;
+        reloc.target_handle = exec.handle;
+        reloc.read_domains = I915_GEM_DOMAIN_COMMAND;
+
+	eb.buffers_ptr = (uintptr_t)&exec;
+	eb.buffer_count = 1;
+	eb.flags = engine->exec_id;
+        if (ctx)
+		i915_execbuffer2_set_context_id(eb, ctx);
+
+	igt_assert_eq(gem_reset_stats(fd, ctx, &before), 0);
+
+	clock_gettime(CLOCK_MONOTONIC, &ts_start);
+
+	igt_assert_eq(0, __gem_execbuf(fd, &eb));
+	igt_assert_lte(0, noop(fd, ctx, engine));
+	gem_sync(fd, exec.handle);
+
+	igt_assert_lte(0, noop(fd, ctx, engine));
+	igt_assert_eq(gem_reset_stats(fd, ctx, &after), 0);
+
+	sync_gpu();
+
+	igt_assert(after.batch_active == before.batch_active + 1);
+
+	gem_close(fd, exec.handle);
+	close(fd);
+
+	igt_assert(igt_seconds_elapsed(&ts_start) > 5);
+	igt_assert(igt_seconds_elapsed(&ts_start) < 15);
+}
+
 static bool gem_has_reset_stats(int fd)
 {
 	struct local_drm_i915_reset_stats rs;
@@ -798,5 +867,11 @@ igt_main
 
 		igt_subtest_f("defer-hangcheck-%s", e->name)
 			RUN_TEST(defer_hangcheck(e));
+
+		igt_subtest_f("no-progress-%s", e->name)
+			RUN_TEST(test_no_seqno_progress(e, false));
+
+		igt_subtest_f("no-progress-ctx-%s", e->name)
+			RUN_CTX_TEST(test_no_seqno_progress(e, true));
 	}
 }
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux