From patchwork Wed Nov 23 10:59:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdiel Janulgue X-Patchwork-Id: 9442963 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 9DD686075F for ; Wed, 23 Nov 2016 11:00:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABF00203B9 for ; Wed, 23 Nov 2016 11:00:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0A1C2236A; Wed, 23 Nov 2016 11:00:23 +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 3E056203B9 for ; Wed, 23 Nov 2016 11:00:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4E2426E7FD; Wed, 23 Nov 2016 11:00:22 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1B38D6E7EF for ; Wed, 23 Nov 2016 10:59:58 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP; 23 Nov 2016 02:59:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,537,1473145200"; d="scan'208";a="8374911" Received: from abdiel-macbookpro.fi.intel.com ([10.237.66.47]) by orsmga002.jf.intel.com with ESMTP; 23 Nov 2016 02:59:56 -0800 From: Abdiel Janulgue To: intel-gfx@lists.freedesktop.org Date: Wed, 23 Nov 2016 12:59:43 +0200 Message-Id: <20161123105943.5157-6-abdiel.janulgue@linux.intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161123105943.5157-1-abdiel.janulgue@linux.intel.com> References: <20161123105943.5157-1-abdiel.janulgue@linux.intel.com> Cc: Daniel Vetter Subject: [Intel-gfx] [i-g-t PATCH v10 5/5] igt/kms_busy.c: Use new igt_spin_batch 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 v7: Adapt to api rename v8: Tidy up finish_fb_busy (Chris Wilson) v10: Adapt to api rename Cc: Chris Wilson Cc: Daniel Vetter Reviewed-by: Tomeu Vizoso Signed-off-by: Abdiel Janulgue --- tests/kms_busy.c | 80 ++++---------------------------------------------------- 1 file changed, 5 insertions(+), 75 deletions(-) diff --git a/tests/kms_busy.c b/tests/kms_busy.c index b555f99..3627e8e 100644 --- a/tests/kms_busy.c +++ b/tests/kms_busy.c @@ -78,80 +78,11 @@ static void do_cleanup_display(igt_display_t *dpy) igt_display_commit2(dpy, dpy->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); } -static uint32_t * -make_fb_busy(igt_display_t *dpy, unsigned ring, const struct igt_fb *fb) -{ - const int gen = intel_gen(intel_get_drm_devid(dpy->drm_fd)); - struct drm_i915_gem_exec_object2 obj[2]; -#define SCRATCH 0 -#define BATCH 1 - struct drm_i915_gem_relocation_entry reloc[2]; - struct drm_i915_gem_execbuffer2 execbuf; - uint32_t *batch; - int i; - - memset(&execbuf, 0, sizeof(execbuf)); - execbuf.buffers_ptr = (uintptr_t)obj; - execbuf.buffer_count = 2; - execbuf.flags = ring; - - memset(obj, 0, sizeof(obj)); - obj[SCRATCH].handle = fb->gem_handle; - - obj[BATCH].handle = gem_create(dpy->drm_fd, 4096); - obj[BATCH].relocs_ptr = (uintptr_t)reloc; - obj[BATCH].relocation_count = 2; - memset(reloc, 0, sizeof(reloc)); - reloc[0].target_handle = obj[BATCH].handle; /* recurse */ - reloc[0].presumed_offset = 0; - reloc[0].offset = sizeof(uint32_t); - reloc[0].delta = 0; - reloc[0].read_domains = I915_GEM_DOMAIN_COMMAND; - reloc[0].write_domain = 0; - - batch = gem_mmap__wc(dpy->drm_fd, - obj[BATCH].handle, 0, 4096, PROT_WRITE); - gem_set_domain(dpy->drm_fd, obj[BATCH].handle, - I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); - - batch[i = 0] = MI_BATCH_BUFFER_START; - if (gen >= 8) { - batch[i] |= 1 << 8 | 1; - batch[++i] = 0; - batch[++i] = 0; - } else if (gen >= 6) { - batch[i] |= 1 << 8; - batch[++i] = 0; - } else { - batch[i] |= 2 << 6; - batch[++i] = 0; - if (gen < 4) { - batch[i] |= 1; - reloc[0].delta = 1; - } - } - - /* dummy write to fb */ - reloc[1].target_handle = obj[SCRATCH].handle; - reloc[1].presumed_offset = 0; - reloc[1].offset = 1024; - reloc[1].delta = 0; - reloc[1].read_domains = I915_GEM_DOMAIN_RENDER; - reloc[1].write_domain = I915_GEM_DOMAIN_RENDER; - - gem_execbuf(dpy->drm_fd, &execbuf); - gem_close(dpy->drm_fd, obj[BATCH].handle); - - return batch; -} - -static void finish_fb_busy(uint32_t *batch, int msecs) +static void finish_fb_busy(igt_spin_t *spin, int msecs) { struct timespec tv = { 0, msecs * 1000 * 1000 }; nanosleep(&tv, NULL); - batch[0] = MI_BATCH_BUFFER_END; - __sync_synchronize(); - munmap(batch, 4096); + igt_spin_batch_end(spin); } static void sighandler(int sig) @@ -165,9 +96,7 @@ static void flip_to_fb(igt_display_t *dpy, int pipe, struct pollfd pfd = { .fd = dpy->drm_fd, .events = POLLIN }; struct timespec tv = { 1, 0 }; struct drm_event_vblank ev; - uint32_t *batch; - - batch = make_fb_busy(dpy, ring, fb); + igt_spin_t *t = igt_spin_batch_new(dpy->drm_fd, ring, fb->gem_handle); igt_fork(child, 1) { igt_assert(gem_bo_busy(dpy->drm_fd, fb->gem_handle)); do_or_die(drmModePageFlip(dpy->drm_fd, @@ -179,7 +108,8 @@ static void flip_to_fb(igt_display_t *dpy, int pipe, } igt_assert_f(nanosleep(&tv, NULL) == -1, "flip to %s blocked waiting for busy fb", name); - finish_fb_busy(batch, 2*TIMEOUT); + finish_fb_busy(t, 2*TIMEOUT); + igt_spin_batch_free(dpy->drm_fd, t); igt_waitchildren(); igt_assert(read(dpy->drm_fd, &ev, sizeof(ev)) == sizeof(ev)); igt_assert(poll(&pfd, 1, 0) == 0);