From patchwork Tue Apr 23 14:00:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 10913147 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 20A6B1390 for ; Tue, 23 Apr 2019 14:00:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C83C288B8 for ; Tue, 23 Apr 2019 14:00:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDF86288E8; Tue, 23 Apr 2019 14:00:52 +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 51BF7288BA for ; Tue, 23 Apr 2019 14:00:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 417D789316; Tue, 23 Apr 2019 14:00:51 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 54437892D7 for ; Tue, 23 Apr 2019 14:00:48 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Apr 2019 07:00:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,386,1549958400"; d="scan'208";a="340006499" Received: from rosetta.fi.intel.com ([10.237.72.186]) by fmsmga005.fm.intel.com with ESMTP; 23 Apr 2019 07:00:46 -0700 Received: by rosetta.fi.intel.com (Postfix, from userid 1000) id 64BDE8404FD; Tue, 23 Apr 2019 17:00:41 +0300 (EEST) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Tue, 23 Apr 2019 17:00:37 +0300 Message-Id: <20190423140038.20190-2-mika.kuoppala@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190423140038.20190-1-mika.kuoppala@linux.intel.com> References: <20190423140038.20190-1-mika.kuoppala@linux.intel.com> Subject: [Intel-gfx] [PATCH i-g-t 2/3] lib/igt_dummyload: Clarify batch mapping 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Use spin->condition to mark the spot we have saved for manipulating the looping condition. Cc: Chris Wilson Signed-off-by: Mika Kuoppala Reviewed-by: Chris Wilson --- lib/igt_dummyload.c | 66 ++++++++++++++++++++--------------- lib/igt_dummyload.h | 4 ++- tests/i915/gem_exec_latency.c | 2 -- 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c index 12465024..8b0a2a17 100644 --- a/lib/igt_dummyload.c +++ b/lib/igt_dummyload.c @@ -62,6 +62,8 @@ #define MI_ARB_CHK (0x5 << 23) static const int BATCH_SIZE = 4096; +static const int LOOP_START_OFFSET = 64; + static IGT_LIST(spin_list); static pthread_mutex_t list_lock = PTHREAD_MUTEX_INITIALIZER; @@ -78,7 +80,7 @@ emit_recursive_batch(igt_spin_t *spin, unsigned int engines[16]; unsigned int nengine; int fence_fd = -1; - uint32_t *batch, *batch_start; + uint32_t *cs, *batch; int i; nengine = 0; @@ -108,11 +110,12 @@ emit_recursive_batch(igt_spin_t *spin, 0, BATCH_SIZE, PROT_WRITE); if (!batch) batch = gem_mmap__gtt(fd, obj[BATCH].handle, - BATCH_SIZE, PROT_WRITE); + BATCH_SIZE, PROT_WRITE); + gem_set_domain(fd, obj[BATCH].handle, - I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); + I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); execbuf->buffer_count++; - batch_start = batch; + cs = batch; if (opts->dependency) { igt_assert(!(opts->flags & IGT_SPIN_POLL_RUN)); @@ -160,31 +163,34 @@ emit_recursive_batch(igt_spin_t *spin, r->offset = sizeof(uint32_t) * 1; r->delta = sizeof(uint32_t) * SPIN_POLL_START_IDX; - *batch++ = MI_STORE_DWORD_IMM | (gen < 6 ? 1 << 22 : 0); + *cs++ = MI_STORE_DWORD_IMM | (gen < 6 ? 1 << 22 : 0); if (gen >= 8) { - *batch++ = r->presumed_offset + r->delta; - *batch++ = 0; + *cs++ = r->presumed_offset + r->delta; + *cs++ = 0; } else if (gen >= 4) { - *batch++ = 0; - *batch++ = r->presumed_offset + r->delta; + *cs++ = 0; + *cs++ = r->presumed_offset + r->delta; r->offset += sizeof(uint32_t); } else { - batch[-1]--; - *batch++ = r->presumed_offset + r->delta; + cs[-1]--; + *cs++ = r->presumed_offset + r->delta; } - *batch++ = 1; + *cs++ = 1; execbuf->buffer_count++; } - spin->batch = batch = batch_start + 64 / sizeof(*batch); spin->handle = obj[BATCH].handle; + igt_assert_lt(cs - batch, LOOP_START_OFFSET / sizeof(*cs)); + spin->condition = batch + LOOP_START_OFFSET / sizeof(*cs); + cs = spin->condition; + /* Allow ourselves to be preempted */ if (!(opts->flags & IGT_SPIN_NO_PREEMPTION)) - *batch++ = MI_ARB_CHK; + *cs++ = MI_ARB_CHK; /* Pad with a few nops so that we do not completely hog the system. * @@ -198,27 +204,27 @@ emit_recursive_batch(igt_spin_t *spin, * trouble. See https://bugs.freedesktop.org/show_bug.cgi?id=102262 */ if (!(opts->flags & IGT_SPIN_FAST)) - batch += 1000; + cs += 1000; /* recurse */ r = &relocs[obj[BATCH].relocation_count++]; r->target_handle = obj[BATCH].handle; - r->offset = (batch + 1 - batch_start) * sizeof(*batch); + r->offset = (cs + 1 - batch) * sizeof(*cs); r->read_domains = I915_GEM_DOMAIN_COMMAND; - r->delta = 64; + r->delta = LOOP_START_OFFSET; if (gen >= 8) { - *batch++ = MI_BATCH_BUFFER_START | 1 << 8 | 1; - *batch++ = r->delta; - *batch++ = 0; + *cs++ = MI_BATCH_BUFFER_START | 1 << 8 | 1; + *cs++ = r->delta; + *cs++ = 0; } else if (gen >= 6) { - *batch++ = MI_BATCH_BUFFER_START | 1 << 8; - *batch++ = r->delta; + *cs++ = MI_BATCH_BUFFER_START | 1 << 8; + *cs++ = r->delta; } else { - *batch++ = MI_BATCH_BUFFER_START | 2 << 6; + *cs++ = MI_BATCH_BUFFER_START | 2 << 6; if (gen < 4) r->delta |= 1; - *batch = r->delta; - batch++; + *cs = r->delta; + cs++; } obj[BATCH].relocs_ptr = to_user_pointer(relocs); @@ -252,6 +258,8 @@ emit_recursive_batch(igt_spin_t *spin, } } + igt_assert_lt(cs - batch, BATCH_SIZE / sizeof(*cs)); + /* Make it easier for callers to resubmit. */ obj[BATCH].relocation_count = 0; @@ -260,7 +268,7 @@ emit_recursive_batch(igt_spin_t *spin, obj[SCRATCH].flags = EXEC_OBJECT_PINNED; obj[BATCH].flags = EXEC_OBJECT_PINNED; - spin->cmd_precondition = *spin->batch; + spin->cmd_precondition = *spin->condition; return fence_fd; } @@ -382,7 +390,7 @@ void igt_spin_reset(igt_spin_t *spin) if (igt_spin_has_poll(spin)) spin->poll[SPIN_POLL_START_IDX] = 0; - *spin->batch = spin->cmd_precondition; + *spin->condition = spin->cmd_precondition; __sync_synchronize(); } @@ -397,7 +405,7 @@ void igt_spin_end(igt_spin_t *spin) if (!spin) return; - *spin->batch = MI_BATCH_BUFFER_END; + *spin->condition = MI_BATCH_BUFFER_END; __sync_synchronize(); } @@ -422,7 +430,7 @@ void igt_spin_free(int fd, igt_spin_t *spin) timer_delete(spin->timer); igt_spin_end(spin); - gem_munmap((void *)((unsigned long)spin->batch & (~4095UL)), + gem_munmap((void *)((unsigned long)spin->condition & (~4095UL)), BATCH_SIZE); if (spin->poll) { diff --git a/lib/igt_dummyload.h b/lib/igt_dummyload.h index 34537f27..61a9f2fc 100644 --- a/lib/igt_dummyload.h +++ b/lib/igt_dummyload.h @@ -36,8 +36,10 @@ typedef struct igt_spin { unsigned int handle; timer_t timer; struct igt_list link; - uint32_t *batch; + + uint32_t *condition; uint32_t cmd_precondition; + int out_fence; struct drm_i915_gem_exec_object2 obj[2]; struct drm_i915_gem_execbuffer2 execbuf; diff --git a/tests/i915/gem_exec_latency.c b/tests/i915/gem_exec_latency.c index 2cfb78bf..e56d6278 100644 --- a/tests/i915/gem_exec_latency.c +++ b/tests/i915/gem_exec_latency.c @@ -83,8 +83,6 @@ poll_ring(int fd, unsigned ring, const char *name) spin[1] = __igt_spin_factory(fd, &opts); igt_assert(igt_spin_has_poll(spin[1])); - igt_assert(*spin[0]->batch == *spin[1]->batch); - igt_spin_end(spin[0]); igt_spin_busywait_until_started(spin[1]);