[PATCH i-g-t 1/4] tests/intel/xe_configfs: Do not execute with open fd

Kamil Konieczny kamil.konieczny at linux.intel.com
Fri Aug 22 13:21:28 UTC 2025


Hi Lucas,
On 2025-08-19 at 13:40:40 -0700, Lucas De Marchi wrote:
> 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 at 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);

Please use drm_close_driver().

Regards,
Kamil

> +
>  		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
> 


More information about the igt-dev mailing list