[PATCH v8 1/7] lib/intel_wa: Add check for workaround in GTs
Mohammed Thasleem
mohammed.thasleem at intel.com
Mon Jun 30 13:41:39 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)
v4: Add check for xe device before execution. (Vinod)
v5: Move igt_has_intel_wa to lib/intel_wa. (Kamil)
v6: Remove unused header and move xe check to intel_is_fbc_supported. (Kamil)
v7: Update the title and move header from .h to .c file. (Kamil)
v8: Close debugfs_fd before exit. (Kamil)
Signed-off-by: Mohammed Thasleem <mohammed.thasleem at intel.com>
---
lib/intel_wa.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
lib/intel_wa.h | 11 ++++++++++
lib/meson.build | 1 +
3 files changed, 66 insertions(+)
create mode 100644 lib/intel_wa.c
create mode 100644 lib/intel_wa.h
diff --git a/lib/intel_wa.c b/lib/intel_wa.c
new file mode 100644
index 000000000..8a3e3cc00
--- /dev/null
+++ b/lib/intel_wa.c
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#include <fcntl.h>
+#include <stdint.h>
+#include <stdio.h>
+
+#include "igt_debugfs.h"
+#include "igt_sysfs.h"
+#include "intel_wa.h"
+#include "xe/xe_query.h"
+
+/**
+ * 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 ret = 0;
+ int debugfs_fd;
+ unsigned int xe;
+ char name[256];
+ 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)) {
+ ret = -1;
+ break;
+ }
+
+ 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) {
+ ret = 1;
+ break;
+ }
+ }
+ }
+
+ close(debugfs_fd);
+ return ret;
+}
diff --git a/lib/intel_wa.h b/lib/intel_wa.h
new file mode 100644
index 000000000..765a5948e
--- /dev/null
+++ b/lib/intel_wa.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#ifndef __INTEL_WA_H__
+#define __INTEL_WA_H__
+
+int igt_has_intel_wa(int drm_fd, const char *check_wa);
+
+#endif /* __INTEL_WA_H__ */
diff --git a/lib/meson.build b/lib/meson.build
index 5e4247aad..ef397fe45 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -88,6 +88,7 @@ lib_sources = [
'intel_aux_pgtable.c',
'intel_reg_map.c',
'intel_iosf.c',
+ 'intel_wa.c',
'igt_kms.c',
'igt_fb.c',
'igt_core.c',
--
2.25.1
More information about the igt-dev
mailing list