From patchwork Sat Dec 12 20:02:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 7835891 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7BE0E9F1C2 for ; Sat, 12 Dec 2015 20:03:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 893962039E for ; Sat, 12 Dec 2015 20:03:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8DC2820390 for ; Sat, 12 Dec 2015 20:03:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F52D6E562; Sat, 12 Dec 2015 12:03:32 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [87.106.93.118]) by gabe.freedesktop.org (Postfix) with ESMTP id A49766E55C for ; Sat, 12 Dec 2015 12:03:24 -0800 (PST) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 49780853-1500048 for multiple; Sat, 12 Dec 2015 20:03:41 +0000 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Sat, 12 Dec 2015 20:03:14 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Sat, 12 Dec 2015 20:02:53 +0000 Message-Id: <1449950575-21012-7-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1449950575-21012-1-git-send-email-chris@chris-wilson.co.uk> References: <1449950575-21012-1-git-send-email-chris@chris-wilson.co.uk> X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Subject: [Intel-gfx] [PATCH igt 7/9] igt/kms_flip: Convert over to real hang injection X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Chris Wilson --- 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);