From patchwork Fri Jan 10 15:24:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 3466981 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7E8E99F2E9 for ; Fri, 10 Jan 2014 15:24:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3175E2010E for ; Fri, 10 Jan 2014 15:24:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8FF142012B for ; Fri, 10 Jan 2014 15:24:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 433C610652B; Fri, 10 Jan 2014 07:24:33 -0800 (PST) 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 ESMTP id 689E610645F for ; Fri, 10 Jan 2014 07:24:31 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 10 Jan 2014 07:24:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,638,1384329600"; d="scan'208";a="456734845" Received: from rosetta.fi.intel.com (HELO rosetta) ([10.237.72.60]) by fmsmga001.fm.intel.com with ESMTP; 10 Jan 2014 07:24:22 -0800 Received: by rosetta (Postfix, from userid 1000) id B0C6381E14; Fri, 10 Jan 2014 17:24:21 +0200 (EET) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Fri, 10 Jan 2014 17:24:17 +0200 Message-Id: <1389367457-13513-2-git-send-email-mika.kuoppala@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1389367457-13513-1-git-send-email-mika.kuoppala@intel.com> References: <1389367457-13513-1-git-send-email-mika.kuoppala@intel.com> Subject: [Intel-gfx] [PATCH 2/2] tests/gem_reset_stats: run tests on all rings X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Run all relevant tests on all rings. Suggested-by: Daniel Vetter Signed-off-by: Mika Kuoppala --- tests/gem_reset_stats.c | 132 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 90 insertions(+), 42 deletions(-) diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c index bed4a0c..a98e2ad 100644 --- a/tests/gem_reset_stats.c +++ b/tests/gem_reset_stats.c @@ -78,6 +78,41 @@ struct local_drm_i915_gem_context_destroy { static igt_debugfs_t dfs; +#define LOCAL_I915_EXEC_VEBOX (4 << 0) + +struct target_ring; + +static bool gem_has_render(int fd) +{ + return true; +} + +static bool has_context(const struct target_ring *ring); + +static const struct target_ring { + uint32_t exec; + bool (*present)(int fd); + bool (*contexts)(const struct target_ring *ring); + const char *name; +} rings[] = { + { I915_EXEC_RENDER, gem_has_render, has_context, "render" }, + { I915_EXEC_BLT, gem_has_blt, has_context, "blt" }, + { I915_EXEC_BSD, gem_has_bsd, has_context, "bsd" }, + { LOCAL_I915_EXEC_VEBOX, gem_has_vebox, has_context, "vebox" }, +}; + +static bool has_context(const struct target_ring *ring) +{ + if(ring->exec == I915_EXEC_RENDER) + return true; + + return false; +} + +#define NUM_RINGS (sizeof(rings)/sizeof(struct target_ring)) + +static const struct target_ring *current_ring; + static uint32_t context_create(int fd) { struct local_drm_i915_gem_context_create create; @@ -160,7 +195,7 @@ static int gem_exec(int fd, struct drm_i915_gem_execbuffer2 *execbuf) return 0; } -static int exec_valid(int fd, int ctx) +static int exec_valid_ring(int fd, int ctx, int ring) { struct drm_i915_gem_execbuffer2 execbuf; struct drm_i915_gem_exec_object2 exec; @@ -186,7 +221,7 @@ static int exec_valid(int fd, int ctx) execbuf.num_cliprects = 0; execbuf.DR1 = 0; execbuf.DR4 = 0; - execbuf.flags = 0; + execbuf.flags = ring; i915_execbuffer2_set_context_id(execbuf, ctx); execbuf.rsvd2 = 0; @@ -197,6 +232,11 @@ static int exec_valid(int fd, int ctx) return exec.handle; } +static int exec_valid(int fd, int ctx) +{ + return exec_valid_ring(fd, ctx, current_ring->exec); +} + static void stop_rings(void) { int fd; @@ -211,7 +251,7 @@ static void stop_rings(void) #define BUFSIZE (4 * 1024) #define ITEMS (BUFSIZE >> 2) -static int inject_hang(int fd, int ctx) +static int inject_hang_ring(int fd, int ctx, int ring) { struct drm_i915_gem_execbuffer2 execbuf; struct drm_i915_gem_exec_object2 exec; @@ -249,7 +289,7 @@ static int inject_hang(int fd, int ctx) execbuf.num_cliprects = 0; execbuf.DR1 = 0; execbuf.DR4 = 0; - execbuf.flags = 0; + execbuf.flags = ring; i915_execbuffer2_set_context_id(execbuf, ctx); execbuf.rsvd2 = 0; @@ -290,7 +330,7 @@ static int inject_hang(int fd, int ctx) execbuf.num_cliprects = 0; execbuf.DR1 = 0; execbuf.DR4 = 0; - execbuf.flags = 0; + execbuf.flags = ring; i915_execbuffer2_set_context_id(execbuf, ctx); execbuf.rsvd2 = 0; @@ -305,6 +345,11 @@ static int inject_hang(int fd, int ctx) return exec.handle; } +static int inject_hang(int fd, int ctx) +{ + return inject_hang_ring(fd, ctx, current_ring->exec); +} + static int _assert_reset_status(int fd, int ctx, int status) { int rs; @@ -727,20 +772,6 @@ static void test_close_pending(void) close(fd); } -#define LOCAL_I915_EXEC_VEBOX (4 << 0) - -static const struct target_ring { - uint32_t exec; - bool (*avail)(int); -} rings[] = { - { 0, 0 }, - { I915_EXEC_BLT, gem_has_blt }, - { I915_EXEC_BSD, gem_has_bsd }, - { LOCAL_I915_EXEC_VEBOX, gem_has_vebox }, -}; - -#define NUM_RINGS (sizeof(rings)/sizeof(struct target_ring)) - static void exec_noop_on_each_ring(int fd, const bool reverse) { uint32_t batch[2] = {MI_BATCH_BUFFER_END, 0}; @@ -777,7 +808,7 @@ static void exec_noop_on_each_ring(int fd, const bool reverse) ring = reverse ? &rings[NUM_RINGS - 1 - i] : &rings[i]; - if (!ring->avail || (ring->avail && ring->avail(fd))) { + if (ring->present(fd)) { execbuf.flags = ring->exec; do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf); } @@ -980,17 +1011,19 @@ static void test_params(void) close(fd); } +#define RING_HAS_CONTEXTS current_ring->contexts(current_ring) +#define RUN_CTX_TEST(...) do { igt_skip_on(RING_HAS_CONTEXTS == false); __VA_ARGS__; } while (0) igt_main { struct local_drm_i915_gem_context_create create; uint32_t devid; - int fd; int ret; igt_skip_on_simulation(); igt_fixture { + int fd; fd = drm_open_any(); devid = intel_get_drm_devid(fd); igt_require_f(intel_gen(devid) >= 4, @@ -1009,35 +1042,50 @@ igt_main igt_subtest("params") test_params(); - igt_subtest("reset-stats") - test_rs(4, 1, 0); + for (int i = 0; i < NUM_RINGS; i++) { + const char *name; + int fd; + + current_ring = &rings[i]; + name = current_ring->name; - igt_subtest("reset-stats-ctx") - test_rs_ctx(4, 4, 1, 2); + fd = drm_open_any(); + gem_require_ring(fd, current_ring->exec); + + igt_subtest_f("reset-stats-%s", name) + test_rs(4, 1, 0); + + igt_subtest_f("reset-stats-ctx-%s", name) + RUN_CTX_TEST(test_rs_ctx(4, 4, 1, 2)); - igt_subtest("ban") - test_ban(); + igt_subtest_f("ban-%s", name) + test_ban(); - igt_subtest("ban-ctx") - test_ban_ctx(); + igt_subtest_f("ban-ctx-%s", name) + RUN_CTX_TEST(test_ban_ctx()); - igt_subtest("unrelated-ctx") - test_unrelated_ctx(); + igt_subtest_f("reset-count-%s", name) + test_reset_count(false); - igt_subtest("reset-count") - test_reset_count(false); + igt_subtest_f("reset-count-ctx-%s", name) + RUN_CTX_TEST(test_reset_count(true)); - igt_subtest("reset-count-ctx") - test_reset_count(true); + igt_subtest_f("unrelated-ctx-%s", name) + RUN_CTX_TEST(test_unrelated_ctx()); - igt_subtest("close-pending") - test_close_pending(); + igt_subtest_f("close-pending-%s", name) { + test_close_pending(); + gem_quiescent_gpu(fd); + } - igt_subtest("close-pending-ctx") - test_close_pending_ctx(); + igt_subtest_f("close-pending-ctx-%s", name) { + RUN_CTX_TEST(test_close_pending_ctx()); + gem_quiescent_gpu(fd); + } - igt_subtest("close-pending-fork") { - test_close_pending_fork(true); - test_close_pending_fork(false); + igt_subtest_f("close-pending-fork-%s", name) { + test_close_pending_fork(true); + test_close_pending_fork(false); + } } }