[igt-dev] [PATCH igt 01/16] igt/gem_sync: Exercise and measure idle requests

Chris Wilson chris at chris-wilson.co.uk
Tue Feb 20 08:45:05 UTC 2018


Don't just wait for the batch to be completed, wait for the system to
idle! Then wake it up and do it again.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 tests/gem_sync.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/tests/gem_sync.c b/tests/gem_sync.c
index ad43b1a3..d70515ea 100644
--- a/tests/gem_sync.c
+++ b/tests/gem_sync.c
@@ -152,6 +152,45 @@ sync_ring(int fd, unsigned ring, int num_children, int timeout)
 	igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0);
 }
 
+static void
+idle_ring(int fd, unsigned ring, int timeout)
+{
+	const uint32_t bbe = MI_BATCH_BUFFER_END;
+	struct drm_i915_gem_exec_object2 object;
+	struct drm_i915_gem_execbuffer2 execbuf;
+	double start, elapsed;
+	unsigned long cycles;
+
+	gem_require_ring(fd, ring);
+
+	memset(&object, 0, sizeof(object));
+	object.handle = gem_create(fd, 4096);
+	gem_write(fd, object.handle, 0, &bbe, sizeof(bbe));
+
+	memset(&execbuf, 0, sizeof(execbuf));
+	execbuf.buffers_ptr = to_user_pointer(&object);
+	execbuf.buffer_count = 1;
+	execbuf.flags = ring;
+	gem_execbuf(fd, &execbuf);
+	gem_sync(fd, object.handle);
+
+	intel_detect_and_clear_missed_interrupts(fd);
+	start = gettime();
+	cycles = 0;
+	do {
+		do {
+			gem_execbuf(fd, &execbuf);
+			gem_quiescent_gpu(fd);
+		} while (++cycles & 1023);
+	} while ((elapsed = gettime() - start) < timeout);
+	igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0);
+
+	igt_info("Completed %ld cycles: %.3f us\n",
+		 cycles, elapsed*1e6/cycles);
+
+	gem_close(fd, object.handle);
+}
+
 static void
 store_ring(int fd, unsigned ring, int num_children, int timeout)
 {
@@ -802,6 +841,8 @@ igt_main
 	for (e = intel_execution_engines; e->name; e++) {
 		igt_subtest_f("%s", e->name)
 			sync_ring(fd, e->exec_id | e->flags, 1, 150);
+		igt_subtest_f("idle-%s", e->name)
+			idle_ring(fd, e->exec_id | e->flags, 150);
 		igt_subtest_f("store-%s", e->name)
 			store_ring(fd, e->exec_id | e->flags, 1, 150);
 		igt_subtest_f("many-%s", e->name)
-- 
2.16.1



More information about the igt-dev mailing list