[igt-dev] [CI i-g-t v2] tests/gem_ctx_sse: Explore..
Tvrtko Ursulin
tursulin at ursulin.net
Thu Aug 23 11:04:05 UTC 2018
From: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
v2: BAT..
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
tests/Makefile.sources | 1 +
tests/gem_ctx_sseu.c | 183 ++++++++++++++++++++++++++
tests/intel-ci/fast-feedback.testlist | 1 +
tests/meson.build | 1 +
4 files changed, 186 insertions(+)
create mode 100644 tests/gem_ctx_sseu.c
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index c84933f1d971..f8f2c8d67d72 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -56,6 +56,7 @@ TESTS_progs = \
gem_ctx_exec \
gem_ctx_isolation \
gem_ctx_param \
+ gem_ctx_sseu \
gem_ctx_switch \
gem_ctx_thrash \
gem_double_irq_loop \
diff --git a/tests/gem_ctx_sseu.c b/tests/gem_ctx_sseu.c
new file mode 100644
index 000000000000..fe2e6081df9b
--- /dev/null
+++ b/tests/gem_ctx_sseu.c
@@ -0,0 +1,183 @@
+/*
+ * 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.
+ *
+ * Authors:
+ * Lionel Landwerlin <lionel.g.landwerlin at intel.com>
+ *
+ */
+
+#include "igt.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/wait.h>
+
+#include "igt_perf.h"
+#include "igt_sysfs.h"
+#include "ioctl_wrappers.h"
+
+#define MI_STORE_REGISTER_MEM (0x24 << 23)
+
+#define MI_SET_PREDICATE (0x1 << 23)
+#define MI_SET_PREDICATE_NOOP_NEVER (0)
+#define MI_SET_PREDICATE_NOOP_RESULT2_CLEAR (1)
+#define MI_SET_PREDICATE_NOOP_RESULT2_SET (2)
+#define MI_SET_PREDICATE_NOOP_RESULT_CLEAR (3)
+#define MI_SET_PREDICATE_NOOP_RESULT_SET (4)
+#define MI_SET_PREDICATE_1_SLICES (5)
+#define MI_SET_PREDICATE_2_SLICES (6)
+#define MI_SET_PREDICATE_3_SLICES (7)
+
+#define GEN8_R_PWR_CLK_STATE 0x20C8
+#define GEN8_RPCS_ENABLE (1 << 31)
+#define GEN8_RPCS_S_CNT_ENABLE (1 << 18)
+#define GEN8_RPCS_S_CNT_SHIFT 15
+#define GEN8_RPCS_S_CNT_MASK (0x7 << GEN8_RPCS_S_CNT_SHIFT)
+#define GEN8_RPCS_SS_CNT_ENABLE (1 << 11)
+#define GEN8_RPCS_SS_CNT_SHIFT 8
+#define GEN8_RPCS_SS_CNT_MASK (0x7 << GEN8_RPCS_SS_CNT_SHIFT)
+#define GEN8_RPCS_EU_MAX_SHIFT 4
+#define GEN8_RPCS_EU_MAX_MASK (0xf << GEN8_RPCS_EU_MAX_SHIFT)
+#define GEN8_RPCS_EU_MIN_SHIFT 0
+#define GEN8_RPCS_EU_MIN_MASK (0xf << GEN8_RPCS_EU_MIN_SHIFT)
+
+static uint32_t *
+fill_relocation(uint32_t *batch,
+ struct drm_i915_gem_relocation_entry *reloc,
+ uint32_t gem_handle, uint32_t delta, /* in bytes */
+ uint32_t offset, /* in dwords */
+ uint32_t read_domains, uint32_t write_domains)
+{
+ reloc->target_handle = gem_handle;
+ reloc->delta = delta;
+ reloc->offset = offset * sizeof(uint32_t);
+ reloc->presumed_offset = 0;
+ reloc->read_domains = read_domains;
+ reloc->write_domain = write_domains;
+
+ *batch++ = delta;
+ *batch++ = 0;
+
+ return batch;
+}
+
+
+static uint32_t
+read_rpcs_reg(int fd, uint32_t context, uint32_t expected_slices)
+{
+ struct drm_i915_gem_execbuffer2 execbuf = { };
+ struct drm_i915_gem_relocation_entry relocs = { };
+ struct drm_i915_gem_exec_object2 obj[2];
+ uint32_t *batch, *b;
+ uint32_t rpcs;
+
+ memset(obj, 0, sizeof(obj));
+ obj[0].handle = gem_create(fd, 4096);
+ obj[1].handle = gem_create(fd, 4096);
+
+ batch = b = gem_mmap__cpu(fd, obj[1].handle, 0, 4096,
+ PROT_READ | PROT_WRITE);
+
+ *b++ = MI_SET_PREDICATE | (1 - 1) |
+ (MI_SET_PREDICATE_1_SLICES + expected_slices - 1);
+
+ *b++ = MI_STORE_REGISTER_MEM | (4 - 2);
+ *b++ = GEN8_R_PWR_CLK_STATE;
+ b = fill_relocation(b, &relocs, obj[0].handle, 0, b - batch,
+ I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
+
+ *b++ = MI_SET_PREDICATE | (1 - 1) | MI_SET_PREDICATE_NOOP_NEVER;
+
+ *b++ = MI_BATCH_BUFFER_END;
+
+ gem_munmap(batch, 4096);
+
+ obj[1].relocation_count = 1;
+ obj[1].relocs_ptr = to_user_pointer(&relocs);
+
+ execbuf.buffers_ptr = to_user_pointer(obj);
+ execbuf.buffer_count = ARRAY_SIZE(obj);
+ i915_execbuffer2_set_context_id(execbuf, context);
+
+ gem_execbuf(fd, &execbuf);
+
+ gem_read(fd, obj[0].handle, 0, &rpcs, sizeof(rpcs));
+
+ gem_close(fd, obj[0].handle);
+ gem_close(fd, obj[1].handle);
+
+ return rpcs;
+}
+
+static void test_slices(int fd)
+{
+ uint32_t ctx = gem_context_create(fd);
+ const unsigned int max = 3;
+ unsigned int cnt = 0;
+ unsigned int i;
+
+ for (i = 1; i <= max; i++) {
+ uint32_t reg = read_rpcs_reg(fd, ctx, i);
+ uint8_t s = (reg & GEN8_RPCS_S_CNT_MASK) >>
+ GEN8_RPCS_S_CNT_SHIFT;
+ uint8_t ss = (reg & GEN8_RPCS_SS_CNT_MASK) >>
+ GEN8_RPCS_SS_CNT_SHIFT;
+
+ igt_info("%u slices: rpcs=%x -> %u%sx%u%s\n",
+ i, reg,
+ s, reg & GEN8_RPCS_S_CNT_ENABLE ? "*" : "",
+ ss, reg & GEN8_RPCS_SS_CNT_ENABLE ? "*" : "");
+
+ if (reg)
+ cnt++;
+ }
+
+ gem_context_destroy(fd, ctx);
+}
+
+igt_main
+{
+ int fd;
+
+ igt_fixture {
+ int gen;
+
+ fd = drm_open_driver(DRIVER_INTEL);
+ igt_require_gem(fd);
+
+ gen = intel_gen(intel_get_drm_devid(fd));
+
+ igt_require(gen >= 8 && gen < 10);
+ }
+
+ igt_subtest("slices")
+ test_slices(fd);
+
+ igt_fixture {
+ close(fd);
+ }
+}
diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-ci/fast-feedback.testlist
index c625904d546f..d4a5ca444607 100644
--- a/tests/intel-ci/fast-feedback.testlist
+++ b/tests/intel-ci/fast-feedback.testlist
@@ -18,6 +18,7 @@ igt at gem_ctx_create@basic-files
igt at gem_ctx_exec@basic
igt at gem_ctx_param@basic
igt at gem_ctx_param@basic-default
+igt at gem_ctx_sseu@slices
igt at gem_ctx_switch@basic-default
igt at gem_ctx_switch@basic-default-heavy
igt at gem_exec_basic@basic-blt
diff --git a/tests/meson.build b/tests/meson.build
index 17deb945ec95..9187f4438280 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -33,6 +33,7 @@ test_progs = [
'gem_ctx_exec',
'gem_ctx_isolation',
'gem_ctx_param',
+ 'gem_ctx_sseu',
'gem_ctx_switch',
'gem_ctx_thrash',
'gem_double_irq_loop',
--
2.17.1
More information about the igt-dev
mailing list