Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mohammed Thasleem <mohammed.thasleem@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: vinod.govindapillai@intel.com,
	Mohammed Thasleem <mohammed.thasleem@intel.com>,
	Kamil Konieczny <kamil.konieczny@linux.intel.com>
Subject: [PATCH v4 1/2] lib/igt_debugfs: Add specific checks for WA in GTs
Date: Fri, 30 May 2025 13:28:10 +0530	[thread overview]
Message-ID: <20250530075811.1033-2-mohammed.thasleem@intel.com> (raw)
In-Reply-To: <20250530075811.1033-1-mohammed.thasleem@intel.com>

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)

Signed-off-by: Mohammed Thasleem <mohammed.thasleem@intel.com>
Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
 lib/igt_debugfs.c | 39 +++++++++++++++++++++++++++++++++++++++
 lib/igt_debugfs.h |  1 +
 2 files changed, 40 insertions(+)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 8ac215a76..5444c6f5f 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,41 @@ 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;
+
+	if (!is_xe_device(drm_fd))
+		return 0;
+
+	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


  reply	other threads:[~2025-05-30  7:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-30  7:58 [PATCH v4 0/2] Refine FBC test conditions Mohammed Thasleem
2025-05-30  7:58 ` Mohammed Thasleem [this message]
2025-05-30 10:00   ` [PATCH v4 1/2] lib/igt_debugfs: Add specific checks for WA in GTs Govindapillai, Vinod
2025-05-30  7:58 ` [PATCH v3 2/2] tests/intel/kms_frontbuffer_tracking: Enable the tests support variations based on the WAs Mohammed Thasleem
2025-05-30 10:15   ` Govindapillai, Vinod
2025-06-01 12:43   ` [PATCH v4 " Mohammed Thasleem
2025-06-09 10:52     ` [v4,2/2] " Joshi, Kunal1
2025-05-30  8:40 ` ✓ Xe.CI.BAT: success for Refine FBC test conditions (rev3) Patchwork
2025-05-30  8:50 ` ✓ i915.CI.BAT: " Patchwork
2025-05-30 10:37 ` ✓ i915.CI.Full: " Patchwork
2025-05-31 10:06 ` ✗ Xe.CI.Full: failure " Patchwork
2025-06-01 13:16 ` ✓ Xe.CI.BAT: success for Refine FBC test conditions (rev4) Patchwork
2025-06-01 13:27 ` ✗ i915.CI.BAT: failure " Patchwork
2025-06-01 22:30 ` ✗ Xe.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=20250530075811.1033-2-mohammed.thasleem@intel.com \
    --to=mohammed.thasleem@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=vinod.govindapillai@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox