From 1b07bb12d35be38c827c1141e17594adfb0b3722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Tue, 16 Jan 2024 05:58:41 -0800 Subject: [PATCH] intel/tools/error_decode: Add support to search for Xe KMD error dumps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Lionel Landwerlin Signed-off-by: José Roberto de Souza Part-of: --- src/intel/tools/aubinator_error_decode.c | 52 ++++++++++++++++++++---- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/src/intel/tools/aubinator_error_decode.c b/src/intel/tools/aubinator_error_decode.c index d66eafef74d..efbb240f7a1 100644 --- a/src/intel/tools/aubinator_error_decode.c +++ b/src/intel/tools/aubinator_error_decode.c @@ -843,9 +843,36 @@ try_open_file(const char *format, ...) } static FILE * -open_error_state_file(const char *path) +open_xe_error_state_file(const char *path) { - FILE *file; + FILE *file = NULL; + + if (path) { + struct stat st; + + if (stat(path, &st)) + return NULL; + + if (S_ISDIR(st.st_mode)) { + file = try_open_file("%s/data", path); + } else { + file = fopen(path, "r"); + } + } else { + for (int minor = 0; minor < 64; minor++) { + file = try_open_file("/sys/class/drm/card%i/device/devcoredump/data", minor); + if (file) + break; + } + } + + return file; +} + +static FILE * +open_i915_error_state_file(const char *path) +{ + FILE *file = NULL; struct stat st; if (stat(path, &st)) @@ -919,15 +946,16 @@ main(int argc, char *argv[]) if (optind >= argc) { if (isatty(0)) { - file = open_error_state_file("/sys/class/drm/card0/error"); + file = open_i915_error_state_file("/sys/class/drm/card0/error"); if (!file) - file = open_error_state_file("/debug/dri"); + file = open_i915_error_state_file("/debug/dri"); if (!file) - file = open_error_state_file("/sys/kernel/debug/dri"); - + file = open_i915_error_state_file("/sys/kernel/debug/dri"); + if (!file) + file = open_xe_error_state_file(NULL); if (file == NULL) { errx(1, - "Couldn't find i915 debugfs directory.\n\n" + "Couldn't find i915 or Xe error dump.\n\n" "Is debugfs mounted? You might try mounting it with a command such as:\n\n" "\tsudo mount -t debugfs debugfs /sys/kernel/debug\n"); } @@ -939,11 +967,17 @@ main(int argc, char *argv[]) if (strcmp(path, "-") == 0) { file = stdin; } else { - file = open_error_state_file(path); - if (file == NULL) { + FILE *i915, *xe; + + i915 = open_i915_error_state_file(path); + xe = open_xe_error_state_file(path); + + if (i915 == NULL && xe == NULL) { fprintf(stderr, "Error opening %s: %s\n", path, strerror(errno)); exit(EXIT_FAILURE); } + + file = i915 ? i915 : xe; } }