From patchwork Wed Oct 12 11:59:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdiel Janulgue X-Patchwork-Id: 9372427 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 A08DF60839 for ; Wed, 12 Oct 2016 12:00:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91EE928E7A for ; Wed, 12 Oct 2016 12:00:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86BDE2955F; Wed, 12 Oct 2016 12:00:16 +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 A680428E7A for ; Wed, 12 Oct 2016 12:00:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 163E66E834; Wed, 12 Oct 2016 12:00:12 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 358AB6E835 for ; Wed, 12 Oct 2016 12:00:03 +0000 (UTC) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP; 12 Oct 2016 05:00:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,482,1473145200"; d="scan'208";a="18803101" Received: from abj-mbp11.fi.intel.com ([10.237.68.148]) by fmsmga005.fm.intel.com with ESMTP; 12 Oct 2016 05:00:02 -0700 From: Abdiel Janulgue To: intel-gfx@lists.freedesktop.org Date: Wed, 12 Oct 2016 14:59:53 +0300 Message-Id: <20161012115954.16803-3-abdiel.janulgue@linux.intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161012115954.16803-1-abdiel.janulgue@linux.intel.com> References: <20161012115954.16803-1-abdiel.janulgue@linux.intel.com> Subject: [Intel-gfx] [RFC i-g-t PATCH 2/3] igt/gem_wait: Use new igt_dummyload api 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-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Abdiel Janulgue --- tests/gem_wait.c | 77 +++++++++----------------------------------------------- 1 file changed, 12 insertions(+), 65 deletions(-) diff --git a/tests/gem_wait.c b/tests/gem_wait.c index 461efdb..24a5f5e 100644 --- a/tests/gem_wait.c +++ b/tests/gem_wait.c @@ -54,36 +54,6 @@ #define BUF_PAGES ((8<<20)>>12) drm_intel_bo *dst, *dst2; -/* returns time diff in milliseconds */ -static int64_t -do_time_diff(struct timespec *end, struct timespec *start) -{ - int64_t ret; - ret = (MSEC_PER_SEC * difftime(end->tv_sec, start->tv_sec)) + - ((end->tv_nsec/NSEC_PER_MSEC) - (start->tv_nsec/NSEC_PER_MSEC)); - return ret; -} - -static void blt_color_fill(struct intel_batchbuffer *batch, - drm_intel_bo *buf, - const unsigned int pages) -{ - const unsigned short height = pages/4; - const unsigned short width = 4096; - - COLOR_BLIT_COPY_BATCH_START(COLOR_BLT_WRITE_ALPHA | - XY_COLOR_BLT_WRITE_RGB); - OUT_BATCH((3 << 24) | /* 32 Bit Color */ - (0xF0 << 16) | /* Raster OP copy background register */ - 0); /* Dest pitch is 0 */ - OUT_BATCH(0); - OUT_BATCH(width << 16 | - height); - OUT_RELOC_FENCED(buf, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0); - OUT_BATCH(rand()); /* random pattern */ - ADVANCE_BATCH(); -} - static void render_timeout(int fd) { drm_intel_bufmgr *bufmgr; @@ -91,10 +61,11 @@ static void render_timeout(int fd) int64_t timeout = ENOUGH_WORK_IN_SECONDS * NSEC_PER_SEC; int64_t negative_timeout = -1; int ret; + const unsigned short height = BUF_PAGES/4; + const unsigned short width = 4096; const bool do_signals = true; /* signals will seem to make the operation * use less process CPU time */ - bool done = false; - int i, iter = 1; + int iter = 1; igt_skip_on_simulation(); @@ -112,30 +83,9 @@ static void render_timeout(int fd) /* Figure out a rough number of fills required to consume 1 second of * GPU work. */ - do { - struct timespec start, end; - long diff; - -#ifndef CLOCK_MONOTONIC_RAW -#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC -#endif - - igt_assert(clock_gettime(CLOCK_MONOTONIC_RAW, &start) == 0); - for (i = 0; i < iter; i++) - blt_color_fill(batch, dst, BUF_PAGES); - intel_batchbuffer_flush(batch); - drm_intel_bo_wait_rendering(dst); - igt_assert(clock_gettime(CLOCK_MONOTONIC_RAW, &end) == 0); - - diff = do_time_diff(&end, &start); - igt_assert(diff >= 0); - - if ((diff / MSEC_PER_SEC) > ENOUGH_WORK_IN_SECONDS) - done = true; - else - iter <<= 1; - } while (!done && iter < 1000000); - + iter = igt_calibrate_dummy_load(bufmgr, batch, fd, + dst->handle, 0, + width, height, 1, IGT_DUMMY_BLIT_FILL); igt_assert_lt(iter, 1000000); igt_debug("%d iters is enough work\n", iter); @@ -146,10 +96,9 @@ static void render_timeout(int fd) /* We should be able to do half as much work in the same amount of time, * but because we might schedule almost twice as much as required, we * might accidentally time out. Hence add some fudge. */ - for (i = 0; i < iter/3; i++) - blt_color_fill(batch, dst2, BUF_PAGES); - intel_batchbuffer_flush(batch); + igt_emit_dummy_load(bufmgr, batch, fd, dst2->handle, 0, + width, height, iter/3, 0, IGT_DUMMY_BLIT_FILL); igt_assert(gem_bo_busy(fd, dst2->handle) == true); igt_assert_eq(gem_wait(fd, dst2->handle, &timeout), 0); @@ -168,10 +117,9 @@ static void render_timeout(int fd) /* Now check that we correctly time out, twice the auto-tune load should * be good enough. */ timeout = ENOUGH_WORK_IN_SECONDS * NSEC_PER_SEC; - for (i = 0; i < iter*2; i++) - blt_color_fill(batch, dst2, BUF_PAGES); - intel_batchbuffer_flush(batch); + igt_emit_dummy_load(bufmgr, batch, fd, dst2->handle, 0, + width, height, iter*2, 0, IGT_DUMMY_BLIT_FILL); ret = gem_wait(fd, dst2->handle, &timeout); igt_assert_eq(ret, -ETIME); @@ -186,10 +134,9 @@ static void render_timeout(int fd) /* Now check that we can pass negative (infinite) timeouts. */ negative_timeout = -1; - for (i = 0; i < iter; i++) - blt_color_fill(batch, dst2, BUF_PAGES); - intel_batchbuffer_flush(batch); + igt_emit_dummy_load(bufmgr, batch, fd, dst2->handle, 0, + width, height, iter, 0, IGT_DUMMY_BLIT_FILL); igt_assert_eq(gem_wait(fd, dst2->handle, &negative_timeout), 0); igt_assert_eq(negative_timeout, -1); /* infinity always remains */