summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-09-04 09:26:24 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2015-01-07 17:35:14 +0000
commit16bafdf5bf0248c02ea9824aca003b2a23d464be (patch)
tree458e41ee3d09e66115755c3300081e9c0c5c2ee9 /lib
parent25cf0551c7d210c8c085c109891dc97a2cc61e27 (diff)
igt/gem_concurrent_blit: Inject hangs before verifying contents
After setting up the copy operations, add a hanging batch. This should mean that we complete the copy and the compare then races against the GEM reset. Hopefully, this will catch driver bugs where the target object is no longer accessible after the hang. Note: hang injection is disabled until the required kernel interface is completed. But there are useful additional tests here... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.sources2
-rw-r--r--lib/igt_gt.c109
-rw-r--r--lib/igt_gt.h35
-rw-r--r--lib/ioctl_wrappers.c33
-rw-r--r--lib/ioctl_wrappers.h12
5 files changed, 191 insertions, 0 deletions
diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 34a3d31c..76f353aa 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -10,6 +10,8 @@ libintel_tools_la_SOURCES = \
igt_debugfs.h \
igt_aux.c \
igt_aux.h \
+ igt_gt.c \
+ igt_gt.h \
instdone.c \
instdone.h \
intel_batchbuffer.c \
diff --git a/lib/igt_gt.c b/lib/igt_gt.c
new file mode 100644
index 00000000..526cbee0
--- /dev/null
+++ b/lib/igt_gt.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright © 2014 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 <string.h>
+#include <errno.h>
+
+#include "igt_core.h"
+#include "igt_gt.h"
+#include "igt_debugfs.h"
+#include "ioctl_wrappers.h"
+#include "intel_reg.h"
+
+int igt_can_hang_ring(int fd, int gen, int ring)
+{
+ if (!gem_context_has_param(fd, LOCAL_CONTEXT_PARAM_BAN_PERIOD))
+ return 0;
+
+ if (gen < 5) /* safe resets */
+ return 0;
+
+ return 1;
+}
+
+struct igt_hang_ring igt_hang_ring(int fd, int gen, int ring)
+{
+ struct drm_i915_gem_relocation_entry reloc;
+ struct drm_i915_gem_execbuffer2 execbuf;
+ struct drm_i915_gem_exec_object2 exec;
+ struct local_i915_gem_context_param param;
+ uint32_t b[8];
+ unsigned ban;
+ unsigned len;
+
+ param.context = 0;
+ param.size = 0;
+ param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD;
+ param.value = 0;
+ gem_context_get_param(fd, &param);
+ ban = param.value;
+
+ param.value = 0;
+ igt_require(gem_context_set_param(fd, &param) == 0);
+
+ memset(&reloc, 0, sizeof(reloc));
+ memset(&exec, 0, sizeof(exec));
+ memset(&execbuf, 0, sizeof(execbuf));
+
+ exec.handle = gem_create(fd, 4096);
+ exec.relocation_count = 1;
+ exec.relocs_ptr = (uintptr_t)&reloc;
+
+ len = 2;
+ if (gen >= 8)
+ len++;
+ b[0] = MI_BATCH_BUFFER_START | (len - 2);
+ b[len] = MI_BATCH_BUFFER_END;
+ b[len+1] = MI_NOOP;
+ gem_write(fd, exec.handle, 0, b, sizeof(b));
+
+ reloc.offset = 4;
+ reloc.target_handle = exec.handle;
+ reloc.read_domains = I915_GEM_DOMAIN_COMMAND;
+
+ execbuf.buffers_ptr = (uintptr_t)&exec;
+ execbuf.buffer_count = 1;
+ execbuf.batch_len = sizeof(b);
+ execbuf.flags = ring;
+ gem_execbuf(fd, &execbuf);
+
+ return (struct igt_hang_ring){ exec.handle, ban };
+}
+
+void igt_post_hang_ring(int fd, struct igt_hang_ring arg)
+{
+ struct local_i915_gem_context_param param;
+
+ if (arg.handle == 0)
+ return;
+
+ gem_set_domain(fd, arg.handle,
+ I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
+ gem_close(fd, arg.handle);
+
+ param.context = 0;
+ param.size = 0;
+ param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD;
+ param.value = arg.ban;
+ gem_context_set_param(fd, &param);
+}
diff --git a/lib/igt_gt.h b/lib/igt_gt.h
new file mode 100644
index 00000000..19bbcef2
--- /dev/null
+++ b/lib/igt_gt.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright © 2014 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.
+ */
+
+#ifndef IGT_GT_H
+#define IGT_GT_H
+
+int igt_can_hang_ring(int fd, int gen, int ring);
+
+struct igt_hang_ring {
+ unsigned handle;
+ unsigned ban;
+} igt_hang_ring(int fd, int gen, int ring);
+void igt_post_hang_ring(int fd, struct igt_hang_ring data);
+
+#endif /* IGT_GT_H */
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index dd48d0e6..5bca4559 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1042,3 +1042,36 @@ off_t prime_get_size(int dma_buf_fd)
return ret;
}
+int gem_context_get_param(int fd, struct local_i915_gem_context_param *p)
+{
+#define LOCAL_I915_GEM_CONTEXT_GETPARAM 0x34
+#define LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_GETPARAM, struct local_i915_gem_context_param)
+ if (drmIoctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, p))
+ return -1;
+
+ errno = 0;
+ return 0;
+}
+
+int gem_context_set_param(int fd, struct local_i915_gem_context_param *p)
+{
+#define LOCAL_I915_GEM_CONTEXT_SETPARAM 0x35
+#define LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_SETPARAM, struct local_i915_gem_context_param)
+ if (drmIoctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, p))
+ return -1;
+
+ errno = 0;
+ return 0;
+}
+
+int gem_context_has_param(int fd, uint64_t param)
+{
+ struct local_i915_gem_context_param p;
+
+ p.context = 0;
+ p.param = param;
+ p.value = 0;
+ p.size = 0;
+
+ return gem_context_get_param(fd, &p) == 0;
+}
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 9e7edad5..2aa41987 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -104,4 +104,16 @@ int prime_handle_to_fd(int fd, uint32_t handle);
uint32_t prime_fd_to_handle(int fd, int dma_buf_fd);
off_t prime_get_size(int dma_buf_fd);
+struct local_i915_gem_context_param {
+ uint32_t context;
+ uint32_t size;
+ uint64_t param;
+#define LOCAL_CONTEXT_PARAM_BAN_PERIOD 0x1
+ uint64_t value;
+};
+
+int gem_context_has_param(int fd, uint64_t param);
+int gem_context_get_param(int fd, struct local_i915_gem_context_param *p);
+int gem_context_set_param(int fd, struct local_i915_gem_context_param *p);
+
#endif /* IOCTL_WRAPPERS_H */