summaryrefslogtreecommitdiff
path: root/tests/i915/i915_hangman.c
diff options
context:
space:
mode:
authorJohn Harrison <John.C.Harrison@Intel.com>2022-01-14 10:17:03 -0800
committerAshutosh Dixit <ashutosh.dixit@intel.com>2022-01-18 12:43:38 -0800
commit2086df9fd81164fd6932d6c78835d0ae44a0e6ba (patch)
tree18917c190da8d0cf8276095c69004f58994f98a3 /tests/i915/i915_hangman.c
parentaae8328db87696065d5930485e8818d8d0dfd163 (diff)
tests/i915/i915_hangman: Add uevent test & fix detector
Some of the IGT framework relies on receving a uevent when a hang occurs. So add a test that this actually works. While testing this, noticed that hangs could sometimes be missed because the uevent was (presumably) still in flight by the time the handler was de-registered. So add an extra delay during cleanup to give the uevent chance to arrive. Signed-off-by: John Harrison <John.C.Harrison@Intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Diffstat (limited to 'tests/i915/i915_hangman.c')
-rw-r--r--tests/i915/i915_hangman.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/i915/i915_hangman.c b/tests/i915/i915_hangman.c
index 7b8390a6..354769f3 100644
--- a/tests/i915/i915_hangman.c
+++ b/tests/i915/i915_hangman.c
@@ -31,6 +31,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
+#include <signal.h>
#include "i915/gem.h"
#include "i915/gem_create.h"
@@ -289,6 +290,38 @@ test_engine_hang(const intel_ctx_t *ctx,
put_ahnd(ahnd);
}
+static int hang_count;
+
+static void sig_io(int sig)
+{
+ hang_count++;
+}
+
+static void test_hang_detector(const intel_ctx_t *ctx,
+ const struct intel_execution_engine2 *e)
+{
+ igt_hang_t hang;
+ uint64_t ahnd = get_reloc_ahnd(device, ctx->id);
+
+ hang_count = 0;
+
+ igt_fork_hang_detector(device);
+
+ /* Steal the signal handler */
+ signal(SIGIO, sig_io);
+
+ /* Make a hang... */
+ hang = igt_hang_ctx_with_ahnd(device, ahnd, ctx->id, e->flags, 0);
+
+ igt_post_hang_ring(device, hang);
+ put_ahnd(ahnd);
+
+ igt_stop_hang_detector();
+
+ /* Did it work? */
+ igt_assert(hang_count == 1);
+}
+
/* This test covers the case where we end up in an uninitialised area of the
* ppgtt and keep executing through it. This is particularly relevant if 48b
* ppgtt is enabled because the ppgtt is massively bigger compared to the 32b
@@ -408,6 +441,16 @@ igt_main
igt_subtest("hangcheck-unterminated")
hangcheck_unterminated(ctx);
+ igt_describe("Check that hang detector works");
+ igt_subtest_with_dynamic("detector") {
+ const struct intel_execution_engine2 *e;
+
+ for_each_ctx_engine(device, ctx, e) {
+ igt_dynamic_f("%s", e->name)
+ test_hang_detector(ctx, e);
+ }
+ }
+
do_tests("GT", "gt", ctx);
igt_fixture {