summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-01-18 22:38:40 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2014-01-18 22:38:40 +0000
commit498fcb001358af8f15bd129f8d1edf2530edf412 (patch)
treee1f65f8749452618c8520d7effbb781aafcdd628
parentb68c35a11da849a2680ba77bf565038fd8f30dd0 (diff)
sna: Refactor common routines for debugfs file dumping
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/kgem.c61
1 files changed, 28 insertions, 33 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 32c10236..0aee9586 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -2871,51 +2871,46 @@ out_16384:
}
#if !NDEBUG
-static void dump_gtt_info(void)
+static bool dump_file(const char *path)
{
- int i;
+ FILE *file;
+ size_t len = 0;
+ char *line = NULL;
- for (i = 0; i < DRM_MAX_MINOR; i++) {
- char path[80];
- FILE *file;
-
- sprintf(path, "/sys/kernel/debug/dri/%d/i915_gem_gtt", i);
- file = fopen(path, "r");
- if (file) {
- size_t len = 0;
- char *line = NULL;
-
- while (getline(&line, &len, file) != -1)
- ErrorF("%s", line);
- free(line);
- fclose(file);
- return;
- }
- }
+ file = fopen(path, "r");
+ if (file == NULL)
+ return false;
+
+ while (getline(&line, &len, file) != -1)
+ ErrorF("%s", line);
+
+ free(line);
+ fclose(file);
+ return true;
}
-static void dump_fence_regs(void)
+static void dump_debugfs(const char *name)
{
int i;
for (i = 0; i < DRM_MAX_MINOR; i++) {
char path[80];
- FILE *file;
-
- sprintf(path, "/sys/kernel/debug/dri/%d/i915_gem_fence_regs", i);
- file = fopen(path, "r");
- if (file) {
- size_t len = 0;
- char *line = NULL;
-
- while (getline(&line, &len, file) != -1)
- ErrorF("%s", line);
- free(line);
- fclose(file);
+
+ sprintf(path, "/sys/kernel/debug/dri/%d/%s", i, name);
+ if (dump_file(path))
return;
- }
}
}
+
+static void dump_gtt_info(void)
+{
+ dump_debugfs("i915_gem_gtt");
+}
+
+static void dump_fence_regs(void)
+{
+ dump_debugfs("i915_gem_fence_regs");
+}
#endif
void _kgem_submit(struct kgem *kgem)