[PATCH v3 1/2] lib/igt_debugfs: Add specific checks for WA in GTs
Mohammed Thasleem
mohammed.thasleem at intel.com
Thu May 22 07:11:06 UTC 2025
This function check the given workaround on available GTs
v2: Add discription for return. (Kamil)
Rename function to igt_has_intel_wa. (Kamil)
Move lib changes to lib/igt_debugfs. (Kamil)
Dump the whole wa sysfs file and then search for the wa. (Vinod)
Use return true/false directly instead assigning value. (Vinod)
v3: Updated return type discription and debugfs_fd failure check. (Kamil)
Return 0 or 1 instead of true or false. (Kamil)
Signed-off-by: Mohammed Thasleem <mohammed.thasleem at intel.com>
---
lib/igt_debugfs.c | 36 ++++++++++++++++++++++++++++++++++++
lib/igt_debugfs.h | 1 +
2 files changed, 37 insertions(+)
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 8ac215a76..e4babc37f 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -44,6 +44,7 @@
#include "igt_kms.h"
#include "igt_debugfs.h"
#include "igt_sysfs.h"
+#include "xe/xe_query.h"
/**
* SECTION:igt_debugfs
@@ -770,3 +771,38 @@ void __igt_debugfs_dump(int device, const char *filename, int level)
igt_log(IGT_LOG_DOMAIN, level, "%s:\n%s\n", filename, contents);
free(contents);
}
+
+/**
+ * igt_has_intel_wa:
+ * @drm_fd: A drm file descriptor
+ * @check_wa: Workaround to be checked
+ *
+ * Returns: 0 if no WA, 1 if WA present, -1 on error
+ */
+int igt_has_intel_wa(int drm_fd, const char *check_wa)
+{
+ int debugfs_fd;
+ unsigned int xe;
+ char name[PATH_MAX];
+ char *debugfs_dump, *has_wa;
+
+ debugfs_fd = igt_debugfs_dir(drm_fd);
+ if (debugfs_fd == -1)
+ return -1;
+
+ xe_for_each_gt(drm_fd, xe) {
+ sprintf(name, "gt%d/workarounds", xe);
+ if (!igt_debugfs_exists(drm_fd, name, O_RDONLY))
+ return -1;
+
+ debugfs_dump = igt_sysfs_get(debugfs_fd, name);
+ if (debugfs_dump != NULL) {
+ has_wa = strstr(debugfs_dump, check_wa);
+ free(debugfs_dump);
+ if (has_wa)
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index f4044d545..6d4c09d2f 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -49,6 +49,7 @@ bool igt_debugfs_search(int fd, const char *filename, const char *substring);
int igt_debugfs_gt_dir(int device, unsigned int gt);
int igt_debugfs_gt_open(int device, unsigned int gt, const char *filename,
int mode);
+int igt_has_intel_wa(int drm_fd, const char *check_wa);
/**
* igt_debugfs_read:
--
2.34.1
More information about the igt-dev
mailing list