From patchwork Tue Mar 13 12:31:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10278535 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 07E5B602BD for ; Tue, 13 Mar 2018 12:32:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA3842900D for ; Tue, 13 Mar 2018 12:32:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAB9429041; Tue, 13 Mar 2018 12:32:20 +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=-4.2 required=2.0 tests=BAYES_00, 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 ABE4128FF9 for ; Tue, 13 Mar 2018 12:32:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ECC0B6E49C; Tue, 13 Mar 2018 12:32:08 +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 52E2D6E486; Tue, 13 Mar 2018 12:32:07 +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 11008632-1500050 for multiple; Tue, 13 Mar 2018 12:31:58 +0000 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Tue, 13 Mar 2018 12:31:58 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 13 Mar 2018 12:31:55 +0000 Message-Id: <20180313123157.18260-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.16.2 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Subject: [Intel-gfx] [PATCH igt 1/3] 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. Signed-off-by: Chris Wilson Cc: Mika Kuoppala Acked-by: Antonio Argenziano --- tests/gem_eio.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/tests/gem_eio.c b/tests/gem_eio.c index 249f5bff..a4bcee3d 100644 --- a/tests/gem_eio.c +++ b/tests/gem_eio.c @@ -34,12 +34,14 @@ #include #include #include +#include #include #include #include "igt.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)."); @@ -452,6 +454,107 @@ static void test_inflight_internal(int fd) trigger_reset(fd); } +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; + + 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; + } + 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(1000); /* timer_delete() doesn't flush pending signals */ + + igt_debug("Cleaning up\n"); + close(timeline); + + 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 @@ -509,4 +612,9 @@ igt_main igt_subtest("in-flight-suspend") test_inflight_suspend(fd); + + igt_subtest("set-wedged-racing") { + igt_require_sw_sync(); + test_set_wedged(fd); + } }