Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Anirban, Sk" <sk.anirban@intel.com>
To: Soham Purkait <soham.purkait@intel.com>,
	<igt-dev@lists.freedesktop.org>,  <riana.tauro@intel.com>,
	<badal.nilawar@intel.com>, <kamil.konieczny@intel.com>
Cc: <anshuman.gupta@intel.com>
Subject: Re: [PATCH i-g-t] tests/intel/xe_configfs: Avoid leaking configfs device groups
Date: Tue, 17 Nov 2026 23:23:42 +0530	[thread overview]
Message-ID: <91e1e755-c450-4fec-abeb-23c81070c7cc@intel.com> (raw)
In-Reply-To: <20261112061324.906135-2-soham.purkait@intel.com>

Hi Soham,

On 12-11-2026 11:43, Soham Purkait wrote:
> Reuse pre-existing groups without removing them, and clean up
> test-created groups and fds in the configfs and survivability tests.
Check the patch subject as you are modifying xe_survivability.c as well 
not only xe_configfs.
>
> Signed-off-by: Soham Purkait <soham.purkait@intel.com>
> ---
>   lib/igt_configfs.c             |  3 ++
>   tests/intel/xe_configfs.c      | 86 ++++++++++++++++++----------------
>   tests/intel/xe_survivability.c | 37 ++++++++++-----
>   3 files changed, 74 insertions(+), 52 deletions(-)
>
> diff --git a/lib/igt_configfs.c b/lib/igt_configfs.c
> index 7bbeca746..ef0ba3ba5 100644
> --- a/lib/igt_configfs.c
> +++ b/lib/igt_configfs.c
> @@ -106,6 +106,9 @@ int igt_configfs_create_device_group(int configfs_fd, const char *name,
>   	mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
>   	int device_fd;
>   
> +	if (preexisting)
> +		*preexisting = false;
> +
change the function description accordingly.
>   	device_fd = igt_fs_create_dir(configfs_fd, name, mode);
>   	if (device_fd == -EEXIST) {
>   		if (preexisting)
> diff --git a/tests/intel/xe_configfs.c b/tests/intel/xe_configfs.c
> index 68daed690..534eb239d 100644
> --- a/tests/intel/xe_configfs.c
> +++ b/tests/intel/xe_configfs.c
> @@ -25,7 +25,8 @@
>   
>   static char bus_addr[NAME_MAX];
>   static struct pci_device *pci_dev;
> -
> +static int configfs_fd = -1;
> +static int configfs_group_fd = -1;
>   static bool configfs_group_preexisting;
>   
>   static bool check_registers(const uint32_t reg[], const uint32_t val[],
> @@ -53,18 +54,37 @@ out:
>   	return ret;
>   }
>   
> +static void close_configfs_group(void)
> +{
> +	if (configfs_group_fd < 0)
> +		return;
> +
> +	igt_configfs_close_device_group(configfs_fd, bus_addr, configfs_group_fd,
> +					configfs_group_preexisting);
> +	configfs_group_fd = -1;
> +	configfs_group_preexisting = false;
> +}
> +
> +static int create_configfs_group(void)
> +{
> +	close_configfs_group();
> +	configfs_group_fd = igt_configfs_create_device_group(configfs_fd, bus_addr,
> +							     &configfs_group_preexisting);
> +
> +	return configfs_group_fd;
> +}
> +
>   static void restore(int sig)
>   {
> -	int configfs_fd;

fix the blank line here.

Thanks,
Anirban

>   
>   	igt_audio_driver_unload(NULL);
>   	igt_kmod_unbind("xe", bus_addr);
>   
> -	/* Drop all custom configfs settings from subtests */
> -	configfs_fd = igt_configfs_open("xe");
> -	if (configfs_fd >= 0 && !configfs_group_preexisting)
> -		igt_fs_remove_dir(configfs_fd, bus_addr);
> -	close(configfs_fd);
> +	close_configfs_group();
> +	if (configfs_fd >= 0) {
> +		close(configfs_fd);
> +		configfs_fd = -1;
> +	}
>   
>   	/* Bind again a clean driver with no custom settings */
>   	igt_kmod_bind("xe", bus_addr);
> @@ -373,7 +393,7 @@ static void set_bus_addr(int fd)
>   
>   int igt_main()
>   {
> -	int fd, configfs_fd, configfs_device_fd;
> +	int fd, configfs_device_fd;
>   	bool is_vf_device;
>   	bool has_survivability;
>   	const char *engine = NULL;
> @@ -409,81 +429,67 @@ int igt_main()
>   	igt_subtest("survivability-mode") {
>   		igt_require(has_survivability);
>   		igt_require_f(!is_vf_device, "survivability mode not supported in VF\n");
> -		configfs_device_fd = igt_configfs_create_device_group(configfs_fd, bus_addr,
> -								      &configfs_group_preexisting);
> +		configfs_device_fd = create_configfs_group();
>   		test_survivability_mode(configfs_device_fd);
> -		igt_configfs_close_device_group(configfs_fd, bus_addr, configfs_device_fd,
> -						configfs_group_preexisting);
> +		close_configfs_group();
>   	}
>   
>   	igt_describe("Validate engines_allowed with invalid options");
>   	igt_subtest("engines-allowed-invalid") {
> -		configfs_device_fd = igt_configfs_create_device_group(configfs_fd, bus_addr,
> -								      &configfs_group_preexisting);
> +		configfs_device_fd = create_configfs_group();
>   		test_engines_allowed_invalid(configfs_device_fd);
> -		igt_configfs_close_device_group(configfs_fd, bus_addr, configfs_device_fd,
> -						configfs_group_preexisting);
> +		close_configfs_group();
>   	}
>   
>   	igt_describe("Validate engines_allowed");
>   	igt_subtest("engines-allowed") {
> -		configfs_device_fd = igt_configfs_create_device_group(configfs_fd, bus_addr,
> -								      &configfs_group_preexisting);
> +		configfs_device_fd = create_configfs_group();
>   		test_engines_allowed(configfs_device_fd);
> -		igt_configfs_close_device_group(configfs_fd, bus_addr, configfs_device_fd,
> -						configfs_group_preexisting);
> +		close_configfs_group();
>   	}
>   
>   	igt_describe("Validate gt_types_allowed");
>   	igt_subtest("gt-types-allowed") {
> -		configfs_device_fd = igt_configfs_create_device_group(configfs_fd, bus_addr,
> -								      &configfs_group_preexisting);
> +		configfs_device_fd = create_configfs_group();
>   		test_gt_types_allowed(configfs_device_fd);
> -		igt_configfs_close_device_group(configfs_fd, bus_addr, configfs_device_fd,
> -						configfs_group_preexisting);
> +		close_configfs_group();
>   	}
>   
>   	igt_describe("Validate ctx_restore_post_bb with invalid options");
>   	igt_subtest("ctx-restore-post-bb-invalid") {
>   		igt_skip_on_f(is_vf_device, "MMIO register readback not possible on VF\n");
> -		configfs_device_fd = igt_configfs_create_device_group(configfs_fd, bus_addr,
> -								      &configfs_group_preexisting);
> +		configfs_device_fd = create_configfs_group();
>   		test_ctx_restore_invalid(configfs_device_fd, "post");
> -		igt_configfs_close_device_group(configfs_fd, bus_addr, configfs_device_fd,
> -						configfs_group_preexisting);
> +		close_configfs_group();
>   	}
>   
>   	igt_describe("Validate ctx_restore_post_bb");
>   	igt_subtest("ctx-restore-post-bb") {
>   		igt_skip_on_f(is_vf_device, "MMIO register readback not possible on VF\n");
> -		configfs_device_fd = igt_configfs_create_device_group(configfs_fd, bus_addr,
> -								      &configfs_group_preexisting);
> +		configfs_device_fd = create_configfs_group();
>   		test_ctx_restore(configfs_device_fd, "post", engine);
> -		igt_configfs_close_device_group(configfs_fd, bus_addr, configfs_device_fd,
> -						configfs_group_preexisting);
> +		close_configfs_group();
>   	}
>   
>   	igt_describe("Validate ctx_restore_mid_bb with invalid options");
>   	igt_subtest("ctx-restore-mid-bb-invalid") {
>   		igt_skip_on_f(is_vf_device, "MMIO register readback not possible on VF\n");
> -		configfs_device_fd = igt_configfs_create_device_group(configfs_fd, bus_addr,
> -								      &configfs_group_preexisting);
> +		configfs_device_fd = create_configfs_group();
>   		test_ctx_restore_invalid(configfs_device_fd, "mid");
> -		igt_configfs_close_device_group(configfs_fd, bus_addr, configfs_device_fd,
> -						configfs_group_preexisting);
> +		close_configfs_group();
>   	}
>   
>   	igt_describe("Validate ctx_restore_mid_bb");
>   	igt_subtest("ctx-restore-mid-bb") {
>   		igt_skip_on_f(is_vf_device, "MMIO register readback not possible on VF\n");
> -		configfs_device_fd = igt_configfs_create_device_group(configfs_fd, bus_addr,
> -								      &configfs_group_preexisting);
> +		configfs_device_fd = create_configfs_group();
>   		test_ctx_restore(configfs_device_fd, "mid", engine);
> -		igt_configfs_close_device_group(configfs_fd, bus_addr, configfs_device_fd,
> -						configfs_group_preexisting);
> +		close_configfs_group();
>   	}
>   
>   	igt_fixture() {
> +		close_configfs_group();
>   		close(configfs_fd);
> +		configfs_fd = -1;
>   	}
>   }
> diff --git a/tests/intel/xe_survivability.c b/tests/intel/xe_survivability.c
> index 015b22051..757ddcc6b 100644
> --- a/tests/intel/xe_survivability.c
> +++ b/tests/intel/xe_survivability.c
> @@ -39,7 +39,8 @@
>    */
>   
>   static char bus_addr[NAME_MAX];
> -
> +static int configfs_fd = -1;
> +static int active_configfs_device_fd = -1;
>   static bool configfs_group_preexisting;
>   
>   static void ignore_wedged_in_dmesg(void)
> @@ -156,17 +157,28 @@ static int find_i2c_adapter(struct pci_device *pci_xe)
>   	return i2c_adapter;
>   }
>   
> +static void close_configfs_group(void)
> +{
> +	if (active_configfs_device_fd < 0)
> +		return;
> +
> +	igt_configfs_close_device_group(configfs_fd, bus_addr, active_configfs_device_fd,
> +					configfs_group_preexisting);
> +	active_configfs_device_fd = -1;
> +	configfs_group_preexisting = false;
> +}
> +
>   static void restore(int sig)
>   {
> -	int configfs_fd;
>   
>   	igt_audio_driver_unload(NULL);
>   	igt_kmod_unbind("xe", bus_addr);
>   
> -	configfs_fd = igt_configfs_open("xe");
> -	if (configfs_fd >= 0 && !configfs_group_preexisting)
> -		igt_fs_remove_dir(configfs_fd, bus_addr);
> -	close(configfs_fd);
> +	close_configfs_group();
> +	if (configfs_fd >= 0) {
> +		close(configfs_fd);
> +		configfs_fd = -1;
> +	}
>   
>   	igt_kmod_bind("xe", bus_addr);
>   }
> @@ -210,7 +222,7 @@ static void test_spinner_after_recovery(int fd)
>   
>   int igt_main()
>   {
> -	int fd, configfs_fd, configfs_device_fd;
> +	int fd;
>   	struct pci_device *pci_xe;
>   	bool vf_device;
>   
> @@ -223,14 +235,15 @@ int igt_main()
>   		igt_device_get_pci_slot_name(fd, bus_addr);
>   		configfs_fd = igt_configfs_open("xe");
>   		igt_require(configfs_fd != -1);
> -		configfs_device_fd = igt_configfs_create_device_group(configfs_fd, bus_addr,
> -								      &configfs_group_preexisting);
> +		active_configfs_device_fd =
> +			igt_configfs_create_device_group(configfs_fd, bus_addr,
> +							 &configfs_group_preexisting);
>   		igt_install_exit_handler(restore);
>   	}
>   
>   	igt_describe("Validate i2c adapter functionality in survivability mode");
>   	igt_subtest("i2c-functionality") {
> -		test_i2c_functionality(configfs_device_fd, pci_xe);
> +		test_i2c_functionality(active_configfs_device_fd, pci_xe);
>   		drm_close_driver(fd);
>   		fd = drm_open_driver(DRIVER_XE);
>   	}
> @@ -261,9 +274,9 @@ int igt_main()
>   	}
>   
>   	igt_fixture() {
> -		igt_configfs_close_device_group(configfs_fd, bus_addr, configfs_device_fd,
> -						configfs_group_preexisting);
> +		close_configfs_group();
>   		close(configfs_fd);
> +		configfs_fd = -1;
>   		drm_close_driver(fd);
>   	}
>   }

      parent reply	other threads:[~2026-11-17 17:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  6:13 [PATCH i-g-t] tests/intel/xe_configfs: Avoid leaking configfs device groups Soham Purkait
2026-11-12  6:47 ` ✓ Xe.CI.BAT: success for " Patchwork
2026-11-12  7:02 ` ✓ i915.CI.BAT: " Patchwork
2026-11-12 12:03 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-11-13  2:37 ` ✗ i915.CI.Full: " Patchwork
2026-11-17 17:53 ` Anirban, Sk [this message]

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=91e1e755-c450-4fec-abeb-23c81070c7cc@intel.com \
    --to=sk.anirban@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@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