summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-01-22 17:33:40 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2016-01-22 17:45:06 +0000
commit5b675f7b2f6487548a91c01eb9a7e36e808617b4 (patch)
tree8812e54f7fc5467635b7e9aaf1ccc503d3c87014 /lib
parente0ee36141ed1747f68580559a7cbfbeba902f05c (diff)
lib: Refactor common detection of missed interrupts
As we have the same function in a few places to read the debugfs/i915_ring_missed_irq file, move it to the core. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_gt.c32
-rw-r--r--lib/igt_gt.h2
2 files changed, 34 insertions, 0 deletions
diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index 84d764a9..149435cd 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -501,3 +501,35 @@ void igt_clflush_range(void *addr, int size)
asm volatile("clflush %0" : "+m" (*(volatile char *)p));
asm volatile("mfence" ::: "memory");
}
+
+/**
+ * intel_detect_and_clear_missed_irq:
+ * @fd: open i915 drm file descriptor, used to quiesce the gpu
+ *
+ * This functions idles the GPU and then queries whether there has
+ * been a missed interrupt reported by the driver. Afterwards it
+ * clears the missed interrupt flag, in order to disable the timer
+ * fallback for the next test.
+ */
+unsigned intel_detect_and_clear_missed_interrupts(int fd)
+{
+ unsigned missed = 0;
+ FILE *file;
+
+ gem_quiescent_gpu(fd);
+
+ file = igt_debugfs_fopen("i915_ring_missed_irq", "r");
+ if (file) {
+ igt_assert(fscanf(file, "%x", &missed) == 1);
+ fclose(file);
+ }
+ if (missed) {
+ file = igt_debugfs_fopen("i915_ring_missed_irq", "w");
+ if (file) {
+ fwrite("0\n", 1, 2, file);
+ fclose(file);
+ }
+ }
+
+ return missed;
+}
diff --git a/lib/igt_gt.h b/lib/igt_gt.h
index 3d81ec95..4cf898a2 100644
--- a/lib/igt_gt.h
+++ b/lib/igt_gt.h
@@ -89,4 +89,6 @@ enum stop_ring_flags igt_get_stop_rings(void);
int igt_setup_clflush(void);
void igt_clflush_range(void *addr, int size);
+unsigned intel_detect_and_clear_missed_interrupts(int fd);
+
#endif /* IGT_GT_H */