All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH igt 7/9] igt/kms_flip: Convert over to real hang injection
Date: Sat, 12 Dec 2015 20:02:53 +0000	[thread overview]
Message-ID: <1449950575-21012-7-git-send-email-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <1449950575-21012-1-git-send-email-chris@chris-wilson.co.uk>

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/kms_flip.c | 89 ++++++++++----------------------------------------------
 1 file changed, 15 insertions(+), 74 deletions(-)

diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index a3acc3d..356462e 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -776,72 +776,17 @@ static void set_y_tiling(struct test_output *o, int fb_idx)
 	drmFree(r);
 }
 
-static void stop_rings(bool stop)
+static igt_hang_ring_t hang_gpu(int fd)
 {
-	if (stop)
-		igt_set_stop_rings(STOP_RING_DEFAULTS);
-	else
-		igt_set_stop_rings(STOP_RING_NONE);
-}
-
-static void eat_error_state(void)
-{
-	static const char dfs_entry_error[] = "i915_error_state";
-	static const char data[] = "";
-	int fd;
-
-	fd = igt_debugfs_open(dfs_entry_error, O_WRONLY);
-	igt_assert_lte(0, fd);
-
-	igt_assert(write(fd, data, sizeof(data)) == sizeof(data));
-	close(fd);
-
-	/* and check whether stop_rings is not reset, i.e. the hang has indeed
-	 * happened */
-	igt_assert_f(igt_get_stop_rings() == STOP_RING_NONE,
-		     "no gpu hang detected, stop_rings is still 0x%x\n",
-		     igt_get_stop_rings());
-
-	close(fd);
-}
-
-static void unhang_gpu(int fd, uint32_t handle)
-{
-	gem_sync(drm_fd, handle);
-	gem_close(drm_fd, handle);
-	eat_error_state();
-	stop_rings(false);
+	return igt_hang_ring(fd, I915_EXEC_DEFAULT);
 }
 
-static uint32_t hang_gpu(int fd)
+static void unhang_gpu(int fd, igt_hang_ring_t hang)
 {
-	struct drm_i915_gem_execbuffer2 execbuf;
-	struct drm_i915_gem_exec_object2 gem_exec;
-	uint32_t b[2] = {MI_BATCH_BUFFER_END};
-
-	stop_rings(true);
-
-	memset(&gem_exec, 0, sizeof(gem_exec));
-	gem_exec.handle = gem_create(fd, 4096);
-	gem_write(fd, gem_exec.handle, 0, b, sizeof(b));
-
-	memset(&execbuf, 0, sizeof(execbuf));
-	execbuf.buffers_ptr = (uintptr_t)&gem_exec;
-	execbuf.buffer_count = 1;
-	execbuf.batch_len = sizeof(b);
-
-	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf)) {
-		igt_assert_f(errno == EIO,
-			     "failed to exercise page flip hang recovery\n");
-
-		unhang_gpu(fd, gem_exec.handle);
-		gem_exec.handle = 0;
-	}
-
-	return gem_exec.handle;
+	igt_post_hang_ring(fd, hang);
 }
 
-static bool is_hung(int fd)
+static bool is_wedged(int fd)
 {
 	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_THROTTLE, 0) == 0)
 		return false;
@@ -883,7 +828,7 @@ static unsigned int run_test_step(struct test_output *o)
 	bool do_vblank;
 	struct vblank_reply vbl_reply;
 	unsigned int target_seq;
-	uint32_t hang = 0;	/* Suppress GCC warning */
+	igt_hang_ring_t hang;
 
 	target_seq = o->vblank_state.seq_step;
 	/* Absolute waits only works once we have a frame counter. */
@@ -989,10 +934,9 @@ static unsigned int run_test_step(struct test_output *o)
 
 	igt_print_activity();
 
-	if (do_flip && (o->flags & TEST_HANG)) {
+	memset(&hang, 0, sizeof(hang));
+	if (do_flip && (o->flags & TEST_HANG))
 		hang = hang_gpu(drm_fd);
-		igt_assert_f(hang, "failed to exercise page flip hang recovery\n");
-	}
 
 	/* try to make sure we can issue two flips during the same frame */
 	if (do_flip && (o->flags & TEST_EBUSY)) {
@@ -1064,8 +1008,7 @@ static unsigned int run_test_step(struct test_output *o)
 	if (do_flip && (o->flags & TEST_EINVAL) && !(o->flags & TEST_FB_BAD_TILING))
 		igt_assert(do_page_flip(o, new_fb_id, true) == expected_einval);
 
-	if (hang)
-		unhang_gpu(drm_fd, hang);
+	unhang_gpu(drm_fd, hang);
 
 	return completed_events;
 }
@@ -1295,13 +1238,12 @@ static unsigned int wait_for_events(struct test_output *o)
 static unsigned event_loop(struct test_output *o, unsigned duration_ms)
 {
 	unsigned long start, end;
-	uint32_t hang = 0;	/* Suppress GCC warning */
+	igt_hang_ring_t hang;
 	int count = 0;
 
-	if (o->flags & TEST_HANG_ONCE) {
+	memset(&hang, 0, sizeof(hang));
+	if (o->flags & TEST_HANG_ONCE)
 		hang = hang_gpu(drm_fd);
-		igt_assert_f(hang, "failed to exercise page flip hang recovery\n");
-	}
 
 	start = gettime_us();
 
@@ -1322,8 +1264,7 @@ static unsigned event_loop(struct test_output *o, unsigned duration_ms)
 
 	end = gettime_us();
 
-	if (hang)
-		unhang_gpu(drm_fd, hang);
+	unhang_gpu(drm_fd, hang);
 
 	/* Flush any remaining events */
 	if (o->pending_events)
@@ -1488,7 +1429,7 @@ static int run_test(int duration, int flags)
 	struct test_output o;
 	int i, n, modes = 0;
 
-	igt_require((flags & TEST_HANG) == 0 || !is_hung(drm_fd));
+	igt_require((flags & TEST_HANG) == 0 || !is_wedged(drm_fd));
 
 	if (flags & TEST_RPM)
 		igt_require(igt_setup_runtime_pm());
@@ -1548,7 +1489,7 @@ static int run_pair(int duration, int flags)
 	struct test_output o;
 	int i, j, m, n, modes = 0;
 
-	igt_require((flags & TEST_HANG) == 0 || !is_hung(drm_fd));
+	igt_require((flags & TEST_HANG) == 0 || !is_wedged(drm_fd));
 
 	resources = drmModeGetResources(drm_fd);
 	igt_assert(resources);
-- 
2.6.3

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

  parent reply	other threads:[~2015-12-12 20:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-12 20:02 [PATCH igt 1/9] lib: Always double check igt_require_hang_ring() on use Chris Wilson
2015-12-12 20:02 ` [PATCH igt 2/9] lib: Expand igt_hang_ring() to select target context and various options Chris Wilson
2015-12-12 20:02 ` [PATCH igt 3/9] igt/drv_hangman: Inject a true hang Chris Wilson
2015-12-16  9:02   ` Daniel Vetter
2015-12-16 10:37     ` Chris Wilson
2015-12-16 13:12       ` Ville Syrjälä
2015-12-16 13:51         ` Chris Wilson
2015-12-16 14:03           ` Chris Wilson
2015-12-12 20:02 ` [PATCH igt 4/9] igt/gem_ctx_exec: Convert from stop-rings to a real GPU hang/reset Chris Wilson
2015-12-12 20:02 ` [PATCH igt 5/9] igt/gem_reset_stats: Convert from stop-rings to real hang injection Chris Wilson
2015-12-12 20:02 ` [PATCH igt 6/9] igt/kms_pipe_crc_basic: Replace stop_rings with igt_hang_ring Chris Wilson
2015-12-12 20:02 ` Chris Wilson [this message]
2015-12-12 20:02 ` [PATCH igt 8/9] igt/gem_workarounds: Convert to real GPU hang injection Chris Wilson
2015-12-12 20:02 ` [PATCH igt 9/9] igt/pm_rps: Trigger a real GPU reset Chris Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449950575-21012-7-git-send-email-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.