All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH igt] igt/gem_ctx_isolation: Reset a scratch context
@ 2018-03-27 13:48 Chris Wilson
  2018-03-27 13:52 ` Chris Wilson
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Chris Wilson @ 2018-03-27 13:48 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev, Tvrtko Ursulin

If we inject a reset into the target context, there is a risk that the
register state is never saved back to memory. The exact interaction
between reset, the context image and the precise timing of our execution
are not well defined. Since we cannot ensure that the context image
remains valid, force a context switch prior to the reset.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105270
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105457
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105545
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 tests/gem_ctx_isolation.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/tests/gem_ctx_isolation.c b/tests/gem_ctx_isolation.c
index d8109aa0..4968e367 100644
--- a/tests/gem_ctx_isolation.c
+++ b/tests/gem_ctx_isolation.c
@@ -522,6 +522,32 @@ static void isolation(int fd,
 #define S4 (4 << 8)
 #define SLEEP_MASK (0xf << 8)
 
+static void inject_reset_context(int fd, unsigned int engine)
+{
+	igt_spin_t *spin;
+	uint32_t ctx;
+
+	/*
+	 * Force a context switch before triggering the reset, or else
+	 * we risk corrupting the target context and we can't blame the
+	 * HW for screwing up if the context was already broken.
+	 */
+
+	ctx = gem_context_create(fd);
+	if (gem_can_store_dword(fd, engine)) {
+		spin = __igt_spin_batch_new_poll(fd, ctx, engine);
+		igt_spin_busywait_until_running(spin);
+	} else {
+		spin = __igt_spin_batch_new(fd, ctx, engine, 0);
+		usleep(1000); /* better than nothing */
+	}
+
+	igt_force_gpu_reset(fd);
+
+	igt_spin_batch_free(fd, spin);
+	gem_context_destroy(fd, ctx);
+}
+
 static void preservation(int fd,
 			 const struct intel_execution_engine2 *e,
 			 unsigned int flags)
@@ -558,7 +584,7 @@ static void preservation(int fd,
 	igt_spin_batch_free(fd, spin);
 
 	if (flags & RESET)
-		igt_force_gpu_reset(fd);
+		inject_reset_context(fd, engine);
 
 	switch (flags & SLEEP_MASK) {
 	case NOSLEEP:
-- 
2.16.3

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-03-27 21:47 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-27 13:48 [igt-dev] [PATCH igt] igt/gem_ctx_isolation: Reset a scratch context Chris Wilson
2018-03-27 13:52 ` Chris Wilson
2018-03-27 13:59   ` Chris Wilson
2018-03-27 15:39     ` Tvrtko Ursulin
2018-03-27 15:41     ` Tvrtko Ursulin
2018-03-27 15:41       ` [Intel-gfx] " Tvrtko Ursulin
2018-03-27 15:25 ` Tvrtko Ursulin
2018-03-27 15:41 ` Tvrtko Ursulin
2018-03-27 15:41   ` Tvrtko Ursulin
2018-03-27 15:58   ` Chris Wilson
2018-03-27 15:58     ` Chris Wilson
2018-03-27 16:32 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-03-27 21:47 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

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.