From patchwork Wed Mar 8 10:44:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mika Kuoppala X-Patchwork-Id: 9610741 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 E090D60414 for ; Wed, 8 Mar 2017 10:42:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DEFD2856E for ; Wed, 8 Mar 2017 10:42:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FFEA28574; Wed, 8 Mar 2017 10:42:50 +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 67F5E2856E for ; Wed, 8 Mar 2017 10:42:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1EF7A6E89C; Wed, 8 Mar 2017 10:42:49 +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 459376E89B for ; Wed, 8 Mar 2017 10:42:48 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP; 08 Mar 2017 02:42:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.36,262,1486454400"; d="scan'208"; a="1119927934" Received: from rosetta.fi.intel.com ([10.237.72.176]) by fmsmga001.fm.intel.com with ESMTP; 08 Mar 2017 02:42:46 -0800 Received: by rosetta.fi.intel.com (Postfix, from userid 1000) id 2845584194D; Wed, 8 Mar 2017 12:44:07 +0200 (EET) From: Mika Kuoppala To: intel-gfx@lists.freedesktop.org Date: Wed, 8 Mar 2017 12:44:06 +0200 Message-Id: <1488969846-13428-1-git-send-email-mika.kuoppala@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20170307161229.GB25286@nuc-i3427.alporthouse.com> References: <20170307161229.GB25286@nuc-i3427.alporthouse.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] tests: Add gem_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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Add gem_spin_batch to test that the dummyload infra is working properly. Can be also act as tool to force a single engine to be busy for controlled period of time. v2: plenty of igt-fu improvements (Chris) v3: nesting batches for more utilization, epsilon fun (Chris) Cc: Abdiel Janulgue Cc: Chris Wilson Signed-off-by: Mika Kuoppala Reviewed-by: Chris Wilson --- tests/Makefile.sources | 1 + tests/gem_spin_batch.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 tests/gem_spin_batch.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 6e07d93..1763b67 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -214,6 +214,7 @@ TESTS_progs = \ gem_unfence_active_buffers \ gem_unref_active_buffers \ gem_wait \ + gem_spin_batch \ gem_workarounds \ gen3_mixed_blits \ gen3_render_linear_blits \ diff --git a/tests/gem_spin_batch.c b/tests/gem_spin_batch.c new file mode 100644 index 0000000..a408fe1 --- /dev/null +++ b/tests/gem_spin_batch.c @@ -0,0 +1,85 @@ +/* + * Copyright © 2017 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#include "igt.h" + +#define MAX_ERROR 3 /* % */ + +#define assert_within_epsilon(x, ref, tolerance) \ + igt_assert_f(100 * x <= (100 + tolerance) * ref && \ + 100 * x >= (100 - tolerance) * ref, \ + "'%s' != '%s' (%ld not within %d%% tolerance of %ld)\n", \ + #x, #ref, (int64_t)x, tolerance, (int64_t)ref) + +static void basic(int fd, unsigned int engine, unsigned int timeout_sec) +{ + const uint64_t timeout_100ms = 100000000LL; + unsigned long loops = 0; + igt_spin_t *spin; + struct timespec tv = { }; + uint64_t elapsed; + + spin = igt_spin_batch_new(fd, engine, 0); + while ((elapsed = igt_nsec_elapsed(&tv)) >> 30 < timeout_sec) { + igt_spin_t *next = igt_spin_batch_new(fd, engine, 0); + + igt_spin_batch_set_timeout(spin, timeout_100ms); + gem_sync(fd, spin->handle); + loops++; + + igt_spin_batch_free(fd, spin); + spin = next; + } + igt_spin_batch_free(fd, spin); + + assert_within_epsilon(timeout_100ms * loops, elapsed, MAX_ERROR); + igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0); +} + +igt_main +{ + const struct intel_execution_engine *e; + int fd = -1; + + igt_skip_on_simulation(); + + igt_fixture { + fd = drm_open_driver(DRIVER_INTEL); + igt_require_gem(fd); + igt_fork_hang_detector(fd); + } + + for (e = intel_execution_engines; e->name; e++) { + if (e->exec_id == 0) + continue; + + igt_subtest_f("basic-%s", e->name) + basic(fd, e->exec_id, 3); + } + + igt_fixture { + igt_stop_hang_detector(); + close(fd); + } +}