All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: igt-dev@lists.freedesktop.org, joonas.lahtinen@linux.intel.com
Cc: intel-gfx@lists.freedesktop.org
Subject: [PATCH igt 16/16] igt/gem_exec_fence: Exercise merging fences
Date: Tue, 20 Feb 2018 08:45:20 +0000	[thread overview]
Message-ID: <20180220084520.27965-16-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20180220084520.27965-1-chris@chris-wilson.co.uk>

Execute the same batch on each engine and check that the composite fence
across all engines completes only after the batch is completed on every
engine.

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

diff --git a/tests/gem_exec_fence.c b/tests/gem_exec_fence.c
index 312505d6..d9432f95 100644
--- a/tests/gem_exec_fence.c
+++ b/tests/gem_exec_fence.c
@@ -207,6 +207,113 @@ static void test_fence_busy(int fd, unsigned ring, unsigned flags)
 	gem_quiescent_gpu(fd);
 }
 
+static void test_fence_busy_all(int fd, unsigned flags)
+{
+	const int gen = intel_gen(intel_get_drm_devid(fd));
+	struct drm_i915_gem_exec_object2 obj;
+	struct drm_i915_gem_relocation_entry reloc;
+	struct drm_i915_gem_execbuffer2 execbuf;
+	struct timespec tv;
+	uint32_t *batch;
+	unsigned int engine;
+	int all, i, timeout;
+
+	gem_quiescent_gpu(fd);
+
+	memset(&execbuf, 0, sizeof(execbuf));
+	execbuf.buffers_ptr = to_user_pointer(&obj);
+	execbuf.buffer_count = 1;
+
+	memset(&obj, 0, sizeof(obj));
+	obj.handle = gem_create(fd, 4096);
+
+	obj.relocs_ptr = to_user_pointer(&reloc);
+	obj.relocation_count = 1;
+	memset(&reloc, 0, sizeof(reloc));
+
+	batch = gem_mmap__wc(fd, obj.handle, 0, 4096, PROT_WRITE);
+	gem_set_domain(fd, obj.handle,
+		       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
+
+	reloc.target_handle = obj.handle; /* recurse */
+	reloc.presumed_offset = 0;
+	reloc.offset = sizeof(uint32_t);
+	reloc.delta = 0;
+	reloc.read_domains = I915_GEM_DOMAIN_COMMAND;
+	reloc.write_domain = 0;
+
+	i = 0;
+	batch[i] = MI_BATCH_BUFFER_START;
+	if (gen >= 8) {
+		batch[i] |= 1 << 8 | 1;
+		batch[++i] = 0;
+		batch[++i] = 0;
+	} else if (gen >= 6) {
+		batch[i] |= 1 << 8;
+		batch[++i] = 0;
+	} else {
+		batch[i] |= 2 << 6;
+		batch[++i] = 0;
+		if (gen < 4) {
+			batch[i] |= 1;
+			reloc.delta = 1;
+		}
+	}
+	i++;
+
+	all = -1;
+	for_each_engine(fd, engine) {
+		int fence, new;
+
+		execbuf.flags = engine | LOCAL_EXEC_FENCE_OUT;
+		execbuf.rsvd2 = -1;
+		gem_execbuf_wr(fd, &execbuf);
+		fence = execbuf.rsvd2 >> 32;
+		igt_assert(fence != -1);
+
+		if (all < 0) {
+			all = fence;
+			break;
+		}
+
+		new = sync_fence_merge(all, fence);
+		igt_assert_lte(0, new);
+		close(all);
+		close(fence);
+
+		all = new;
+	}
+
+	igt_assert(gem_bo_busy(fd, obj.handle));
+	igt_assert(fence_busy(all));
+
+	timeout = 120;
+	if ((flags & HANG) == 0) {
+		*batch = MI_BATCH_BUFFER_END;
+		__sync_synchronize();
+		timeout = 1;
+	}
+	munmap(batch, 4096);
+
+	if (flags & WAIT) {
+		struct pollfd pfd = { .fd = all, .events = POLLIN };
+		igt_assert(poll(&pfd, 1, timeout*1000) == 1);
+	} else {
+		memset(&tv, 0, sizeof(tv));
+		while (fence_busy(all))
+			igt_assert(igt_seconds_elapsed(&tv) < timeout);
+	}
+
+	igt_assert(!gem_bo_busy(fd, obj.handle));
+	igt_assert_eq(sync_fence_status(all),
+		      flags & HANG ? -EIO : SYNC_FENCE_OK);
+
+	close(all);
+	gem_close(fd, obj.handle);
+
+	gem_quiescent_gpu(fd);
+}
+
 static void test_fence_await(int fd, unsigned ring, unsigned flags)
 {
 	const int gen = intel_gen(intel_get_drm_devid(fd));
@@ -1558,6 +1665,26 @@ igt_main
 		gem_submission_print_method(i915);
 	}
 
+	igt_subtest_group {
+		igt_fixture {
+			igt_fork_hang_detector(i915);
+		}
+
+		igt_subtest("basic-busy-all")
+			test_fence_busy_all(i915, 0);
+		igt_subtest("basic-wait-all")
+			test_fence_busy_all(i915, WAIT);
+
+		igt_fixture {
+			igt_stop_hang_detector();
+		}
+
+		igt_subtest("busy-hang-all")
+			test_fence_busy_all(i915, HANG);
+		igt_subtest("wait-hang-all")
+			test_fence_busy_all(i915, WAIT | HANG);
+	}
+
 	for (e = intel_execution_engines; e->name; e++) {
 		igt_subtest_group {
 			igt_fixture {
-- 
2.16.1

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

WARNING: multiple messages have this Message-ID (diff)
From: Chris Wilson <chris@chris-wilson.co.uk>
To: igt-dev@lists.freedesktop.org, joonas.lahtinen@linux.intel.com
Cc: intel-gfx@lists.freedesktop.org
Subject: [igt-dev] [PATCH igt 16/16] igt/gem_exec_fence: Exercise merging fences
Date: Tue, 20 Feb 2018 08:45:20 +0000	[thread overview]
Message-ID: <20180220084520.27965-16-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20180220084520.27965-1-chris@chris-wilson.co.uk>

Execute the same batch on each engine and check that the composite fence
across all engines completes only after the batch is completed on every
engine.

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

diff --git a/tests/gem_exec_fence.c b/tests/gem_exec_fence.c
index 312505d6..d9432f95 100644
--- a/tests/gem_exec_fence.c
+++ b/tests/gem_exec_fence.c
@@ -207,6 +207,113 @@ static void test_fence_busy(int fd, unsigned ring, unsigned flags)
 	gem_quiescent_gpu(fd);
 }
 
+static void test_fence_busy_all(int fd, unsigned flags)
+{
+	const int gen = intel_gen(intel_get_drm_devid(fd));
+	struct drm_i915_gem_exec_object2 obj;
+	struct drm_i915_gem_relocation_entry reloc;
+	struct drm_i915_gem_execbuffer2 execbuf;
+	struct timespec tv;
+	uint32_t *batch;
+	unsigned int engine;
+	int all, i, timeout;
+
+	gem_quiescent_gpu(fd);
+
+	memset(&execbuf, 0, sizeof(execbuf));
+	execbuf.buffers_ptr = to_user_pointer(&obj);
+	execbuf.buffer_count = 1;
+
+	memset(&obj, 0, sizeof(obj));
+	obj.handle = gem_create(fd, 4096);
+
+	obj.relocs_ptr = to_user_pointer(&reloc);
+	obj.relocation_count = 1;
+	memset(&reloc, 0, sizeof(reloc));
+
+	batch = gem_mmap__wc(fd, obj.handle, 0, 4096, PROT_WRITE);
+	gem_set_domain(fd, obj.handle,
+		       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
+
+	reloc.target_handle = obj.handle; /* recurse */
+	reloc.presumed_offset = 0;
+	reloc.offset = sizeof(uint32_t);
+	reloc.delta = 0;
+	reloc.read_domains = I915_GEM_DOMAIN_COMMAND;
+	reloc.write_domain = 0;
+
+	i = 0;
+	batch[i] = MI_BATCH_BUFFER_START;
+	if (gen >= 8) {
+		batch[i] |= 1 << 8 | 1;
+		batch[++i] = 0;
+		batch[++i] = 0;
+	} else if (gen >= 6) {
+		batch[i] |= 1 << 8;
+		batch[++i] = 0;
+	} else {
+		batch[i] |= 2 << 6;
+		batch[++i] = 0;
+		if (gen < 4) {
+			batch[i] |= 1;
+			reloc.delta = 1;
+		}
+	}
+	i++;
+
+	all = -1;
+	for_each_engine(fd, engine) {
+		int fence, new;
+
+		execbuf.flags = engine | LOCAL_EXEC_FENCE_OUT;
+		execbuf.rsvd2 = -1;
+		gem_execbuf_wr(fd, &execbuf);
+		fence = execbuf.rsvd2 >> 32;
+		igt_assert(fence != -1);
+
+		if (all < 0) {
+			all = fence;
+			break;
+		}
+
+		new = sync_fence_merge(all, fence);
+		igt_assert_lte(0, new);
+		close(all);
+		close(fence);
+
+		all = new;
+	}
+
+	igt_assert(gem_bo_busy(fd, obj.handle));
+	igt_assert(fence_busy(all));
+
+	timeout = 120;
+	if ((flags & HANG) == 0) {
+		*batch = MI_BATCH_BUFFER_END;
+		__sync_synchronize();
+		timeout = 1;
+	}
+	munmap(batch, 4096);
+
+	if (flags & WAIT) {
+		struct pollfd pfd = { .fd = all, .events = POLLIN };
+		igt_assert(poll(&pfd, 1, timeout*1000) == 1);
+	} else {
+		memset(&tv, 0, sizeof(tv));
+		while (fence_busy(all))
+			igt_assert(igt_seconds_elapsed(&tv) < timeout);
+	}
+
+	igt_assert(!gem_bo_busy(fd, obj.handle));
+	igt_assert_eq(sync_fence_status(all),
+		      flags & HANG ? -EIO : SYNC_FENCE_OK);
+
+	close(all);
+	gem_close(fd, obj.handle);
+
+	gem_quiescent_gpu(fd);
+}
+
 static void test_fence_await(int fd, unsigned ring, unsigned flags)
 {
 	const int gen = intel_gen(intel_get_drm_devid(fd));
@@ -1558,6 +1665,26 @@ igt_main
 		gem_submission_print_method(i915);
 	}
 
+	igt_subtest_group {
+		igt_fixture {
+			igt_fork_hang_detector(i915);
+		}
+
+		igt_subtest("basic-busy-all")
+			test_fence_busy_all(i915, 0);
+		igt_subtest("basic-wait-all")
+			test_fence_busy_all(i915, WAIT);
+
+		igt_fixture {
+			igt_stop_hang_detector();
+		}
+
+		igt_subtest("busy-hang-all")
+			test_fence_busy_all(i915, HANG);
+		igt_subtest("wait-hang-all")
+			test_fence_busy_all(i915, WAIT | HANG);
+	}
+
 	for (e = intel_execution_engines; e->name; e++) {
 		igt_subtest_group {
 			igt_fixture {
-- 
2.16.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2018-02-20  8:45 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20  8:45 [PATCH igt 01/16] igt/gem_sync: Exercise and measure idle requests Chris Wilson
2018-02-20  8:45 ` [Intel-gfx] " Chris Wilson
2018-02-20  8:45 ` [PATCH igt 02/16] lib: Cache the debugfs mountpoint Chris Wilson
2018-02-20  8:45   ` [igt-dev] " Chris Wilson
2018-02-20  8:45 ` [PATCH igt 03/16] lib: Always set mismatching index for igt_find_crc_mismatch Chris Wilson
2018-02-20  8:45   ` [igt-dev] " Chris Wilson
2018-02-20  8:45 ` [PATCH igt 04/16] igt/gem_exec_flush: Silence old compiler warning Chris Wilson
2018-02-20  8:45   ` [igt-dev] " Chris Wilson
2018-02-20  8:45 ` [PATCH igt 05/16] igt/syncobj: Tidy ye olde compiler warnings Chris Wilson
2018-02-20  8:45   ` [igt-dev] " Chris Wilson
2018-02-20  8:45 ` [PATCH igt 06/16] lib: Remove overzealous assertion on gem_set_caching() Chris Wilson
2018-02-20  8:45   ` [igt-dev] " Chris Wilson
2018-02-20  8:45 ` [PATCH igt 07/16] igt/gem_exec_schedule: Trim max number of contexts used Chris Wilson
2018-02-20  8:45   ` [igt-dev] " Chris Wilson
2018-02-20 10:52   ` Joonas Lahtinen
2018-02-20 10:52     ` [Intel-gfx] " Joonas Lahtinen
2018-02-20  8:45 ` [PATCH igt 08/16] igt/gem_exec_schedule: Replace constant 16 with its magic macro Chris Wilson
2018-02-20  8:45   ` [igt-dev] " Chris Wilson
2018-02-20 10:57   ` Joonas Lahtinen
2018-02-20 10:57     ` [igt-dev] " Joonas Lahtinen
2018-02-20 11:01     ` Chris Wilson
2018-02-20 11:01       ` [igt-dev] " Chris Wilson
2018-02-20  8:45 ` [PATCH igt 09/16] igt/gem_fenced_exec_thrash: Use fixed durations Chris Wilson
2018-02-20  8:45   ` [igt-dev] " Chris Wilson
2018-02-20  8:45 ` [PATCH igt 10/16] igt/gem_eio: Use slow spinners to inject hangs Chris Wilson
2018-02-20  8:45   ` [igt-dev] " Chris Wilson
2018-02-20 11:14   ` Joonas Lahtinen
2018-02-20 11:14     ` [Intel-gfx] " Joonas Lahtinen
2018-02-20  8:45 ` [PATCH igt 11/16] igt/gem_eio: Exercise set-wedging against request submission Chris Wilson
2018-02-20  8:45   ` [Intel-gfx] " Chris Wilson
2018-02-20  8:45 ` [PATCH igt 12/16] igt/gem_ctx_isolation: Check isolation of registers between contexts Chris Wilson
2018-02-20  8:45   ` [igt-dev] " Chris Wilson
2018-02-20 14:56   ` Joonas Lahtinen
2018-02-20 14:56     ` [igt-dev] " Joonas Lahtinen
2018-02-20  8:45 ` [PATCH igt 13/16] igt/gem_ctx_switch: Do a warmup pass over all contexts Chris Wilson
2018-02-20  8:45   ` [Intel-gfx] " Chris Wilson
2018-02-20 14:57   ` Joonas Lahtinen
2018-02-20 14:57     ` [igt-dev] " Joonas Lahtinen
2018-02-20  8:45 ` [PATCH igt 14/16] igt/gem_ctx_switch: Exercise all engines at once Chris Wilson
2018-02-20  8:45   ` [igt-dev] " Chris Wilson
2018-02-20  8:45 ` [PATCH igt 15/16] igt/gem_exec_capture: Exercise readback of userptr Chris Wilson
2018-02-20  8:45   ` [igt-dev] " Chris Wilson
2018-02-20  8:45 ` Chris Wilson [this message]
2018-02-20  8:45   ` [igt-dev] [PATCH igt 16/16] igt/gem_exec_fence: Exercise merging fences Chris Wilson
2018-02-20  9:09 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [01/16] igt/gem_sync: Exercise and measure idle requests Patchwork
2018-02-20 10:02 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2018-03-05 13:43 ` [PATCH igt 01/16] " Joonas Lahtinen
2018-03-05 13:43   ` [igt-dev] " Joonas Lahtinen
2018-03-05 14:39   ` Chris Wilson
2018-03-05 14:39     ` [igt-dev] " Chris Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180220084520.27965-16-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=joonas.lahtinen@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.