From patchwork Thu Nov 28 08:34:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 11265577 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AD298139A for ; Thu, 28 Nov 2019 08:35:03 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6DD9D21771 for ; Thu, 28 Nov 2019 08:35:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6DD9D21771 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=chris-wilson.co.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E22C6E750; Thu, 28 Nov 2019 08:35:01 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 34BB96E750; Thu, 28 Nov 2019 08:34:59 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 19370925-1500050 for multiple; Thu, 28 Nov 2019 08:34:53 +0000 From: Chris Wilson To: igt-dev@lists.freedesktop.org Date: Thu, 28 Nov 2019 08:34:50 +0000 Message-Id: <20191128083451.3782143-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 1/2] Remove i915/gem_cpu_reloc 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: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The test does not do what is on the tin since the kernel smartly replaces the stalls with gpu relocations, and all the test is providing is a trivial amount of stress beyond gem_exec_reloc. Signed-off-by: Chris Wilson --- tests/Makefile.sources | 3 - tests/i915/gem_cpu_reloc.c | 309 ------------------------------------- tests/meson.build | 1 - 3 files changed, 313 deletions(-) delete mode 100644 tests/i915/gem_cpu_reloc.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index d86f9c263..bf1b96725 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -125,9 +125,6 @@ gem_close_race_SOURCES = i915/gem_close_race.c TESTS_progs += gem_concurrent_blit gem_concurrent_blit_SOURCES = i915/gem_concurrent_blit.c -TESTS_progs += gem_cpu_reloc -gem_cpu_reloc_SOURCES = i915/gem_cpu_reloc.c - TESTS_progs += gem_create gem_create_SOURCES = i915/gem_create.c diff --git a/tests/i915/gem_cpu_reloc.c b/tests/i915/gem_cpu_reloc.c deleted file mode 100644 index 470998628..000000000 --- a/tests/i915/gem_cpu_reloc.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright © 2012 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. - * - * Authors: - * Chris Wilson - * - */ - -/* - * Testcase: Test the relocations through the CPU domain - * - * Attempt to stress test performing relocations whilst the batch is in the - * CPU domain. - * - * A freshly allocated buffer starts in the CPU domain, and the pwrite - * should also be performed whilst in the CPU domain and so we should - * execute the relocations within the CPU domain. If for any reason one of - * those steps should land it in the GTT domain, we take the secondary - * precaution of filling the mappable portion of the GATT. - * - * In order to detect whether a relocation fails, we first fill a target - * buffer with a sequence of invalid commands that would cause the GPU to - * immediate hang, and then attempt to overwrite them with a legal, if - * short, batchbuffer using a BLT. Then we come to execute the bo, if the - * relocation fail and we either copy across all zeros or garbage, then the - * GPU will hang. - */ - -#include "igt.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "intel_bufmgr.h" - -#define MI_INSTR(opcode, flags) ((opcode) << 23 | (flags)) - -IGT_TEST_DESCRIPTION("Test the relocations through the CPU domain."); - -static uint32_t * -gen2_emit_store_addr(uint32_t *cs, struct drm_i915_gem_relocation_entry *addr) -{ - *cs++ = MI_STORE_DWORD_IMM - 1; - addr->offset += sizeof(*cs); - cs += 1; /* addr */ - cs += 1; /* value: implicit 0xffffffff */ - return cs; -} - -static uint32_t * -gen4_emit_store_addr(uint32_t *cs, struct drm_i915_gem_relocation_entry *addr) -{ - *cs++ = MI_STORE_DWORD_IMM; - *cs++ = 0; - addr->offset += 2 * sizeof(*cs); - cs += 1; /* addr */ - cs += 1; /* value: implicit 0xffffffff */ - return cs; -} - -static uint32_t * -gen8_emit_store_addr(uint32_t *cs, struct drm_i915_gem_relocation_entry *addr) -{ - *cs++ = (MI_STORE_DWORD_IMM | 1 << 21) + 1; - addr->offset += sizeof(*cs); - igt_assert((addr->delta & 7) == 0); - cs += 2; /* addr */ - cs += 2; /* value: implicit 0xffffffffffffffff */ - return cs; -} - -static uint32_t * -gen2_emit_bb_start(uint32_t *cs, struct drm_i915_gem_relocation_entry *addr) -{ - *cs++ = MI_BATCH_BUFFER_START | 2 << 6; - addr->offset += sizeof(*cs); - addr->delta += 1; - cs += 1; /* addr */ - return cs; -} - -static uint32_t * -gen4_emit_bb_start(uint32_t *cs, struct drm_i915_gem_relocation_entry *addr) -{ - *cs++ = MI_BATCH_BUFFER_START | 2 << 6 | 1 << 8; - addr->offset += sizeof(*cs); - cs += 1; /* addr */ - return cs; -} - -static uint32_t * -gen6_emit_bb_start(uint32_t *cs, struct drm_i915_gem_relocation_entry *addr) -{ - *cs++ = MI_BATCH_BUFFER_START | 1 << 8; - addr->offset += sizeof(*cs); - cs += 1; /* addr */ - return cs; -} - -static uint32_t * -hsw_emit_bb_start(uint32_t *cs, struct drm_i915_gem_relocation_entry *addr) -{ - *cs++ = MI_BATCH_BUFFER_START | 2 << 6 | 1 << 8 | 1 << 13; - addr->offset += sizeof(*cs); - cs += 1; /* addr */ - return cs; -} - -static uint32_t * -gen8_emit_bb_start(uint32_t *cs, struct drm_i915_gem_relocation_entry *addr) -{ - if (((uintptr_t)cs & 7) == 0) { - *cs++ = MI_NOOP; /* align addr for MI_STORE_DWORD_IMM */ - addr->offset += sizeof(*cs); - } - - *cs++ = MI_BATCH_BUFFER_START + 1; - addr->offset += sizeof(*cs); - cs += 2; /* addr */ - - return cs; -} - -static void * -create_tmpl(int i915, struct drm_i915_gem_relocation_entry *reloc) -{ - const uint32_t devid = intel_get_drm_devid(i915); - const int gen = intel_gen(devid); - uint32_t *(*emit_store_addr)(uint32_t *cs, - struct drm_i915_gem_relocation_entry *addr); - uint32_t *(*emit_bb_start)(uint32_t *cs, - struct drm_i915_gem_relocation_entry *reloc); - void *tmpl; - - if (gen >= 8) - emit_store_addr = gen8_emit_store_addr; - else if (gen >= 4) - emit_store_addr = gen4_emit_store_addr; - else - emit_store_addr = gen2_emit_store_addr; - - if (gen >= 8) - emit_bb_start = gen8_emit_bb_start; - else if (IS_HASWELL(devid)) - emit_bb_start = hsw_emit_bb_start; - else if (gen >= 6) - emit_bb_start = gen6_emit_bb_start; - else if (gen >= 4) - emit_bb_start = gen4_emit_bb_start; - else - emit_bb_start = gen2_emit_bb_start; - - tmpl = malloc(4096); - igt_assert(tmpl); - memset(tmpl, 0xff, 4096); - - /* Jump over the booby traps to the end */ - reloc[0].delta = 64; - emit_bb_start(tmpl, &reloc[0]); - - /* Restore the bad address to catch missing relocs */ - reloc[1].offset = 64; - reloc[1].delta = reloc[0].offset; - *emit_store_addr(tmpl + 64, &reloc[1]) = MI_BATCH_BUFFER_END; - - return tmpl; -} - -static void run_test(int i915, int count) -{ - struct drm_i915_gem_execbuffer2 execbuf; - struct drm_i915_gem_relocation_entry reloc[2]; - struct drm_i915_gem_exec_object2 obj; - - uint32_t *handles; - uint32_t *tmpl; - - handles = malloc(count * sizeof(uint32_t)); - igt_assert(handles); - - memset(reloc, 0, sizeof(reloc)); - tmpl = create_tmpl(i915, reloc); - for (int i = 0; i < count; i++) { - handles[i] = gem_create(i915, 4096); - gem_write(i915, handles[i], 0, tmpl, 4096); - } - free(tmpl); - - memset(&obj, 0, sizeof(obj)); - obj.relocs_ptr = to_user_pointer(reloc); - obj.relocation_count = ARRAY_SIZE(reloc); - - memset(&execbuf, 0, sizeof(execbuf)); - execbuf.buffers_ptr = to_user_pointer(&obj); - execbuf.buffer_count = 1; - - /* fill the entire gart with batches and run them */ - for (int i = 0; i < count; i++) { - obj.handle = handles[i]; - - reloc[0].target_handle = obj.handle; - reloc[0].presumed_offset = -1; - reloc[1].target_handle = obj.handle; - reloc[1].presumed_offset = -1; - - gem_execbuf(i915, &execbuf); - } - - /* And again in reverse to try and catch the relocation code out */ - for (int i = 0; i < count; i++) { - obj.handle = handles[count - i - 1]; - - reloc[0].target_handle = obj.handle; - reloc[0].presumed_offset = -1; - reloc[1].target_handle = obj.handle; - reloc[1].presumed_offset = -1; - - gem_execbuf(i915, &execbuf); - } - - /* Third time unlucky? */ - for (int i = 0; i < count; i++) { - obj.handle = handles[i]; - - reloc[0].target_handle = obj.handle; - reloc[0].presumed_offset = -1; - reloc[1].target_handle = obj.handle; - reloc[1].presumed_offset = -1; - - gem_set_domain(i915, obj.handle, - I915_GEM_DOMAIN_CPU, - I915_GEM_DOMAIN_CPU); - - gem_execbuf(i915, &execbuf); - } - - for (int i = 0; i < count; i++) - gem_close(i915, handles[i]); - free(handles); -} - -igt_main -{ - int i915; - - igt_fixture { - i915 = drm_open_driver(DRIVER_INTEL); - igt_require_gem(i915); - - /* could use BLT_FILL instead for gen2 */ - igt_require(gem_can_store_dword(i915, 0)); - - igt_fork_hang_detector(i915); - } - - igt_subtest("basic") - run_test(i915, 1); - - igt_subtest("full") { - uint64_t aper_size = gem_mappable_aperture_size(); - unsigned long count = aper_size / 4096 + 1; - - intel_require_memory(count, 4096, CHECK_RAM); - - run_test(i915, count); - } - - igt_subtest("forked") { - uint64_t aper_size = gem_mappable_aperture_size(); - unsigned long count = aper_size / 4096 + 1; - int ncpus = sysconf(_SC_NPROCESSORS_ONLN); - - intel_require_memory(count, 4096, CHECK_RAM); - - igt_fork(child, ncpus) - run_test(i915, count / ncpus + 1); - igt_waitchildren(); - } - - igt_fixture { - igt_stop_hang_detector(); - } -} diff --git a/tests/meson.build b/tests/meson.build index a909d271e..9dfcf207e 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -113,7 +113,6 @@ i915_progs = [ 'gem_close', 'gem_close_race', 'gem_concurrent_blit', - 'gem_cpu_reloc', 'gem_cs_prefetch', 'gem_cs_tlb', 'gem_ctx_bad_destroy', From patchwork Thu Nov 28 08:34:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 11265579 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 17DA6139A for ; Thu, 28 Nov 2019 08:35:05 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F348B2176D for ; Thu, 28 Nov 2019 08:35:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F348B2176D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=chris-wilson.co.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BFC0C6E783; Thu, 28 Nov 2019 08:35:01 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 04F4D6E750; Thu, 28 Nov 2019 08:34:59 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 19370926-1500050 for multiple; Thu, 28 Nov 2019 08:34:53 +0000 From: Chris Wilson To: igt-dev@lists.freedesktop.org Date: Thu, 28 Nov 2019 08:34:51 +0000 Message-Id: <20191128083451.3782143-2-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191128083451.3782143-1-chris@chris-wilson.co.uk> References: <20191128083451.3782143-1-chris@chris-wilson.co.uk> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 2/2] Remove i915/gem_exec_blt 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: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The tests/gem_exec_blt is a benchmarking tool, providing no verification as that is done by gem_linear_blits, gem_tiled_blits, gem_blits, gem_concurrent_blit et al. It's just a waste of time in CI, and when we do start including performance tests in our regression suite, we have benchmarks/gem_blt as our baseline. Signed-off-by: Chris Wilson --- tests/Makefile.sources | 3 - tests/i915/gem_exec_blt.c | 346 -------------------------------------- tests/meson.build | 1 - 3 files changed, 350 deletions(-) delete mode 100644 tests/i915/gem_exec_blt.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index bf1b96725..bdd912d2d 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -206,9 +206,6 @@ gem_exec_basic_SOURCES = i915/gem_exec_basic.c TESTS_progs += gem_exec_big gem_exec_big_SOURCES = i915/gem_exec_big.c -TESTS_progs += gem_exec_blt -gem_exec_blt_SOURCES = i915/gem_exec_blt.c - TESTS_progs += gem_exec_capture gem_exec_capture_SOURCES = i915/gem_exec_capture.c diff --git a/tests/i915/gem_exec_blt.c b/tests/i915/gem_exec_blt.c deleted file mode 100644 index ffb60d0cc..000000000 --- a/tests/i915/gem_exec_blt.c +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright © 2011 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. - * - * Authors: - * Chris Wilson - * - */ - -#include "igt.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "drm.h" -#include "igt_sysfs.h" - -#define OBJECT_SIZE 16384 - -#define COPY_BLT_CMD (2<<29|0x53<<22|0x6) -#define BLT_WRITE_ALPHA (1<<21) -#define BLT_WRITE_RGB (1<<20) -#define BLT_SRC_TILED (1<<15) -#define BLT_DST_TILED (1<<11) - -#define LOCAL_I915_EXEC_NO_RELOC (1<<11) -#define LOCAL_I915_EXEC_HANDLE_LUT (1<<12) - -static int gem_linear_blt(int fd, - uint32_t *batch, - uint32_t src, - uint32_t dst, - uint32_t length, - struct drm_i915_gem_relocation_entry *reloc) -{ - uint32_t *b = batch; - int height = length / (16 * 1024); - - igt_assert_lte(height, 1 << 16); - - if (height) { - int i = 0; - b[i++] = COPY_BLT_CMD | BLT_WRITE_ALPHA | BLT_WRITE_RGB; - if (intel_gen(intel_get_drm_devid(fd)) >= 8) - b[i-1]+=2; - b[i++] = 0xcc << 16 | 1 << 25 | 1 << 24 | (16*1024); - b[i++] = 0; - b[i++] = height << 16 | (4*1024); - b[i++] = 0; - reloc->offset = (b-batch+4) * sizeof(uint32_t); - reloc->delta = 0; - reloc->target_handle = dst; - reloc->read_domains = I915_GEM_DOMAIN_RENDER; - reloc->write_domain = I915_GEM_DOMAIN_RENDER; - reloc->presumed_offset = 0; - reloc++; - if (intel_gen(intel_get_drm_devid(fd)) >= 8) - b[i++] = 0; /* FIXME */ - - b[i++] = 0; - b[i++] = 16*1024; - b[i++] = 0; - reloc->offset = (b-batch+7) * sizeof(uint32_t); - if (intel_gen(intel_get_drm_devid(fd)) >= 8) - reloc->offset += sizeof(uint32_t); - reloc->delta = 0; - reloc->target_handle = src; - reloc->read_domains = I915_GEM_DOMAIN_RENDER; - reloc->write_domain = 0; - reloc->presumed_offset = 0; - reloc++; - if (intel_gen(intel_get_drm_devid(fd)) >= 8) - b[i++] = 0; /* FIXME */ - - b += i; - length -= height * 16*1024; - } - - if (length) { - int i = 0; - b[i++] = COPY_BLT_CMD | BLT_WRITE_ALPHA | BLT_WRITE_RGB; - if (intel_gen(intel_get_drm_devid(fd)) >= 8) - b[i-1]+=2; - b[i++] = 0xcc << 16 | 1 << 25 | 1 << 24 | (16*1024); - b[i++] = height << 16; - b[i++] = (1+height) << 16 | (length / 4); - b[i++] = 0; - reloc->offset = (b-batch+4) * sizeof(uint32_t); - reloc->delta = 0; - reloc->target_handle = dst; - reloc->read_domains = I915_GEM_DOMAIN_RENDER; - reloc->write_domain = I915_GEM_DOMAIN_RENDER; - reloc->presumed_offset = 0; - reloc++; - if (intel_gen(intel_get_drm_devid(fd)) >= 8) - b[i++] = 0; /* FIXME */ - - b[i++] = height << 16; - b[i++] = 16*1024; - b[i++] = 0; - reloc->offset = (b-batch+7) * sizeof(uint32_t); - if (intel_gen(intel_get_drm_devid(fd)) >= 8) - reloc->offset += sizeof(uint32_t); - reloc->delta = 0; - reloc->target_handle = src; - reloc->read_domains = I915_GEM_DOMAIN_RENDER; - reloc->write_domain = 0; - reloc->presumed_offset = 0; - reloc++; - if (intel_gen(intel_get_drm_devid(fd)) >= 8) - b[i++] = 0; /* FIXME */ - - b += i; - } - - b[0] = MI_BATCH_BUFFER_END; - b[1] = 0; - - return (b+2 - batch) * sizeof(uint32_t); -} - -static double elapsed(const struct timeval *start, - const struct timeval *end, - int loop) -{ - return (1e6*(end->tv_sec - start->tv_sec) + (end->tv_usec - start->tv_usec))/loop; -} - -static const char *bytes_per_sec(char *buf, double v) -{ - const char *order[] = { - "", - "KiB", - "MiB", - "GiB", - "TiB", - "PiB", - NULL, - }, **o = order; - - while (v > 1024 && o[1]) { - v /= 1024; - o++; - } - sprintf(buf, "%.1f%s/s", v, *o); - return buf; -} - -static int dcmp(const void *A, const void *B) -{ - const double *a = A, *b = B; - if (*a < *b) - return -1; - else if (*a > *b) - return 1; - else - return 0; -} - -static void run(int fd, int object_size, bool dumb) -{ - struct drm_i915_gem_execbuffer2 execbuf; - struct drm_i915_gem_exec_object2 exec[3]; - struct drm_i915_gem_relocation_entry reloc[4]; - uint32_t buf[20]; - uint32_t handle, src, dst; - int len, count; - int ring; - - if (dumb) - handle = kmstest_dumb_create(fd, 32, 32, 32, NULL, NULL); - else - handle = gem_create(fd, 4096); - - src = gem_create(fd, object_size); - dst = gem_create(fd, object_size); - - len = gem_linear_blt(fd, buf, 0, 1, object_size, reloc); - gem_write(fd, handle, 0, buf, len); - - memset(exec, 0, sizeof(exec)); - exec[0].handle = src; - exec[1].handle = dst; - - exec[2].handle = handle; - if (intel_gen(intel_get_drm_devid(fd)) >= 8) - exec[2].relocation_count = len > 56 ? 4 : 2; - else - exec[2].relocation_count = len > 40 ? 4 : 2; - exec[2].relocs_ptr = to_user_pointer(reloc); - - ring = 0; - if (HAS_BLT_RING(intel_get_drm_devid(fd))) - ring = I915_EXEC_BLT; - - memset(&execbuf, 0, sizeof(execbuf)); - execbuf.buffers_ptr = to_user_pointer(exec); - execbuf.buffer_count = 3; - execbuf.batch_len = len; - execbuf.flags = ring; - execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT; - execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC; - - if (__gem_execbuf(fd, &execbuf)) { - len = gem_linear_blt(fd, buf, src, dst, object_size, reloc); - igt_assert(len == execbuf.batch_len); - gem_write(fd, handle, 0, buf, len); - execbuf.flags = ring; - gem_execbuf(fd, &execbuf); - } - gem_sync(fd, handle); - - for (count = 1; count <= 1<<12; count <<= 1) { - struct timeval start, end; - const int reps = 9; - double t[reps], sum; - int n; - - for (n = 0; n < reps; n++) { - gettimeofday(&start, NULL); - for (int loop = 0; loop < count; loop++) - gem_execbuf(fd, &execbuf); - gem_sync(fd, handle); - gettimeofday(&end, NULL); - t[n] = elapsed(&start, &end, count); - } - qsort(t, n, sizeof(double), dcmp); - sum = 0; - for (n = 2; n < reps - 2; n++) - sum += t[n]; - sum /= reps - 4; - igt_info("Time to blt %d bytes x %6d: %7.3fµs, %s\n", - object_size, count, sum, - bytes_per_sec((char *)buf, object_size/sum*1e6)); - fflush(stdout); - } - gem_close(fd, handle); -} - -static void set_auto_freq(int sysfs) -{ - int min = igt_sysfs_get_u32(sysfs, "gt_RPn_freq_mhz"); - int max = igt_sysfs_get_u32(sysfs, "gt_RP0_freq_mhz"); - if (max <= min) - return; - - igt_debug("Setting min to %dMHz, and max to %dMHz\n", min, max); - igt_sysfs_set_u32(sysfs, "gt_min_freq_mhz", min); - igt_sysfs_set_u32(sysfs, "gt_max_freq_mhz", max); -} - -static void set_min_freq(int sysfs) -{ - int min = igt_sysfs_get_u32(sysfs, "gt_RPn_freq_mhz"); - igt_require(min > 0); - igt_debug("Setting min/max to %dMHz\n", min); - igt_require(igt_sysfs_set_u32(sysfs, "gt_min_freq_mhz", min) && - igt_sysfs_set_u32(sysfs, "gt_max_freq_mhz", min)); -} - -static void set_max_freq(int sysfs) -{ - int max = igt_sysfs_get_u32(sysfs, "gt_RP0_freq_mhz"); - igt_require(max > 0); - igt_debug("Setting min/max to %dMHz\n", max); - igt_require(igt_sysfs_set_u32(sysfs, "gt_max_freq_mhz", max) && - igt_sysfs_set_u32(sysfs, "gt_min_freq_mhz", max)); -} - - -igt_main -{ - const struct { - const char *suffix; - void (*func)(int); - } rps[] = { - { "", set_auto_freq }, - { "-min", set_min_freq }, - { "-max", set_max_freq }, - { NULL, NULL }, - }, *r; - int min = -1, max = -1; - int fd, sysfs; - - igt_skip_on_simulation(); - - igt_fixture { - fd = drm_open_driver(DRIVER_INTEL); - igt_require_gem(fd); - gem_require_blitter(fd); - - sysfs = igt_sysfs_open(fd); - igt_require(sysfs >= 0); - - min = igt_sysfs_get_u32(sysfs, "gt_min_freq_mhz"); - max = igt_sysfs_get_u32(sysfs, "gt_max_freq_mhz"); - } - - for (r = rps; r->suffix; r++) { - igt_fixture r->func(sysfs); - - igt_subtest_f("cold%s", r->suffix) - run(fd, OBJECT_SIZE, false); - - igt_subtest_f("normal%s", r->suffix) - run(fd, OBJECT_SIZE, false); - - igt_subtest_f("dumb-buf%s", r->suffix) - run(fd, OBJECT_SIZE, true); - } - - igt_fixture { - if (min > 0) - igt_sysfs_set_u32(sysfs, "gt_min_freq_mhz", min); - if (max > 0) - igt_sysfs_set_u32(sysfs, "gt_max_freq_mhz", max); - - close(sysfs); - close(fd); - } -} diff --git a/tests/meson.build b/tests/meson.build index 9dfcf207e..59c6961f1 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -135,7 +135,6 @@ i915_progs = [ 'gem_exec_bad_domains', 'gem_exec_basic', 'gem_exec_big', - 'gem_exec_blt', 'gem_exec_capture', 'gem_exec_create', 'gem_exec_faulting_reloc',