From: Sk Anirban <sk.anirban@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: anshuman.gupta@intel.com, badal.nilawar@intel.com,
riana.tauro@intel.com, karthik.poosa@intel.com,
raag.jadav@intel.com, soham.purkait@intel.com,
mallesh.koujalagi@intel.com, matthew.d.roper@intel.com,
Sk Anirban <sk.anirban@intel.com>
Subject: [PATCH] tests/intel/xe_configfs: reuse pre-existing configfs group
Date: Mon, 3 Aug 2026 15:19:55 +0530 [thread overview]
Message-ID: <20260803094954.3087948-2-sk.anirban@intel.com> (raw)
Handle a pre-existing configfs group by opening and reusing it, retain
it across cleanup, and validate the fd so the test fails early with a
clear message on any error.
Signed-off-by: Sk Anirban <sk.anirban@intel.com>
---
tests/intel/xe_configfs.c | 39 ++++++++++++++++++++++++++++++++++-----
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/tests/intel/xe_configfs.c b/tests/intel/xe_configfs.c
index 450c0a119..32e1f9e2d 100644
--- a/tests/intel/xe_configfs.c
+++ b/tests/intel/xe_configfs.c
@@ -26,6 +26,13 @@
static char bus_addr[NAME_MAX];
static struct pci_device *pci_dev;
+/*
+ * Set when the device's configfs group already existed before the test
+ * started. In that case we must not remove it during cleanup, so we leave
+ * the pre-existing configuration untouched.
+ */
+static bool configfs_group_preexisting;
+
static bool check_registers(const uint32_t reg[], const uint32_t val[],
size_t max)
{
@@ -60,7 +67,7 @@ static void restore(int sig)
/* Drop all custom configfs settings from subtests */
configfs_fd = igt_configfs_open("xe");
- if (configfs_fd >= 0)
+ if (configfs_fd >= 0 && !configfs_group_preexisting)
igt_fs_remove_dir(configfs_fd, bus_addr);
close(configfs_fd);
@@ -70,10 +77,19 @@ static void restore(int sig)
static void set_survivability_mode(int configfs_device_fd, bool value)
{
+ int ret;
+
igt_audio_driver_unload(NULL);
- igt_kmod_unbind("xe", bus_addr);
+
+ ret = igt_kmod_unbind("xe", bus_addr);
+ igt_assert_f(!ret, "Failed to unbind xe from %s: %s\n",
+ bus_addr, strerror(-ret));
+
igt_sysfs_set_boolean(configfs_device_fd, "survivability_mode", value);
- igt_kmod_bind("xe", bus_addr);
+
+ ret = igt_kmod_bind("xe", bus_addr);
+ igt_assert_f(!ret, "Failed to bind xe to %s: %s\n",
+ bus_addr, strerror(-ret));
}
/**
@@ -93,6 +109,9 @@ static void test_survivability_mode(int configfs_device_fd)
fd = open(path, O_RDONLY);
igt_assert_f(fd >= 0, "Survivability mode not set\n");
+
+ set_survivability_mode(configfs_device_fd, false);
+
close(fd);
}
@@ -363,7 +382,15 @@ static int create_device_configfs_group(int configfs_fd)
int configfs_device_fd;
configfs_device_fd = igt_fs_create_dir(configfs_fd, bus_addr, mode);
- igt_assert(configfs_device_fd);
+ if (configfs_device_fd == -EEXIST) {
+ configfs_group_preexisting = true;
+ configfs_device_fd = openat(configfs_fd, bus_addr, O_DIRECTORY);
+ if (configfs_device_fd < 0)
+ configfs_device_fd = -errno;
+ }
+ igt_assert_f(configfs_device_fd >= 0,
+ "Failed to create/open configfs group for %s: %s\n",
+ bus_addr, strerror(-configfs_device_fd));
return configfs_device_fd;
}
@@ -371,7 +398,9 @@ static int create_device_configfs_group(int configfs_fd)
static void close_configfs_group(int configfs_fd, int configfs_device_fd)
{
close(configfs_device_fd);
- igt_fs_remove_dir(configfs_fd, bus_addr);
+
+ if (!configfs_group_preexisting)
+ igt_fs_remove_dir(configfs_fd, bus_addr);
}
int igt_main()
--
2.43.0
reply other threads:[~2026-08-03 9:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260803094954.3087948-2-sk.anirban@intel.com \
--to=sk.anirban@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=badal.nilawar@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=karthik.poosa@intel.com \
--cc=mallesh.koujalagi@intel.com \
--cc=matthew.d.roper@intel.com \
--cc=raag.jadav@intel.com \
--cc=riana.tauro@intel.com \
--cc=soham.purkait@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