public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Christoph Manszewski <christoph.manszewski@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Piotr Rudnicki" <piotr.rudnicki@intel.com>,
	"Dominik Karol Piątkowski" <dominik.karol.piatkowski@intel.com>,
	"Jan Sokolowski" <jan.sokolowski@intel.com>
Subject: [PATCH i-g-t v5 5/5] lib/xe/xe_eudebug: Get drm card sysfs path
Date: Wed, 11 Mar 2026 12:06:42 +0100	[thread overview]
Message-ID: <20260311110636.798120-12-christoph.manszewski@intel.com> (raw)
In-Reply-To: <20260311110636.798120-7-christoph.manszewski@intel.com>

Add helper function to get the card name as defined in the:
'/sys/class/drm/card<N>' path.

Reviewed-by: Piotr Rudnicki <piotr.rudnicki@intel.com>
Link: https://lore.kernel.org/r/20260220153748.210381-12-christoph.manszewski@intel.com
Signed-off-by: Christoph Manszewski <christoph.manszewski@intel.com>
---
 lib/xe/xe_eudebug.c | 40 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)

diff --git a/lib/xe/xe_eudebug.c b/lib/xe/xe_eudebug.c
index c722a968a..3bffda561 100644
--- a/lib/xe/xe_eudebug.c
+++ b/lib/xe/xe_eudebug.c
@@ -1900,6 +1900,34 @@ static void metadata_event(struct xe_eudebug_client *c, uint32_t flags,
 }
 
 #define EU_DEBUG_TOGGLE "device/enable_eudebug"
+
+static char *get_card_name(int fd, char *card_name, size_t len)
+{
+	char sysfs_path[PATH_MAX];
+	char link_target[PATH_MAX];
+	char *card_start;
+	ssize_t link_len;
+
+	if (!igt_sysfs_path(fd, sysfs_path, sizeof(sysfs_path)))
+		return NULL;
+
+	link_len = readlink(sysfs_path, link_target, sizeof(link_target) - 1);
+	if (link_len < 0)
+		return NULL;
+
+	link_target[link_len] = '\0';
+
+	card_start = strstr(link_target, "card");
+	if (!card_start)
+		return NULL;
+
+	snprintf(card_name, len, "%s", card_start);
+	card_start = strchr(card_name, '/');
+	if (card_start)
+		*card_start = '\0';
+
+	return card_name;
+}
 /**
  * __xe_eudebug_enable_getset
  * @fd: xe client
@@ -1961,7 +1989,7 @@ out:
  */
 bool xe_eudebug_enable(int fd, bool enable)
 {
-	char sysfs_path[PATH_MAX];
+	char card_name[NAME_MAX];
 	bool old = false;
 	int ret = 0;
 
@@ -1983,9 +2011,13 @@ bool xe_eudebug_enable(int fd, bool enable)
 	}
 
 	if (ret == -ENOENT) {
-		igt_assert(igt_sysfs_path(fd, sysfs_path, sizeof(sysfs_path)));
-		igt_skip("'%s/" EU_DEBUG_TOGGLE
-			 "' sysfs attribute not found, EU DEBUG not supported\n", sysfs_path);
+		if (get_card_name(fd, card_name, sizeof(card_name)))
+			igt_skip("'/sys/class/drm/%s/" EU_DEBUG_TOGGLE
+				 "' sysfs attribute not found, EU DEBUG not supported\n",
+				 card_name);
+		else
+			igt_skip("'" EU_DEBUG_TOGGLE
+				 "' sysfs attribute not found, EU DEBUG not supported\n");
 	}
 
 	igt_abort_on_f(ret, "xe_eudebug_enable: Failed to %s eudebug\n",
-- 
2.47.1


  parent reply	other threads:[~2026-03-11 11:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-11 11:06 [PATCH i-g-t v5 0/5] Improve eudebug test cleanup Christoph Manszewski
2026-03-11 11:06 ` [PATCH i-g-t v5 1/5] tests/xe/xe_eudebug: Change pthread_join to pthread_timedjoin_np Christoph Manszewski
2026-03-11 11:06 ` [PATCH i-g-t v5 2/5] lib/xe/xe_eudebug: Modify toggle error handling Christoph Manszewski
2026-03-11 11:06 ` [PATCH i-g-t v5 3/5] xe/xe_eudebug: Add reattach function and make plain connect private Christoph Manszewski
2026-03-11 11:06 ` [PATCH i-g-t v5 4/5] lib/xe/xe_eudebug: Track active debugger sessions and close when disabling Christoph Manszewski
2026-03-11 11:06 ` Christoph Manszewski [this message]
2026-03-12  0:04 ` ✓ Xe.CI.BAT: success for Improve eudebug test cleanup (rev5) Patchwork
2026-03-12  0:07 ` ✓ i915.CI.BAT: " Patchwork
2026-03-12 19:08 ` ✓ i915.CI.Full: " Patchwork
2026-03-12 19:10 ` ✗ Xe.CI.FULL: failure " 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=20260311110636.798120-12-christoph.manszewski@intel.com \
    --to=christoph.manszewski@intel.com \
    --cc=dominik.karol.piatkowski@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jan.sokolowski@intel.com \
    --cc=piotr.rudnicki@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