[PATCH i-g-t] i915: Exercise hostile context execution

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

 



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@xxxxxxxxxxxxxxxxxx>
Cc: Jon Bloomfield <jon.bloomfield@xxxxxxxxx>
Cc: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
---
 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

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




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux