From patchwork Fri Jul 27 11:13:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10546931 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F601180E for ; Fri, 27 Jul 2018 11:13:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D9DD2B5DE for ; Fri, 27 Jul 2018 11:13:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F15D2B700; Fri, 27 Jul 2018 11:13:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DD0662B5DE for ; Fri, 27 Jul 2018 11:13:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5B20C6E966; Fri, 27 Jul 2018 11:13:33 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 370056E25C; Fri, 27 Jul 2018 11:13:31 +0000 (UTC) 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 12480693-1500050 for multiple; Fri, 27 Jul 2018 12:13:23 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Fri, 27 Jul 2018 12:13:24 +0100 Message-Id: <20180727111324.7471-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.18.0 Subject: [Intel-gfx] [PATCH i-g-t] igt/gem_eio: Measure reset delay from thread X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP We assert that we complete a wedge within 250ms. However, when we use a thread to delay the wedging until after we start waiting, that thread itself is delayed longer than our wait timeout. This results in a false positive error where we fail the test before we even trigger the reset. Reorder the test so that we only ever measure the delay from triggering the reset until we wakeup, and assert that is in a timely fashion (less than 250ms). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105954 Signed-off-by: Chris Wilson Reviewed-by: Tvrtko Ursulin --- tests/gem_eio.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/tests/gem_eio.c b/tests/gem_eio.c index 3162a3170..b26b4b895 100644 --- a/tests/gem_eio.c +++ b/tests/gem_eio.c @@ -190,7 +190,8 @@ static igt_spin_t * spin_sync(int fd, uint32_t ctx, unsigned long flags) struct hang_ctx { int debugfs; - struct timespec ts; + struct timespec delay; + struct timespec *ts; timer_t timer; }; @@ -198,8 +199,10 @@ static void hang_handler(union sigval arg) { struct hang_ctx *ctx = arg.sival_ptr; - igt_debug("hang delay = %.2fus\n", igt_nsec_elapsed(&ctx->ts) / 1000.0); + igt_debug("hang delay = %.2fus\n", + igt_nsec_elapsed(&ctx->delay) / 1000.0); + igt_nsec_elapsed(ctx->ts); igt_assert(igt_sysfs_set(ctx->debugfs, "i915_wedged", "-1")); igt_assert_eq(timer_delete(ctx->timer), 0); @@ -207,7 +210,7 @@ static void hang_handler(union sigval arg) free(ctx); } -static void hang_after(int fd, unsigned int us) +static void hang_after(int fd, unsigned int us, struct timespec *ts) { struct sigevent sev = { .sigev_notify = SIGEV_THREAD, @@ -229,30 +232,30 @@ static void hang_after(int fd, unsigned int us) igt_assert_eq(timer_create(CLOCK_MONOTONIC, &sev, &ctx->timer), 0); - igt_nsec_elapsed(&ctx->ts); + ctx->ts = ts; + igt_nsec_elapsed(&ctx->delay); igt_assert_eq(timer_settime(ctx->timer, 0, &its, NULL), 0); } -static int __check_wait(int fd, uint32_t bo, unsigned int wait) +static void __check_wait(int fd, uint32_t bo, unsigned int wait) { - unsigned long wait_timeout = 250e6; /* Some margin for actual reset. */ - int ret; + struct timespec ts = {}; + uint64_t elapsed; if (wait) { - /* - * Double the wait plus some fixed margin to ensure gem_wait - * can never time out before the async hang runs. - */ - wait_timeout += wait * 2000 + 250e6; - hang_after(fd, wait); + hang_after(fd, wait, &ts); } else { + igt_nsec_elapsed(&ts); manual_hang(fd); } - ret = __gem_wait(fd, bo, wait_timeout); + gem_sync(fd, bo); - return ret; + elapsed = igt_nsec_elapsed(&ts); + igt_assert_f(elapsed < 250e6, + "Wake up following reset+wedge took %.3fms\n", + elapsed*1e-6); } static void __test_banned(int fd) @@ -322,7 +325,7 @@ static void test_wait(int fd, unsigned int flags, unsigned int wait) hang = spin_sync(fd, 0, I915_EXEC_DEFAULT); - igt_assert_eq(__check_wait(fd, hang->handle, wait), 0); + __check_wait(fd, hang->handle, wait); igt_spin_batch_free(fd, hang); @@ -392,7 +395,7 @@ static void test_inflight(int fd, unsigned int wait) igt_assert(fence[n] != -1); } - igt_assert_eq(__check_wait(fd, obj[1].handle, wait), 0); + __check_wait(fd, obj[1].handle, wait); for (unsigned int n = 0; n < ARRAY_SIZE(fence); n++) { igt_assert_eq(sync_fence_status(fence[n]), -EIO); @@ -443,7 +446,7 @@ static void test_inflight_suspend(int fd) igt_set_autoresume_delay(30); igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE); - igt_assert_eq(__check_wait(fd, obj[1].handle, 10), 0); + __check_wait(fd, obj[1].handle, 10); for (unsigned int n = 0; n < ARRAY_SIZE(fence); n++) { igt_assert_eq(sync_fence_status(fence[n]), -EIO); @@ -521,7 +524,7 @@ static void test_inflight_contexts(int fd, unsigned int wait) igt_assert(fence[n] != -1); } - igt_assert_eq(__check_wait(fd, obj[1].handle, wait), 0); + __check_wait(fd, obj[1].handle, wait); for (unsigned int n = 0; n < ARRAY_SIZE(fence); n++) { igt_assert_eq(sync_fence_status(fence[n]), -EIO); @@ -630,7 +633,7 @@ static void test_inflight_internal(int fd, unsigned int wait) nfence++; } - igt_assert_eq(__check_wait(fd, obj[1].handle, wait), 0); + __check_wait(fd, obj[1].handle, wait); while (nfence--) { igt_assert_eq(sync_fence_status(fences[nfence]), -EIO); @@ -682,7 +685,7 @@ static void test_reset_stress(int fd, unsigned int flags) gem_execbuf(fd, &execbuf); /* Wedge after a small delay. */ - igt_assert_eq(__check_wait(fd, obj.handle, 100e3), 0); + __check_wait(fd, obj.handle, 100e3); /* Unwedge by forcing a reset. */ igt_assert(i915_reset_control(true));