diff mbox

[i-g-t,2/2] tests/drv_hangman: watchdog tests

Message ID 20170223194421.28463-5-michel.thierry@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michel Thierry Feb. 23, 2017, 7:44 p.m. UTC
Test watchdog triggered resets.

Signed-off-by: Michel Thierry <michel.thierry@intel.com>
---
 tests/drv_hangman.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

Comments

Chris Wilson Feb. 23, 2017, 10:26 p.m. UTC | #1
On Thu, Feb 23, 2017 at 11:44:21AM -0800, Michel Thierry wrote:
> Test watchdog triggered resets.

How about setting a watchdog N with a dummy load set to expire in 2N
(where 2N is less 1s to avoid hangcheck). Then check fence status to
ensure watchdog kicked the batch.  See gem_exec_fence.
-Chris
Chris Wilson Feb. 23, 2017, 11:06 p.m. UTC | #2
On Thu, Feb 23, 2017 at 10:26:29PM +0000, Chris Wilson wrote:
> On Thu, Feb 23, 2017 at 11:44:21AM -0800, Michel Thierry wrote:
> > Test watchdog triggered resets.
> 
> How about setting a watchdog N with a dummy load set to expire in 2N
> (where 2N is less 1s to avoid hangcheck). Then check fence status to
> ensure watchdog kicked the batch.  See gem_exec_fence.

Or better yet, in gem_exec_watchdog set i915.enable_hangcheck=0

Hmm, which raises a good question is the user watchdog independent of
the hangcheck module_option. My vote is for yes, but that will require
a little rejigging.
-Chris
diff mbox

Patch

diff --git a/tests/drv_hangman.c b/tests/drv_hangman.c
index 51bdbdaa..ba230f65 100644
--- a/tests/drv_hangman.c
+++ b/tests/drv_hangman.c
@@ -126,13 +126,21 @@  static bool uses_cmd_parser(void)
 
 static void check_error_state(const char *expected_ring_name,
 			      uint64_t expected_offset,
-			      const uint32_t *batch)
+			      const uint32_t *batch,
+			      bool watchdog)
 {
 	bool cmd_parser = uses_cmd_parser();
 	FILE *file = open_error();
 	char *line = NULL;
+	const char *watchdog_hang_reason = "reason: Watchdog timeout";
 	size_t line_size = 0;
 
+	if (watchdog) {
+		/* NOTE: expected engine name check happens later */
+		if (getline(&line, &line_size, file) > 0)
+			igt_assert(strstr(line, watchdog_hang_reason));
+	}
+
 	while (getline(&line, &line_size, file) > 0) {
 		char *dashes;
 		uint32_t gtt_offset_upper, gtt_offset_lower;
@@ -180,21 +188,29 @@  static void check_error_state(const char *expected_ring_name,
 }
 
 static void test_error_state_capture(unsigned ring_id,
-				     const char *ring_name)
+				     const char *ring_name,
+				     bool watchdog)
 {
 	uint32_t *batch;
 	igt_hang_t hang;
 	uint64_t offset;
+	unsigned flags = HANG_ALLOW_CAPTURE;
 
+	igt_skip_on_f(watchdog && ring_id == I915_EXEC_BLT,
+		      "no official watchdog support in BLT engine\n");
 	igt_require(gem_has_ring(device, ring_id));
 	clear_error_state();
+	assert_error_state_clear();
 
-	hang = igt_hang_ctx(device, 0, ring_id, HANG_ALLOW_CAPTURE, &offset);
+	if (watchdog)
+		flags |= HANG_USE_WATCHDOG;
+
+	hang = igt_hang_ctx(device, 0, ring_id, flags, &offset);
 	batch = gem_mmap__cpu(device, hang.handle, 0, 4096, PROT_READ);
 	gem_set_domain(device, hang.handle, I915_GEM_DOMAIN_CPU, 0);
 	igt_post_hang_ring(device, hang);
 
-	check_error_state(ring_name, offset, batch);
+	check_error_state(ring_name, offset, batch, watchdog);
 	munmap(batch, 4096);
 }
 
@@ -259,7 +275,11 @@  igt_main
 
 		igt_subtest_f("error-state-capture-%s", e->name)
 			test_error_state_capture(e->exec_id | e->flags,
-						 e->full_name);
+						 e->full_name, false);
+
+		igt_subtest_f("watchdog-%s", e->name)
+			test_error_state_capture(e->exec_id | e->flags,
+						 e->full_name, true);
 	}
 
 	igt_subtest("hangcheck-unterminated")