summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-04-06 18:29:37 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-04-06 18:30:19 +0200
commit1677c2129113adfd7cda766548b09e0bfec10b3e (patch)
tree01f943f2b668a6a4b934106c995935a84fd909d1 /tests
parentc97a45ff098ba1e9772b5d1ebeedf52ec2b64652 (diff)
tests/kms_flip: don't leak gpu hang state
We need to clear out the error_state. While at it also make sure that the hang was indeed detected. Whoever writes the next test to race against gpu hangs should probably extract these two functions into the drmtest library. Which just one user that's not really worth it right now. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests')
-rw-r--r--tests/kms_flip.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 596d07ac..39f0043e 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -552,6 +552,62 @@ static int exec_nop(int fd, uint32_t handle)
return r;
}
+static void eat_error_state(struct test_output *o)
+{
+ static const char dfs_base[] = "/sys/kernel/debug/dri";
+ static const char dfs_entry_error[] = "i915_error_state";
+ static const char dfs_entry_stop[] = "i915_ring_stop";
+ static const char data[] = "";
+ static char tmp[128];
+ char fname[FILENAME_MAX];
+ int card_index = drm_get_card(0);
+ int fd;
+ ssize_t r;
+
+ assert(card_index != -1);
+
+ /* clear the error state */
+ snprintf(fname, FILENAME_MAX, "%s/%i/%s",
+ dfs_base, card_index, dfs_entry_error);
+
+ fd = open(fname, O_WRONLY);
+ if (fd < 0) {
+ fprintf(stderr, "failed to open '%s': %s\n",
+ fname, strerror(errno));
+ return;
+ }
+
+ r = write(fd, data, sizeof data);
+ if (r < 0)
+ fprintf(stderr, "failed to write '%s': %s\n",
+ fname, strerror(errno));
+ close(fd);
+
+ /* and check whether stop_rings is not reset, i.e. the hang has indeed
+ * happened */
+ snprintf(fname, FILENAME_MAX, "%s/%i/%s",
+ dfs_base, card_index, dfs_entry_stop);
+
+ fd = open(fname, O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "failed to open '%s': %s\n",
+ fname, strerror(errno));
+ return;
+ }
+
+ r = read(fd, tmp, sizeof tmp);
+ if (r < 0)
+ fprintf(stderr, "failed to read '%s': %s\n",
+ fname, strerror(errno));
+
+ if (atoi(tmp) != 0) {
+ fprintf(stderr, "no gpu hang detected, stop_rings is still %s\n", tmp);
+ exit(20);
+ }
+
+ close(fd);
+}
+
static void hang_gpu(struct test_output *o)
{
static const char dfs_base[] = "/sys/kernel/debug/dri";
@@ -728,6 +784,7 @@ static unsigned int run_test_step(struct test_output *o)
if (do_flip && (o->flags & TEST_HANG)) {
gem_sync(drm_fd, handle);
gem_close(drm_fd, handle);
+ eat_error_state(o);
}
return completed_events;