From: sai.gowtham.ch@intel.com
To: igt-dev@lists.freedesktop.org, sai.gowtham.ch@intel.com
Subject: [PATCH 2/2] tools/intel_error_decode: Enable support for xe driver in the tool
Date: Fri, 31 Jan 2025 20:29:40 +0000 [thread overview]
Message-ID: <20250131202940.1124460-3-sai.gowtham.ch@intel.com> (raw)
In-Reply-To: <20250131202940.1124460-1-sai.gowtham.ch@intel.com>
From: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
Enables error decode support for xe dumps. which uses intel_error_decode_xe
lib.
Signed-off-by: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
---
tools/intel_error_decode.c | 156 +++++++++++++++++++++++++------------
1 file changed, 107 insertions(+), 49 deletions(-)
diff --git a/tools/intel_error_decode.c b/tools/intel_error_decode.c
index 451608826..a722621e2 100644
--- a/tools/intel_error_decode.c
+++ b/tools/intel_error_decode.c
@@ -57,7 +57,11 @@
#include "instdone.h"
#include "intel_reg.h"
#include "drmtest.h"
+#include "drm-uapi/xe_drm.h"
#include "i915/intel_decode.h"
+#include "xe/intel_error_decode_xe_lib.h"
+
+#define XE_KMD_ERROR_DUMP_IDENTIFIER "**** Xe Device Coredump ****"
static uint32_t
print_head(unsigned int reg)
@@ -793,14 +797,86 @@ static void setup_pager(void)
}
}
+static FILE *
+try_open_file(const char *format, ...)
+{
+ int ret;
+ char *filename;
+ FILE *file;
+ va_list args;
+
+ va_start(args, format);
+ ret = vasprintf(&filename, format, args);
+ va_end(args);
+
+ igt_assert(ret > 0);
+ file = fopen(filename, "r");
+ free(filename);
+
+ return file;
+}
+
+static FILE *
+open_i915_core_dump(const char *path)
+{
+ FILE *file = NULL;
+ struct stat st;
+
+ if (stat(path, &st))
+ return NULL;
+
+ if (S_ISDIR(st.st_mode)) {
+ file = try_open_file("%s/i915_error_state", path);
+ if (!file) {
+ int minor;
+ for (minor = 0; minor < 64; minor++) {
+ file = try_open_file("%s/%d/i915_error_state", path, minor);
+ if (file)
+ break;
+ }
+ }
+ } else {
+ file = fopen(path, "r");
+ }
+
+ return file;
+}
+
+static FILE *
+open_xe_core_dump(const char *path)
+{
+ 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;
+}
+
int
main(int argc, char *argv[])
{
FILE *file;
const char *path;
char *filename = NULL;
- struct stat st;
- int error;
+ char *line = NULL;
+ size_t line_size;
if (argc > 2) {
fprintf(stderr,
@@ -823,69 +899,51 @@ main(int argc, char *argv[])
if (argc == 1) {
if (isatty(0)) {
- path = "/sys/class/drm/card0/error";
- error = stat(path, &st);
- if (error != 0) {
- path = "/debug/dri";
- error = stat(path, &st);
+ file = open_i915_core_dump("/sys/class/drm/card0/error");
+ if (!file) {
+ file = open_i915_core_dump("/debug/dri");
}
- if (error != 0) {
- path = "/sys/kernel/debug/dri";
- error = stat(path, &st);
+ if (!file) {
+ file = open_i915_core_dump("/sys/kernel/debug/dri");
}
- if (error != 0) {
+ if (!file) {
+ file = open_xe_core_dump(NULL);
+ }
+ if (file == NULL) {
errx(1,
- "Couldn't find i915 debugfs directory.\n\n"
+ "Couldn't find i915 or xe debugfs directory.\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");
}
} else {
- read_data_file(stdin);
- exit(0);
+ file = stdin;
}
} else {
path = argv[1];
- error = stat(path, &st);
- if (error != 0) {
- fprintf(stderr, "Error opening %s: %s\n",
- path, strerror(errno));
- exit(1);
- }
- }
+ if (strcmp(path, "-") == 0) {
+ file = stdin;
+ } else {
+ FILE *i915, *xe;
- if (S_ISDIR(st.st_mode)) {
- int ret;
+ i915 = open_i915_core_dump(path);
+ xe = open_xe_core_dump(path);
- ret = asprintf(&filename, "%s/i915_error_state", path);
- assert(ret > 0);
- file = fopen(filename, "r");
- if (!file) {
- int minor;
- for (minor = 0; minor < 64; minor++) {
- free(filename);
- ret = asprintf(&filename, "%s/%d/i915_error_state", path, minor);
- assert(ret > 0);
-
- file = fopen(filename, "r");
- if (file)
- break;
+ if (i915 == NULL && xe == NULL) {
+ fprintf(stderr, "Error opening %s: %s\n", path, strerror(errno));
+ exit(1);
}
- }
- if (!file) {
- fprintf(stderr, "Failed to find i915_error_state beneath %s\n",
- path);
- exit (1);
- }
- } else {
- file = fopen(path, "r");
- if (!file) {
- fprintf(stderr, "Failed to open %s: %s\n",
- path, strerror(errno));
- exit (1);
+
+ file = i915 ? i915 : xe;
}
}
- read_data_file(file);
+ getline(&line, &line_size, file);
+ rewind(file);
+ if (strncmp(line, XE_KMD_ERROR_DUMP_IDENTIFIER, strlen(XE_KMD_ERROR_DUMP_IDENTIFIER)) == 0)
+ read_xe_data_file(file);
+ else
+ read_data_file(file);
+ free(line);
fclose(file);
if (filename != path)
--
2.34.1
next prev parent reply other threads:[~2025-01-31 20:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-31 20:29 [PATCH 0/2] Extend intel_error_decode tool to work with xe sai.gowtham.ch
2025-01-31 20:29 ` [PATCH 1/2] lib/xe/intel_error_decode_xe: error decode support for xe driver sai.gowtham.ch
2025-02-06 18:48 ` Rodrigo Vivi
2025-02-06 19:04 ` Souza, Jose
2025-02-11 5:35 ` Ch, Sai Gowtham
2025-02-11 13:21 ` Souza, Jose
2025-01-31 20:29 ` sai.gowtham.ch [this message]
2025-02-06 16:24 ` [PATCH 2/2] tools/intel_error_decode: Enable support for xe driver in the tool Rodrigo Vivi
2025-02-11 5:37 ` Ch, Sai Gowtham
2025-01-31 21:48 ` ✓ Xe.CI.BAT: success for Extend intel_error_decode tool to work with xe Patchwork
2025-01-31 21:49 ` ✓ i915.CI.BAT: " Patchwork
2025-02-01 5:27 ` ✗ Xe.CI.Full: failure " Patchwork
2025-02-01 12:15 ` ✗ i915.CI.Full: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250131202940.1124460-3-sai.gowtham.ch@intel.com \
--to=sai.gowtham.ch@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.