summaryrefslogtreecommitdiff
path: root/tests/i915/gem_ctx_exec.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-10-22 16:44:23 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2019-10-23 13:52:52 +0100
commit8153b95b53bdef26d2c3e318197d174e982b4265 (patch)
treec1f386e6c03525198d173426e93b18402ad63a50 /tests/i915/gem_ctx_exec.c
parentda9abbab69be80dd00812a4607a4ea2dffcc4544 (diff)
i915: Exercise hostile context execution
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> Acked-by: Andi Shyti <andi.shyti@intel.com>
Diffstat (limited to 'tests/i915/gem_ctx_exec.c')
-rw-r--r--tests/i915/gem_ctx_exec.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/i915/gem_ctx_exec.c b/tests/i915/gem_ctx_exec.c
index 614a9f40..92e89986 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;