summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-03-09 11:35:50 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2016-03-09 11:39:42 +0000
commitc684065be080d446018f5fc34de647d8e39d04e0 (patch)
tree712531781b9a6fb4a47eb976a727e3127bbc90ef
parent93824f0cd09f7f7fec6366504c46b3ede5223436 (diff)
igt/gem_exec_store: The simplest batch that does something!
A very simple, the simplest!, batch that can execution on any known engine that just writes a value into memory. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--tests/Makefile.sources1
-rw-r--r--tests/gem_exec_store.c105
2 files changed, 106 insertions, 0 deletions
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 7dc75d52..7432dbbf 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -38,6 +38,7 @@ TESTS_progs_M = \
gem_exec_nop \
gem_exec_params \
gem_exec_parse \
+ gem_exec_store \
gem_exec_suspend \
gem_exec_reloc \
gem_fenced_exec_thrash \
diff --git a/tests/gem_exec_store.c b/tests/gem_exec_store.c
new file mode 100644
index 00000000..b7eb34fd
--- /dev/null
+++ b/tests/gem_exec_store.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright © 2009 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.
+ *
+ */
+
+/** @file gem_exec_store.c
+ *
+ * Simplest non-NOOP only batch with verification.
+ */
+
+#include "igt.h"
+#include "igt_gt.h"
+
+static void store_dword(int fd, unsigned ring)
+{
+ const int gen = intel_gen(intel_get_drm_devid(fd));
+ struct drm_i915_gem_exec_object2 obj[2];
+ struct drm_i915_gem_relocation_entry reloc;
+ struct drm_i915_gem_execbuffer2 execbuf;
+ uint32_t batch[16];
+ int i;
+
+ gem_require_ring(fd, ring);
+ igt_skip_on_f(gen == 6 && (ring & ~(3<<13)) == I915_EXEC_BSD,
+ "MI_STORE_DATA broken on gen6 bsd\n");
+
+ memset(&execbuf, 0, sizeof(execbuf));
+ execbuf.buffers_ptr = (uintptr_t)obj;
+ execbuf.buffer_count = 2;
+ execbuf.flags = ring;
+ if (gen < 6)
+ execbuf.flags |= I915_EXEC_SECURE;
+
+ memset(obj, 0, sizeof(obj));
+ obj[0].handle = gem_create(fd, 4096);
+ obj[1].handle = gem_create(fd, 4096);
+
+ memset(&reloc, 0, sizeof(reloc));
+ reloc.target_handle = obj[0].handle;
+ reloc.presumed_offset = 0;
+ reloc.offset = sizeof(uint32_t);
+ reloc.delta = 0;
+ reloc.read_domains = I915_GEM_DOMAIN_INSTRUCTION;
+ reloc.write_domain = I915_GEM_DOMAIN_INSTRUCTION;
+ obj[1].relocs_ptr = (uintptr_t)&reloc;
+ obj[1].relocation_count = 1;
+
+ i = 0;
+ batch[i] = MI_STORE_DWORD_IMM | (gen < 6 ? 1 << 22 : 0);
+ if (gen >= 8) {
+ batch[++i] = 0;
+ batch[++i] = 0;
+ } else if (gen >= 4) {
+ batch[++i] = 0;
+ batch[++i] = 0;
+ reloc.offset += sizeof(uint32_t);
+ } else {
+ batch[i]--;
+ batch[++i] = 0;
+ }
+ batch[++i] = 0xc0ffee;
+ batch[++i] = MI_BATCH_BUFFER_END;
+ gem_write(fd, obj[1].handle, 0, batch, sizeof(batch));
+ gem_execbuf(fd, &execbuf);
+ gem_close(fd, obj[1].handle);
+
+ gem_read(fd, obj[0].handle, 0, batch, sizeof(batch));
+ gem_close(fd, obj[0].handle);
+ igt_assert_eq(*batch, 0xc0ffee);
+}
+
+igt_main
+{
+ const struct intel_execution_engine *e;
+ int fd;
+
+ igt_fixture
+ fd = drm_open_driver_master(DRIVER_INTEL);
+
+ for (e = intel_execution_engines; e->name; e++)
+ igt_subtest_f("basic-%s", e->name)
+ store_dword(fd, e->exec_id | e->flags);
+
+ igt_fixture
+ close(fd);
+}