From patchwork Tue Jul 30 03:58:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramalingam C X-Patchwork-Id: 11065557 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 70DC8912 for ; Tue, 30 Jul 2019 10:57:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 607C5286A4 for ; Tue, 30 Jul 2019 10:57:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54D442871A; Tue, 30 Jul 2019 10:57:25 +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=-3.7 required=2.0 tests=BAYES_00,DATE_IN_PAST_06_12, 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 DFC25286A4 for ; Tue, 30 Jul 2019 10:57:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 715796E48F; Tue, 30 Jul 2019 10:57:24 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8877B6E48F for ; Tue, 30 Jul 2019 10:57:23 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jul 2019 03:57:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,326,1559545200"; d="scan'208";a="371499522" Received: from ramaling-i9x.iind.intel.com ([10.99.66.154]) by fmsmga006.fm.intel.com with ESMTP; 30 Jul 2019 03:57:21 -0700 From: Ramalingam C To: intel-gfx Date: Tue, 30 Jul 2019 09:28:35 +0530 Message-Id: <20190730035835.24103-1-ramalingam.c@intel.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v5] tests/i915/gem_exec_async: Update with engine discovery 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Legacy execbuf abi tests are prefixed with legacy. New test are added to run on physical engines accessed through engine discovery. So legacy tests run on the unconfigured (with engine map) context and use a new helper gem_eb_flags_to_engine to look up the engine from the intel_execution_engines2 static list. This is only to enable the core test code to be shared. Places where new contexts are created had to be updated to either equally configure the contexts or not. v2: retained the test as it is for legacy uapi testing and duplciated for new engine discovery [Tvrtko] v3: Few nits addressed [Tvrtko] v4: In legacy uAPI test path, iterate through for_each_engine [Tvrtko] v5: Function for exec_flag comparison [Tvrtko] Signed-off-by: Ramalingam C --- lib/igt_gt.c | 25 ++++++++++++++++++ lib/igt_gt.h | 1 + tests/i915/gem_exec_async.c | 52 +++++++++++++++++++++++++++---------- 3 files changed, 64 insertions(+), 14 deletions(-) diff --git a/lib/igt_gt.c b/lib/igt_gt.c index 78e3cd08925b..f594a46282bc 100644 --- a/lib/igt_gt.c +++ b/lib/igt_gt.c @@ -633,3 +633,28 @@ bool gem_ring_has_physical_engine(int fd, unsigned ring) return gem_has_ring(fd, ring); } + +bool gem_eb_flags_are_different_engines(unsigned eb_flag1, unsigned eb_flag2) +{ + if (eb_flag1 == eb_flag2) + return false; + + /* DEFAULT stands for RENDER in legacy uAPI*/ + if ((eb_flag1 == I915_EXEC_DEFAULT && eb_flag2 == I915_EXEC_RENDER) || + (eb_flag1 == I915_EXEC_RENDER && eb_flag2 == I915_EXEC_DEFAULT)) + return false; + + /* + * BSD could be executed on BSD1/BSD2. So BSD and BSD-n could be + * same engine. + */ + if ((eb_flag1 == I915_EXEC_BSD) && + (eb_flag2 & ~I915_EXEC_BSD_MASK) == I915_EXEC_BSD) + return false; + + if ((eb_flag2 == I915_EXEC_BSD) && + (eb_flag1 & ~I915_EXEC_BSD_MASK) == I915_EXEC_BSD) + return false; + + return true; +} diff --git a/lib/igt_gt.h b/lib/igt_gt.h index 73b5002a04bd..760b8baefc48 100644 --- a/lib/igt_gt.h +++ b/lib/igt_gt.h @@ -101,5 +101,6 @@ extern const struct intel_execution_engine2 { } intel_execution_engines2[]; int gem_execbuf_flags_to_engine_class(unsigned int flags); +bool gem_eb_flags_are_different_engines(unsigned eb_flag1, unsigned eb_flag2); #endif /* IGT_GT_H */ diff --git a/tests/i915/gem_exec_async.c b/tests/i915/gem_exec_async.c index 9a06af7e29cb..5fdce5ac5b77 100644 --- a/tests/i915/gem_exec_async.c +++ b/tests/i915/gem_exec_async.c @@ -80,9 +80,10 @@ static void store_dword(int fd, unsigned ring, gem_close(fd, obj[1].handle); } -static void one(int fd, unsigned ring, uint32_t flags) +static void one(int fd, const struct intel_execution_engine2 *e2, bool legacy) { const int gen = intel_gen(intel_get_drm_devid(fd)); + const struct intel_execution_engine2 *other2; struct drm_i915_gem_exec_object2 obj[2]; #define SCRATCH 0 #define BATCH 1 @@ -138,20 +139,33 @@ static void one(int fd, unsigned ring, uint32_t flags) memset(&execbuf, 0, sizeof(execbuf)); execbuf.buffers_ptr = to_user_pointer(obj); execbuf.buffer_count = 2; - execbuf.flags = ring | flags; + execbuf.flags = e2->flags; igt_require(__gem_execbuf(fd, &execbuf) == 0); gem_close(fd, obj[BATCH].handle); i = 0; - for_each_physical_engine(fd, other) { - if (other == ring) - continue; + if (legacy) { + for_each_engine(fd, other) { + if (gem_eb_flags_are_different_engines(e2->flags, other)) + continue; - if (!gem_can_store_dword(fd, other)) - continue; + if (!gem_can_store_dword(fd, other)) + continue; + + store_dword(fd, other, obj[SCRATCH].handle, 4*i, i); + i++; + } + } else { + __for_each_physical_engine(fd, other2) { + if (gem_engine_is_equal(e2, other2)) + continue; - store_dword(fd, other, obj[SCRATCH].handle, 4*i, i); - i++; + if (!gem_class_can_store_dword(fd, other2->class)) + continue; + + store_dword(fd, other2->flags, obj[SCRATCH].handle, 4*i, i); + i++; + } } *batch = MI_BATCH_BUFFER_END; @@ -185,7 +199,9 @@ static bool has_async_execbuf(int fd) igt_main { + const struct intel_execution_engine2 *e2; const struct intel_execution_engine *e; + struct intel_execution_engine2 e2__; int fd = -1; igt_skip_on_simulation(); @@ -200,14 +216,22 @@ igt_main } for (e = intel_execution_engines; e->name; e++) { - /* default exec-id is purely symbolic */ - if (e->exec_id == 0) + e2__ = gem_eb_flags_to_engine(e->exec_id | e->flags); + if (e2__.flags == -1) continue; + e2 = &e2__; - igt_subtest_f("concurrent-writes-%s", e->name) { + igt_subtest_f("legacy-concurrent-writes-%s", e2->name) { igt_require(gem_ring_has_physical_engine(fd, e->exec_id | e->flags)); - igt_require(gem_can_store_dword(fd, e->exec_id | e->flags)); - one(fd, e->exec_id, e->flags); + igt_require(gem_class_can_store_dword(fd, e2->class)); + one(fd, e2, true); + } + } + + __for_each_physical_engine(fd, e2) { + igt_subtest_f("concurrent-writes-%s", e2->name) { + igt_require(gem_class_can_store_dword(fd, e2->class)); + one(fd, e2, false); } }