From patchwork Wed May 22 11:37:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10955755 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 1D61776 for ; Wed, 22 May 2019 11:37:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E2C628B14 for ; Wed, 22 May 2019 11:37:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02F4828B17; Wed, 22 May 2019 11:37:34 +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 A8CFF28B14 for ; Wed, 22 May 2019 11:37:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CBF5D899C4; Wed, 22 May 2019 11:37:30 +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 00B9489998; Wed, 22 May 2019 11:37:27 +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 16639715-1500050 for multiple; Wed, 22 May 2019 12:37:16 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Wed, 22 May 2019 12:37:12 +0100 Message-Id: <20190522113712.23512-12-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190522113712.23512-1-chris@chris-wilson.co.uk> References: <20190522113712.23512-1-chris@chris-wilson.co.uk> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 12/12] i915/gem_exec_latency: Add another variant of waiter latency 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 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Chris Wilson --- tests/i915/gem_exec_latency.c | 81 +++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/tests/i915/gem_exec_latency.c b/tests/i915/gem_exec_latency.c index e88fbbc6a..fd4ceb4d6 100644 --- a/tests/i915/gem_exec_latency.c +++ b/tests/i915/gem_exec_latency.c @@ -490,6 +490,83 @@ static void execution_latency(int i915, unsigned int ring, const char *name) gem_close(i915, obj.handle); } +static void wakeup_latency(int i915, unsigned int ring, const char *name) +{ + struct drm_i915_gem_exec_object2 obj = { + .handle = gem_create(i915, 4095), + }; + struct drm_i915_gem_execbuffer2 execbuf = { + .buffers_ptr = to_user_pointer(&obj), + .buffer_count = 1, + .flags = ring | LOCAL_I915_EXEC_NO_RELOC | LOCAL_I915_EXEC_HANDLE_LUT, + }; + const unsigned int mmio_base = 0x2000; + const unsigned int cs_timestamp = mmio_base + 0x358; + volatile uint32_t *timestamp; + struct igt_mean wakeup; + uint32_t *cs, *result; + + timestamp = + (volatile uint32_t *)((volatile char *)igt_global_mmio + cs_timestamp); + + obj.handle = gem_create(i915, 4096); + obj.flags = EXEC_OBJECT_PINNED; + result = gem_mmap__wc(i915, obj.handle, 0, 4096, PROT_WRITE); + + cs = result; + + *cs++ = 0x24 << 23 | 2; /* SRM */ + *cs++ = cs_timestamp; + *cs++ = 4096 - 16 * 4; + *cs++ = 0; + + *cs++ = MI_BATCH_BUFFER_START | 1; + *cs++ = 0; + *cs++ = 0; + + *cs++ = 0x24 << 23 | 2; /* SRM */ + *cs++ = cs_timestamp; + *cs++ = 4096 - 16 * 4 + 4; + *cs++ = 0; + *cs++ = 0xa << 23; + + cs = result + 1024 - 16; + + { + struct sched_param p = { .sched_priority = 99 }; + sched_setscheduler(0, SCHED_FIFO | SCHED_RESET_ON_FORK, &p); + } + + igt_mean_init(&wakeup); + igt_until_timeout(2) { + uint32_t end; + + igt_fork(child, 1) { + result[4] = MI_BATCH_BUFFER_START | 1; + cs[0] = 0; + + gem_execbuf(i915, &execbuf); + + while (!cs[0]) + ; + result[4] = 0; + __sync_synchronize(); + } + gem_sync(i915, obj.handle); + end = *timestamp; + + igt_mean_add(&wakeup, (end - cs[1]) * rcs_clock); + igt_waitchildren(); + } + igt_info("%s Wakeup latency: %.2f±%.2fms [%.2f, %.2f]\n", name, + 1e-6 * igt_mean_get(&wakeup), + 1e-6 * sqrt(igt_mean_get_variance(&wakeup)), + 1e-6 * wakeup.min, 1e-6 * wakeup.max); + + munmap(result, 4096); + gem_close(i915, obj.handle); +} + static void __submit_spin(int fd, igt_spin_t *spin, unsigned int flags) { @@ -942,6 +1019,10 @@ igt_main execution_latency(device, e->exec_id | e->flags, e->name); + igt_subtest_f("%s-wakeup-latency", e->name) + wakeup_latency(device, + e->exec_id | e->flags, + e->name); igt_subtest_f("%s-live-dispatch-queued", e->name) latency_on_ring(device,