From patchwork Wed Oct 12 11:59:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdiel Janulgue X-Patchwork-Id: 9372425 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 D824F60839 for ; Wed, 12 Oct 2016 12:00:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C789C2954F for ; Wed, 12 Oct 2016 12:00:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBE5329552; Wed, 12 Oct 2016 12:00:14 +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 D972E29550 for ; Wed, 12 Oct 2016 12:00:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A7EAE6E83A; Wed, 12 Oct 2016 12:00:07 +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 3AFC46E835 for ; Wed, 12 Oct 2016 12:00:04 +0000 (UTC) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP; 12 Oct 2016 05:00:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,482,1473145200"; d="scan'208";a="18803177" Received: from abj-mbp11.fi.intel.com ([10.237.68.148]) by fmsmga005.fm.intel.com with ESMTP; 12 Oct 2016 05:00:03 -0700 From: Abdiel Janulgue To: intel-gfx@lists.freedesktop.org Date: Wed, 12 Oct 2016 14:59:54 +0300 Message-Id: <20161012115954.16803-4-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 3/3] igt/kms_flip: 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/kms_flip.c | 191 +++---------------------------------------------------- 1 file changed, 10 insertions(+), 181 deletions(-) diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 065ad66..93cf391 100644 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -187,109 +187,6 @@ static unsigned long gettime_us(void) return ts.tv_sec * 1000000 + ts.tv_nsec / 1000; } -static int calibrate_dummy_load(struct test_output *o, - const char *ring_name, - int (*emit)(struct test_output *o, int limit, int timeout)) -{ - unsigned long start; - int ops = 1; - - start = gettime_us(); - - do { - unsigned long diff; - int ret; - - ret = emit(o, (ops+1)/2, 10); - diff = gettime_us() - start; - - if (ret || diff / USEC_PER_SEC >= 1) - break; - - ops += ops; - } while (ops < 100000); - - igt_debug("%s dummy load calibrated: %d operations / second\n", - ring_name, ops); - - return ops; -} - -static void blit_copy(drm_intel_bo *dst, drm_intel_bo *src, - unsigned int width, unsigned int height, - unsigned int dst_pitch, unsigned int src_pitch) -{ - BLIT_COPY_BATCH_START(0); - OUT_BATCH((3 << 24) | /* 32 bits */ - (0xcc << 16) | /* copy ROP */ - dst_pitch); - OUT_BATCH(0 << 16 | 0); - OUT_BATCH(height << 16 | width); - OUT_RELOC_FENCED(dst, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0); - OUT_BATCH(0 << 16 | 0); - OUT_BATCH(src_pitch); - OUT_RELOC_FENCED(src, I915_GEM_DOMAIN_RENDER, 0, 0); - ADVANCE_BATCH(); - - if (batch->gen >= 6) { - BEGIN_BATCH(3, 0); - OUT_BATCH(XY_SETUP_CLIP_BLT_CMD); - OUT_BATCH(0); - OUT_BATCH(0); - ADVANCE_BATCH(); - } -} - -static int _emit_dummy_load__bcs(struct test_output *o, int limit, int timeout) -{ - int i, ret = 0; - drm_intel_bo *src_bo, *dst_bo, *fb_bo; - struct igt_fb *fb_info = &o->fb_info[o->current_fb_id]; - - igt_require(bufmgr); - - src_bo = drm_intel_bo_alloc(bufmgr, "dummy_bo", 2048*2048*4, 4096); - igt_assert(src_bo); - - dst_bo = drm_intel_bo_alloc(bufmgr, "dummy_bo", 2048*2048*4, 4096); - igt_assert(dst_bo); - - fb_bo = gem_handle_to_libdrm_bo(bufmgr, drm_fd, "imported", fb_info->gem_handle); - igt_assert(fb_bo); - - for (i = 0; i < limit; i++) { - blit_copy(dst_bo, src_bo, - 2048, 2048, - 2048*4, 2048*4); - - igt_swap(src_bo, dst_bo); - } - blit_copy(fb_bo, src_bo, - min(o->fb_width, 2048), min(o->fb_height, 2048), - fb_info->stride, 2048*4); - intel_batchbuffer_flush(batch); - - if (timeout > 0) - ret = drm_intel_gem_bo_wait(fb_bo, timeout * NSEC_PER_SEC); - - drm_intel_bo_unreference(src_bo); - drm_intel_bo_unreference(dst_bo); - drm_intel_bo_unreference(fb_bo); - - return ret; -} - -static void emit_dummy_load__bcs(struct test_output *o, int seconds) -{ - static int ops_per_sec; - - if (ops_per_sec == 0) - ops_per_sec = calibrate_dummy_load(o, "bcs", - _emit_dummy_load__bcs); - - _emit_dummy_load__bcs(o, seconds * ops_per_sec, 0); -} - static void emit_fence_stress(struct test_output *o) { const int num_fences = gem_available_fences(drm_fd); @@ -334,82 +231,6 @@ static void emit_fence_stress(struct test_output *o) free(exec); } -static int _emit_dummy_load__rcs(struct test_output *o, int limit, int timeout) -{ - const struct igt_fb *fb_info = &o->fb_info[o->current_fb_id]; - igt_render_copyfunc_t copyfunc; - struct igt_buf sb[3], *src, *dst, *fb; - int i, ret = 0; - - igt_require(bufmgr); - - copyfunc = igt_get_render_copyfunc(devid); - if (copyfunc == NULL) - return _emit_dummy_load__bcs(o, limit, timeout); - - sb[0].bo = drm_intel_bo_alloc(bufmgr, "dummy_bo", 2048*2048*4, 4096); - igt_assert(sb[0].bo); - sb[0].size = sb[0].bo->size; - sb[0].tiling = I915_TILING_NONE; - sb[0].data = NULL; - sb[0].num_tiles = sb[0].bo->size; - sb[0].stride = 4 * 2048; - - sb[1].bo = drm_intel_bo_alloc(bufmgr, "dummy_bo", 2048*2048*4, 4096); - igt_assert(sb[1].bo); - sb[1].size = sb[1].bo->size; - sb[1].tiling = I915_TILING_NONE; - sb[1].data = NULL; - sb[1].num_tiles = sb[1].bo->size; - sb[1].stride = 4 * 2048; - - sb[2].bo = gem_handle_to_libdrm_bo(bufmgr, drm_fd, "imported", fb_info->gem_handle); - igt_assert(sb[2].bo); - sb[2].size = sb[2].bo->size; - sb[2].tiling = fb_info->tiling; - sb[2].data = NULL; - sb[2].num_tiles = sb[2].bo->size; - sb[2].stride = fb_info->stride; - - src = &sb[0]; - dst = &sb[1]; - fb = &sb[2]; - - for (i = 0; i < limit; i++) { - copyfunc(batch, NULL, - src, 0, 0, - 2048, 2048, - dst, 0, 0); - - igt_swap(src, dst); - } - copyfunc(batch, NULL, - src, 0, 0, - min(o->fb_width, 2048), min(o->fb_height, 2048), - fb, 0, 0); - intel_batchbuffer_flush(batch); - - if (timeout > 0) - ret = drm_intel_gem_bo_wait(fb->bo, timeout * NSEC_PER_SEC); - - drm_intel_bo_unreference(sb[0].bo); - drm_intel_bo_unreference(sb[1].bo); - drm_intel_bo_unreference(sb[2].bo); - - return ret; -} - -static void emit_dummy_load__rcs(struct test_output *o, int seconds) -{ - static int ops_per_sec; - - if (ops_per_sec == 0) - ops_per_sec = calibrate_dummy_load(o, "rcs", - _emit_dummy_load__rcs); - - _emit_dummy_load__bcs(o, seconds * ops_per_sec, 0); -} - static void dpms_off_other_outputs(struct test_output *o) { int i, n; @@ -865,10 +686,18 @@ static unsigned int run_test_step(struct test_output *o) o->current_fb_id = !o->current_fb_id; if (o->flags & TEST_WITH_DUMMY_BCS) - emit_dummy_load__bcs(o, 1); + igt_emit_dummy_load(bufmgr, batch, drm_fd, + o->fb_info[o->current_fb_id].gem_handle, + o->fb_info[o->current_fb_id].stride, + o->fb_width, o->fb_height, 0, 1, + IGT_DUMMY_BLIT_COPY); if (o->flags & TEST_WITH_DUMMY_RCS) - emit_dummy_load__rcs(o, 1); + igt_emit_dummy_load(bufmgr, batch, drm_fd, + o->fb_info[o->current_fb_id].gem_handle, + o->fb_info[o->current_fb_id].stride, + o->fb_width, o->fb_height, 0, 1, + IGT_DUMMY_RENDER_COPY); if (o->flags & TEST_FB_RECREATE) recreate_fb(o);