From patchwork Mon Jun 18 09:53:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10470603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 319B1600CC for ; Mon, 18 Jun 2018 09:53:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2094228995 for ; Mon, 18 Jun 2018 09:53:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1517B2899F; Mon, 18 Jun 2018 09:53:53 +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 A130728995 for ; Mon, 18 Jun 2018 09:53:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 63FA78919B; Mon, 18 Jun 2018 09:53:51 +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 C46BC8919B; Mon, 18 Jun 2018 09:53:49 +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 12079568-1500050 for multiple; Mon, 18 Jun 2018 10:53:17 +0100 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Mon, 18 Jun 2018 10:53:18 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Mon, 18 Jun 2018 10:53:18 +0100 Message-Id: <20180618095318.21059-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.17.1 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Subject: [Intel-gfx] [PATCH i-g-t] igt/gem_eio: Exercise set-wedging against request submission 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 Build up a large stockpile of requests, ~500,000, and feed them into the system at 20KHz whilst simultaneously triggering set-wedged in order to try and race i915_gem_set_wedged() against the engine->submit_request() callback. v2: Tweak sleep for flushing timer signals. Signed-off-by: Chris Wilson Cc: Mika Kuoppala Acked-by: Antonio Argenziano --- tests/gem_eio.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/tests/gem_eio.c b/tests/gem_eio.c index 5faf7502b..f0dda8150 100644 --- a/tests/gem_eio.c +++ b/tests/gem_eio.c @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #include #include @@ -43,6 +45,7 @@ #include "igt.h" #include "igt_device.h" #include "igt_sysfs.h" +#include "i915/gem_ring.h" #include "sw_sync.h" IGT_TEST_DESCRIPTION("Test that specific ioctls report a wedged GPU (EIO)."); @@ -705,6 +708,111 @@ static void test_reset_stress(int fd, unsigned int flags) gem_context_destroy(fd, ctx0); } +static void notify(union sigval arg) +{ + sw_sync_timeline_inc(arg.sival_int, 1); +} + +static void test_set_wedged(int fd) +{ +#define NCTX 4096 + const uint32_t bbe = MI_BATCH_BUFFER_END; + const unsigned int ring_size = gem_measure_ring_inflight(fd, 0, 0) - 1; + struct drm_i915_gem_execbuffer2 execbuf; + struct drm_i915_gem_exec_object2 obj; + int dir = igt_debugfs_dir(fd); + struct itimerspec its; + struct sigevent sev; + uint32_t *contexts; + timer_t timer; + int timeline; + int syncpt; + + igt_require_sw_sync(); + igt_require(gem_has_contexts(fd)); + + contexts = calloc(NCTX, sizeof(*contexts)); + igt_assert(contexts); + + for (int n = 0; n < NCTX; n++) + contexts[n] = context_create_safe(fd); + + memset(&obj, 0, sizeof(obj)); + obj.handle = gem_create(fd, 4096); + gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); + + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = to_user_pointer(&obj); + execbuf.buffer_count = 1; + execbuf.flags = I915_EXEC_FENCE_IN; + + for (unsigned int nctx = 1; nctx <= NCTX; nctx <<= 1) { + unsigned int nrq = ring_size; + if (!gem_has_execlists(fd)) { + nrq = (ring_size + nctx - 1) / nctx + 1; + nctx = ring_size / nrq + 1; + } + igt_assert(nrq); + igt_assert(nctx); + + timeline = sw_sync_timeline_create(); + + /* Build up a large orderly queue of requests */ + syncpt = 1; + for (int m = 0; m < nrq; m++) { + for (int n = 0; n < nctx; n++) { + execbuf.rsvd1 = contexts[n]; + execbuf.rsvd2 = + sw_sync_timeline_create_fence(timeline, syncpt); + gem_execbuf(fd, &execbuf); + close(execbuf.rsvd2); + + syncpt++; + } + } + igt_debug("Queued %d requests over %d contexts\n", + syncpt, nctx); + + igt_require(i915_reset_control(false)); + + /* Feed each request in at 20KHz */ + memset(&sev, 0, sizeof(sev)); + sev.sigev_notify = SIGEV_THREAD; + sev.sigev_value.sival_int = timeline; + sev.sigev_notify_function = notify; + igt_assert(timer_create(CLOCK_MONOTONIC, &sev, &timer) == 0); + + memset(&its, 0, sizeof(its)); + its.it_interval.tv_sec = 0; + its.it_interval.tv_nsec = 5000; + its.it_value = its.it_interval; + igt_assert(timer_settime(timer, 0, &its, NULL) == 0); + usleep(10); + + igt_debug("Triggering wedge\n"); + igt_sysfs_set(dir, "i915_wedged", "-1"); + + igt_debug("Disabling timer\n"); + timer_delete(timer); + usleep(10000);/* timer_delete() doesn't flush pending signals */ + + igt_debug("Cleaning up\n"); + close(timeline); + + sched_yield(); + igt_assert(!gem_bo_busy(fd, obj.handle)); + + igt_assert(i915_reset_control(true)); + trigger_reset(fd); + } + + gem_close(fd, obj.handle); + for (int n = 0; n < NCTX; n++) + gem_context_destroy(fd, contexts[n]); + free(contexts); + close(dir); +} + static int fd = -1; static void @@ -795,4 +903,7 @@ igt_main } } } + + igt_subtest("set-wedged-racing") + test_set_wedged(fd); }