All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kamil Konieczny <kamil.konieczny@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 2/3] tests/i915/gem_close_race: fix multi-gpu subtests
Date: Tue, 14 Feb 2023 20:28:29 +0100	[thread overview]
Message-ID: <20230214192830.51997-3-kamil.konieczny@linux.intel.com> (raw)
In-Reply-To: <20230214192830.51997-1-kamil.konieczny@linux.intel.com>

Change subtests and open cards in order, starting from first and
ending on last one.

Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
 tests/i915/gem_close_race.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
index 9c646f42..0ee46bf4 100644
--- a/tests/i915/gem_close_race.c
+++ b/tests/i915/gem_close_race.c
@@ -255,17 +255,34 @@ static void thread(int fd, struct drm_gem_open name,
 	free(history);
 }
 
+static void multigpu_open(int *fds, int gpu_count)
+{
+	for (int i = 1; i < gpu_count; i++) {
+		fds[i] = i ? __drm_open_driver_another(i, DRIVER_INTEL) : drm_open_driver(DRIVER_INTEL);
+		igt_assert(fds[i] >= 0);
+	}
+}
+
+static void multigpu_close(int *fds, int gpu_count)
+{
+	for (int i = gpu_count - 1; i >= 0; i--)
+		close(fds[i]);
+}
+
 static void multigpu_threads(int timeout, unsigned int flags, int gpu_count)
 {
 	int size = sysconf(_SC_NPROCESSORS_ONLN);
+#define MAX_GPU 16
+	int fds[MAX_GPU];
 
+	multigpu_open(fds, gpu_count);
 	size /= gpu_count;
 	if (size < 1)
 		size = 1;
 
 	igt_multi_fork(gpu, gpu_count) {
 		struct drm_gem_open name;
-		int fd = __drm_open_driver_another(gpu, DRIVER_INTEL);
+		int fd = gem_reopen_driver(fds[gpu]);
 
 		igt_assert(fd > 0);
 
@@ -278,6 +295,7 @@ static void multigpu_threads(int timeout, unsigned int flags, int gpu_count)
 	}
 
 	igt_waitchildren();
+	multigpu_close(fds, gpu_count);
 }
 
 static void threads(int timeout, unsigned int flags)
@@ -334,10 +352,14 @@ igt_main
 
 	igt_describe("Basic workload submission on multi-GPU machine.");
 	igt_subtest("multigpu-basic-process") {
+		int fds[MAX_GPU];
+
 		igt_require(gpu_count > 1);
+		igt_require(gpu_count <= MAX_GPU);
+		multigpu_open(fds, gpu_count);
 
 		igt_multi_fork(child, gpu_count) {
-			int fd = __drm_open_driver_another(child, DRIVER_INTEL);
+			int fd = gem_reopen_driver(fds[child]);
 
 			igt_assert(fd > 0);
 			process(fd, child);
@@ -346,6 +368,7 @@ igt_main
 		}
 
 		igt_waitchildren();
+		multigpu_close(fds, gpu_count);
 	}
 
 	igt_describe("Share buffer handle across different drm fd's and trying to race "
-- 
2.37.2

  parent reply	other threads:[~2023-02-14 19:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14 19:28 [igt-dev] [PATCH i-g-t 0/3] Fix multi-gpu subtests and open all cards consecutivly Kamil Konieczny
2023-02-14 19:28 ` [igt-dev] [PATCH i-g-t 1/3] tests/i915/gem_basic: fix multigpu subtest Kamil Konieczny
2023-02-14 19:28 ` Kamil Konieczny [this message]
2023-02-14 19:28 ` [igt-dev] [PATCH i-g-t 3/3] i915/gem_exec_gttfill: " Kamil Konieczny
2023-02-14 20:23 ` [igt-dev] ✓ Fi.CI.BAT: success for Fix multi-gpu subtests and open all cards consecutivly Patchwork
2023-02-15  5:16 ` [igt-dev] ✓ Fi.CI.IGT: " 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=20230214192830.51997-3-kamil.konieczny@linux.intel.com \
    --to=kamil.konieczny@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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.