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>
This commit is contained in:
Chris Wilson
2016-01-22 17:33:40 +00:00
parent e0ee36141e
commit 5b675f7b2f
5 changed files with 42 additions and 73 deletions
+32
View File
@@ -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;
}
+2
View File
@@ -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 */