summaryrefslogtreecommitdiff
path: root/lib/igt_gt.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-09-13 11:13:14 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2016-09-13 11:13:45 +0100
commit0a1fc45e862d4d5e4e9cba2b5c600588327f8f02 (patch)
tree628cd5cbab5c721b3e88cec567e91d925f985f2a /lib/igt_gt.c
parentc947bfe563fe16bcad8b7b53b98e32de5aa0d7a6 (diff)
igt/gem_busy: Prevent banning when running multiple hang tests
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/igt_gt.c')
-rw-r--r--lib/igt_gt.c102
1 files changed, 79 insertions, 23 deletions
diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index 22cda157..a94cad32 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -70,6 +70,19 @@ static bool has_gpu_reset(int fd)
return once;
}
+static void eat_error_state(void)
+{
+ int fd, ret;
+
+ fd = igt_debugfs_open("i915_error_state", O_WRONLY);
+ do {
+ ret = write(fd, "", 1);
+ if (ret < 0)
+ ret = -errno;
+ } while (ret == -EINTR || ret == -EAGAIN);
+ close(fd);
+}
+
/**
* igt_require_hang_ring:
* @fd: open i915 drm file descriptor
@@ -110,6 +123,62 @@ void igt_require_hang_ring(int fd, int ring)
igt_require(has_gpu_reset(fd));
}
+igt_hang_t igt_allow_hang(int fd, unsigned ctx, unsigned flags)
+{
+ struct local_i915_gem_context_param param;
+ unsigned ban;
+
+ if (!igt_check_boolean_env_var("IGT_HANG", true))
+ igt_skip("hang injection disabled by user");
+ gem_context_require_ban_period(fd);
+ if (!igt_check_boolean_env_var("IGT_HANG_WITHOUT_RESET", false))
+ igt_require(has_gpu_reset(fd));
+
+ param.context = ctx;
+ param.size = 0;
+
+ if ((flags & HANG_ALLOW_CAPTURE) == 0) {
+ param.param = LOCAL_CONTEXT_PARAM_NO_ERROR_CAPTURE;
+ param.value = 1;
+ /* Older kernels may not have NO_ERROR_CAPTURE, in which case
+ * we just eat the error state in post-hang (and hope we eat
+ * the right one).
+ */
+ __gem_context_set_param(fd, &param);
+ }
+
+ param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD;
+ param.value = 0;
+ gem_context_get_param(fd, &param);
+ ban = param.value;
+
+ if ((flags & HANG_ALLOW_BAN) == 0) {
+ param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD;
+ param.value = 0;
+ gem_context_set_param(fd, &param);
+ }
+
+ return (struct igt_hang){ 0, ctx, ban, flags };
+}
+
+void igt_disallow_hang(int fd, igt_hang_t arg)
+{
+ struct local_i915_gem_context_param param;
+
+ param.context = arg.ctx;
+ param.size = 0;
+ param.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD;
+ param.value = arg.ban;
+ gem_context_set_param(fd, &param);
+
+ if ((arg.flags & HANG_ALLOW_CAPTURE) == 0) {
+ param.param = LOCAL_CONTEXT_PARAM_NO_ERROR_CAPTURE;
+ param.value = 0;
+ if (__gem_context_set_param(fd, &param))
+ eat_error_state();
+ }
+}
+
/**
* igt_hang_ring_ctx:
* @fd: open i915 drm file descriptor
@@ -118,18 +187,18 @@ void igt_require_hang_ring(int fd, int ring)
* @flags: set of flags to control execution
*
* This helper function injects a hanging batch associated with @ctx into @ring.
- * It returns a #igt_hang_ring_t structure which must be passed to
+ * It returns a #igt_hang_t structure which must be passed to
* igt_post_hang_ring() for hang post-processing (after the gpu hang
* interaction has been tested.
*
* Returns:
* Structure with helper internal state for igt_post_hang_ring().
*/
-igt_hang_ring_t igt_hang_ctx(int fd,
- uint32_t ctx,
- int ring,
- unsigned flags,
- uint64_t *offset)
+igt_hang_t igt_hang_ctx(int fd,
+ uint32_t ctx,
+ int ring,
+ unsigned flags,
+ uint64_t *offset)
{
struct drm_i915_gem_relocation_entry reloc;
struct drm_i915_gem_execbuffer2 execbuf;
@@ -214,7 +283,7 @@ igt_hang_ring_t igt_hang_ctx(int fd,
if (offset)
*offset = exec.offset;
- return (struct igt_hang_ring){ exec.handle, ctx, ban, flags };
+ return (igt_hang_t){ exec.handle, ctx, ban, flags };
}
/**
@@ -223,30 +292,17 @@ igt_hang_ring_t igt_hang_ctx(int fd,
* @ring: execbuf ring flag
*
* This helper function injects a hanging batch into @ring. It returns a
- * #igt_hang_ring_t structure which must be passed to igt_post_hang_ring() for
+ * #igt_hang_t structure which must be passed to igt_post_hang_ring() for
* hang post-processing (after the gpu hang interaction has been tested.
*
* Returns:
* Structure with helper internal state for igt_post_hang_ring().
*/
-igt_hang_ring_t igt_hang_ring(int fd, int ring)
+igt_hang_t igt_hang_ring(int fd, int ring)
{
return igt_hang_ctx(fd, 0, ring, 0, NULL);
}
-static void eat_error_state(void)
-{
- int fd, ret;
-
- fd = igt_debugfs_open("i915_error_state", O_WRONLY);
- do {
- ret = write(fd, "", 1);
- if (ret < 0)
- ret = -errno;
- } while (ret == -EINTR || ret == -EAGAIN);
- close(fd);
-}
-
/**
* igt_post_hang_ring:
* @fd: open i915 drm file descriptor
@@ -255,7 +311,7 @@ static void eat_error_state(void)
* This function does the necessary post-processing after a gpu hang injected
* with igt_hang_ring().
*/
-void igt_post_hang_ring(int fd, struct igt_hang_ring arg)
+void igt_post_hang_ring(int fd, igt_hang_t arg)
{
struct local_i915_gem_context_param param;