public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] i915: Exercise hostile context execution
@ 2019-10-22 15:47 Chris Wilson
  2019-10-22 16:30 ` [igt-dev] ✗ GitLab.Pipeline: warning for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Chris Wilson @ 2019-10-22 15:47 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev, Tvrtko Ursulin, Jon Bloomfield

Verify that contexts are automatically shotdown on close if hangchecking
is disabled.

Basic environmental robustness test stolen from gem_ctx_persistence.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jon Bloomfield <jon.bloomfield@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 tests/i915/gem_ctx_exec.c | 41 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/tests/i915/gem_ctx_exec.c b/tests/i915/gem_ctx_exec.c
index 614a9f401..92e899869 100644
--- a/tests/i915/gem_ctx_exec.c
+++ b/tests/i915/gem_ctx_exec.c
@@ -40,6 +40,8 @@
 
 #include <drm.h>
 
+#include "igt_dummyload.h"
+#include "igt_sysfs.h"
 
 IGT_TEST_DESCRIPTION("Test context batch buffer execution.");
 
@@ -196,6 +198,42 @@ static void norecovery(int i915)
 	 igt_disallow_hang(i915, hang);
 }
 
+static bool __enable_hangcheck(int dir, bool state)
+{
+	return igt_sysfs_set(dir, "enable_hangcheck", state ? "1" : "0");
+}
+
+static void nohangcheck_hostile(int i915)
+{
+	int64_t timeout = NSEC_PER_SEC / 2;
+	igt_spin_t *spin;
+	uint32_t ctx;
+	int dir;
+
+	/*
+	 * Even if the user disables hangcheck during their context,
+	 * we forcibly terminate that context.
+	 */
+
+	dir = igt_sysfs_open_parameters(i915);
+	igt_require(dir != -1);
+
+	ctx = gem_context_create(i915);
+
+	igt_require(__enable_hangcheck(dir, false));
+
+	spin = igt_spin_new(i915, ctx, .flags = IGT_SPIN_NO_PREEMPTION);
+	gem_context_destroy(i915, ctx);
+
+	igt_assert_eq(gem_wait(i915, spin->handle, &timeout), 0);
+
+	igt_require(__enable_hangcheck(dir, true));
+
+	igt_spin_free(i915, spin);
+	gem_quiescent_gpu(i915);
+	close(dir);
+}
+
 igt_main
 {
 	const uint32_t batch[2] = { 0, MI_BATCH_BUFFER_END };
@@ -239,6 +277,9 @@ igt_main
 	igt_subtest("basic-norecovery")
 		norecovery(fd);
 
+	igt_subtest("basic-nohangcheck")
+		nohangcheck_hostile(fd);
+
 	igt_subtest("reset-pin-leak") {
 		int i;
 
-- 
2.24.0.rc0

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

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

end of thread, other threads:[~2019-10-23 12:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-22 15:47 [igt-dev] [PATCH i-g-t] i915: Exercise hostile context execution Chris Wilson
2019-10-22 16:30 ` [igt-dev] ✗ GitLab.Pipeline: warning for " Patchwork
2019-10-22 16:31 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2019-10-23  4:25 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2019-10-23 12:50 ` [igt-dev] [PATCH i-g-t] " Andi Shyti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox