igt-dev.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Lucas De Marchi <lucas.demarchi@intel.com>,
	Riana Tauro <riana.tauro@intel.com>,
	Vinay Belgaumkar <vinay.belgaumkar@intel.com>
Subject: [PATCH i-g-t 1/4] tests/intel/xe_configfs: Do not execute with open fd
Date: Tue, 19 Aug 2025 13:40:40 -0700	[thread overview]
Message-ID: <20250819-configfs-unbind-v1-1-8359e66e3241@intel.com> (raw)
In-Reply-To: <20250819-configfs-unbind-v1-0-8359e66e3241@intel.com>

The survivability_mode test does an unbind/set-configfs/bind sequence.
If and fd is open, that will still refer to the old instance of the
driver and is a dangling fd. Close it right when it's not needed anymore
as in future other tests will also unbind/bind.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 tests/intel/xe_configfs.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/tests/intel/xe_configfs.c b/tests/intel/xe_configfs.c
index 5c65cd01d..f01b13e13 100644
--- a/tests/intel/xe_configfs.c
+++ b/tests/intel/xe_configfs.c
@@ -101,15 +101,19 @@ static void test_engines_allowed(int configfs_device_fd)
 	}
 }
 
-static int create_device_configfs_group(int configfs_fd, int fd)
+static void set_bus_addr(int fd)
 {
-	int configfs_device_fd;
 	struct pci_device *pci_dev;
-	mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
 
 	pci_dev = igt_device_get_pci_device(fd);
 	snprintf(bus_addr, sizeof(bus_addr), "%04x:%02x:%02x.%01x",
 		 pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func);
+}
+
+static int create_device_configfs_group(int configfs_fd)
+{
+	mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
+	int configfs_device_fd;
 
 	configfs_device_fd = igt_fs_create_dir(configfs_fd, bus_addr, mode);
 	igt_assert(configfs_device_fd);
@@ -120,17 +124,22 @@ static int create_device_configfs_group(int configfs_fd, int fd)
 igt_main
 {
 	int fd, configfs_fd, configfs_device_fd;
+	uint32_t devid;
 
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_XE);
+		devid = intel_get_drm_devid(fd);
+		set_bus_addr(fd);
+		close(fd);
+
 		configfs_fd = igt_configfs_open("xe");
 		igt_require(configfs_fd != -1);
-		configfs_device_fd = create_device_configfs_group(configfs_fd, fd);
+		configfs_device_fd = create_device_configfs_group(configfs_fd);
 	}
 
 	igt_describe("Validate survivability mode");
 	igt_subtest("survivability-mode") {
-		igt_require(IS_BATTLEMAGE(intel_get_drm_devid(fd)));
+		igt_require(IS_BATTLEMAGE(devid));
 		igt_install_exit_handler(restore);
 		test_survivability_mode(configfs_device_fd);
 	}
@@ -151,6 +160,5 @@ igt_main
 		igt_fs_remove_dir(configfs_fd, bus_addr);
 		close(configfs_device_fd);
 		close(configfs_fd);
-		close(fd);
 	}
 }

-- 
2.50.1


  reply	other threads:[~2025-08-19 20:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-19 20:40 [PATCH i-g-t 0/4] tests/intel/xe_configfs: Unbind before tests Lucas De Marchi
2025-08-19 20:40 ` Lucas De Marchi [this message]
2025-08-22 13:21   ` [PATCH i-g-t 1/4] tests/intel/xe_configfs: Do not execute with open fd Kamil Konieczny
2025-08-19 20:40 ` [PATCH i-g-t 2/4] tests/intel/xe_configfs: Unbind before testing engines_allowed Lucas De Marchi
2025-08-25 10:19   ` Riana Tauro
2025-08-19 20:40 ` [PATCH i-g-t 3/4] tests/intel/xe_configfs: Install exit handler once Lucas De Marchi
2025-08-22  6:01   ` Riana Tauro
2025-08-19 20:40 ` [PATCH i-g-t 4/4] tests/intel/xe_configfs: Reset all custom settings on exit Lucas De Marchi
2025-08-25 11:18   ` Riana Tauro
2025-08-19 21:46 ` ✗ i915.CI.BAT: failure for tests/intel/xe_configfs: Unbind before tests Patchwork
2025-08-19 21:51 ` ✓ Xe.CI.BAT: success " Patchwork
2025-08-20 16:51 ` ✗ 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=20250819-configfs-unbind-v1-1-8359e66e3241@intel.com \
    --to=lucas.demarchi@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=riana.tauro@intel.com \
    --cc=vinay.belgaumkar@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;
as well as URLs for NNTP newsgroup(s).