diff mbox

[2/3] tests/gem_reset_stats: stop rings after injecting hang

Message ID 1384959497-25533-2-git-send-email-mika.kuoppala@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mika Kuoppala Nov. 20, 2013, 2:58 p.m. UTC
To make driver report a simulated hang in dmesg.

Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
 tests/gem_reset_stats.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff mbox

Patch

diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c
index a7497f3..9e52b60 100644
--- a/tests/gem_reset_stats.c
+++ b/tests/gem_reset_stats.c
@@ -42,6 +42,7 @@ 
 #include "intel_batchbuffer.h"
 #include "intel_gpu_tools.h"
 #include "rendercopy.h"
+#include "igt_debugfs.h"
 
 #define RS_NO_ERROR      0
 #define RS_BATCH_ACTIVE  (1 << 0)
@@ -73,6 +74,8 @@  struct local_drm_i915_gem_context_destroy {
 #define CONTEXT_DESTROY_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2e, struct local_drm_i915_gem_context_destroy)
 #define GET_RESET_STATS_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x32, struct local_drm_i915_reset_stats)
 
+static igt_debugfs_t dfs;
+
 static uint32_t context_create(int fd)
 {
 	struct local_drm_i915_gem_context_create create;
@@ -192,6 +195,17 @@  static int exec_valid(int fd, int ctx)
 	return exec.handle;
 }
 
+static void stop_rings(void)
+{
+	int fd;
+
+	fd = igt_debugfs_open(&dfs, "i915_ring_stop", O_WRONLY);
+	igt_assert(fd >= 0);
+
+	igt_assert(write(fd, "0xff", 4) == 4);
+	close(fd);
+}
+
 #define BUFSIZE (4 * 1024)
 #define ITEMS   (BUFSIZE >> 2)
 
@@ -284,6 +298,8 @@  static int inject_hang(int fd, int ctx)
 
 	free(buf);
 
+	stop_rings();
+
 	return exec.handle;
 }
 
@@ -743,6 +759,8 @@  igt_main
 			igt_skip("Kernel is too old, or contexts not supported: %s\n",
 				 strerror(errno));
 
+		assert(igt_debugfs_init(&dfs) == 0);
+
 		close(fd);
 	}