All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>,
	Adam Miszczak <adam.miszczak@linux.intel.com>,
	Jakub Kolakowski <jakub1.kolakowski@intel.com>,
	Lukasz Laguna <lukasz.laguna@intel.com>
Subject: [PATCH i-g-t] tests/intel/xe_sriov_scheduling: Close open handles before disabling VFs
Date: Wed, 14 May 2025 16:25:43 +0200	[thread overview]
Message-ID: <20250514142543.345665-1-marcin.bernatowicz@linux.intel.com> (raw)

Prevent a potential hot-unplug scenario by explicitly closing all
open handles before disabling VFs. Extract handle cleanup into a
dedicated subm_set_close_handles() helper and invoke it before
asserts.

Cc: Adam Miszczak <adam.miszczak@linux.intel.com>
Cc: Jakub Kolakowski <jakub1.kolakowski@intel.com>
Cc: Lukasz Laguna <lukasz.laguna@intel.com>
Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
---
 tests/intel/xe_sriov_scheduling.c | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/tests/intel/xe_sriov_scheduling.c b/tests/intel/xe_sriov_scheduling.c
index 89cdd8750..2cd18c982 100644
--- a/tests/intel/xe_sriov_scheduling.c
+++ b/tests/intel/xe_sriov_scheduling.c
@@ -241,22 +241,41 @@ static void subm_set_init_sync_method(struct subm_set *set, enum subm_sync_metho
 		pthread_barrier_init(&set->barrier, NULL, set->ndata);
 }
 
-static void subm_set_fini(struct subm_set *set)
+static void subm_set_close_handles(struct subm_set *set)
 {
+	struct subm *s;
 	int i;
 
 	if (!set->ndata)
 		return;
 
 	for (i = 0; i < set->ndata; ++i) {
-		igt_stats_fini(&set->data[i].stats.samples);
-		subm_fini(&set->data[i].subm);
-		drm_close_driver(set->data[i].subm.fd);
+		s = &set->data[i].subm;
+
+		if (s->fd != -1) {
+			subm_fini(s);
+			drm_close_driver(s->fd);
+			s->fd = -1;
+		}
 	}
-	subm_set_free_data(set);
+}
+
+static void subm_set_fini(struct subm_set *set)
+{
+	int i;
+
+	if (!set->ndata)
+		return;
 
 	if (set->sync_method == SYNC_BARRIER)
 		pthread_barrier_destroy(&set->barrier);
+
+	subm_set_close_handles(set);
+
+	for (i = 0; i < set->ndata; ++i)
+		igt_stats_fini(&set->data[i].stats.samples);
+
+	subm_set_free_data(set);
 }
 
 struct init_vf_ids_opts {
@@ -602,6 +621,7 @@ static void throughput_ratio(int pf_fd, int num_vfs, const struct subm_opts *opt
 
 	/* dispatch spinners, wait for results */
 	subm_set_dispatch_and_wait_threads(set);
+	subm_set_close_handles(set);
 
 	/* verify results */
 	compute_common_time_frame_stats(set);
@@ -696,6 +716,7 @@ static void nonpreempt_engine_resets(int pf_fd, int num_vfs,
 
 	/* dispatch spinners, wait for results */
 	subm_set_dispatch_and_wait_threads(set);
+	subm_set_close_handles(set);
 
 	/* verify results */
 	for (int n = 0; n < set->ndata; ++n) {
-- 
2.31.1


             reply	other threads:[~2025-05-14 14:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-14 14:25 Marcin Bernatowicz [this message]
2025-05-14 17:42 ` ✓ Xe.CI.BAT: success for tests/intel/xe_sriov_scheduling: Close open handles before disabling VFs Patchwork
2025-05-14 17:53 ` ✓ i915.CI.BAT: " Patchwork
2025-05-15  0:39 ` ✗ Xe.CI.Full: failure " Patchwork
2025-05-15 14:03   ` Bernatowicz, Marcin
2025-05-15  0:48 ` ✗ i915.CI.Full: " Patchwork
2025-05-15 14:04   ` Bernatowicz, Marcin
2025-05-15  8:52 ` [PATCH i-g-t] " Adam Miszczak

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=20250514142543.345665-1-marcin.bernatowicz@linux.intel.com \
    --to=marcin.bernatowicz@linux.intel.com \
    --cc=adam.miszczak@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jakub1.kolakowski@intel.com \
    --cc=lukasz.laguna@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.