diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-01-25 16:34:08 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-02-01 13:37:56 +0000 |
commit | 68a95f0e389096e7e4d87cd87dbb09edaca9909b (patch) | |
tree | e46bd05a21f6f8a2b443d45dbe8d3550923688d0 /tools/intel_error_decode.c | |
parent | 3c5c8ba71c4c32dcac1cf0493210d21fc9b33c8a (diff) |
error decode: Search for first i915_error_state
Handy for multi-GPU systems where the IGFX may not be first.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tools/intel_error_decode.c')
-rw-r--r-- | tools/intel_error_decode.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/tools/intel_error_decode.c b/tools/intel_error_decode.c index a11c918c..a27ade9b 100644 --- a/tools/intel_error_decode.c +++ b/tools/intel_error_decode.c @@ -344,10 +344,10 @@ main (int argc, char *argv[]) if (argc == 1) { if (isatty(0)) { - path = "/debug/dri/0"; + path = "/debug/dri"; err = stat (path, &st); if (err != 0) { - path = "/sys/kernel/debug/dri/0"; + path = "/sys/kernel/debug/dri"; err = stat (path, &st); if (err != 0) { errx(1, @@ -370,21 +370,37 @@ main (int argc, char *argv[]) } } - if (S_ISDIR (st.st_mode)) + if (S_ISDIR (st.st_mode)) { asprintf (&filename, "%s/i915_error_state", path); - else - filename = (char *) path; - - file = fopen(filename, "r"); - if (file) { - read_data_file (file); - fclose (file); + file = fopen(filename, "r"); + if (!file) { + int minor; + for (minor = 0; minor < 64; minor++) { + free(filename); + asprintf(&filename, "%s/%d/i915_error_state", path, minor); + file = fopen(filename, "r"); + if (file) + break; + } + } + if (!file) { + fprintf (stderr, "Failed to find i915_error_state beneath %s\n", + path); + exit (1); + } } else { - fprintf (stderr, "Failed to open %s: %s\n", - filename, strerror (errno)); - exit (1); + filename = (char *) path; + file = fopen(filename, "r"); + if (!file) { + fprintf (stderr, "Failed to open %s: %s\n", + filename, strerror (errno)); + exit (1); + } } + read_data_file (file); + fclose (file); + if (filename != path) free (filename); |