Igt-dev Archive on 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 v9 4/8] lib/drmtest: save skip offset for first opened device
Date: Fri, 20 Oct 2023 15:00:12 +0200	[thread overview]
Message-ID: <20231020130016.86398-5-kamil.konieczny@linux.intel.com> (raw)
In-Reply-To: <20231020130016.86398-1-kamil.konieczny@linux.intel.com>

On some boards with many discrete GPU cards it may happen that
on-board one is integrated and will be skipped during opening
a first device. With out-of-order try and open it may result
with off-by-one error opening wrong card. Fixed this with saving
skip offset for first device name.

Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
 lib/drmtest.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 7c2fd7c56..89d045200 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -292,6 +292,8 @@ static struct {
 }_opened_fds[64];
 
 static int _opened_fds_count;
+static int _opened_fds0_skip;
+static int _opened_fds0_chipset;
 
 static void _set_opened_fd(int idx, int fd)
 {
@@ -348,7 +350,11 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset,
 	if (forced)
 		igt_debug("Force option used: Using driver %s\n", forced);
 
-	offset += as_idx;
+	if (offset == 0 && as_idx != 0 && _opened_fds0_chipset == chipset)
+		offset += as_idx + _opened_fds0_skip;
+	else
+		offset += as_idx;
+
 	for (int i = 0; i < 16; i++) {
 		char name[80];
 		int fd;
@@ -359,8 +365,15 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset,
 			continue;
 
 		fd = open_device(name, chipset);
-		if (fd != -1)
+		if (fd != -1) {
+			if (i != 0 && offset == as_idx && as_idx == 0
+			    && chipset != DRIVER_VGEM && chipset != DRIVER_ANY) {
+				_opened_fds0_skip = i;
+				_opened_fds0_chipset = chipset;
+			}
+
 			return fd;
+		}
 	}
 
 	return -1;
-- 
2.42.0

  parent reply	other threads:[~2023-10-20 13:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-20 13:00 [igt-dev] [PATCH i-g-t v9 0/8] drmtest changes for running tests on multi-gpu Kamil Konieczny
2023-10-20 13:00 ` [igt-dev] [PATCH i-g-t v9 1/8] lib/drmtest: allow out of order device opening Kamil Konieczny
2023-10-20 13:00 ` [igt-dev] [PATCH i-g-t v9 2/8] tests/intel/xe_create: extend massive subtest to multi-gpu Kamil Konieczny
2023-10-20 13:00 ` [igt-dev] [PATCH i-g-t v9 3/8] lib/drmtest: drop checks for opened device for filters Kamil Konieczny
2023-10-20 13:00 ` Kamil Konieczny [this message]
2023-10-20 13:00 ` [igt-dev] [PATCH i-g-t v9 5/8] lib/drmtest: create helper for countig number of GPUs Kamil Konieczny
2023-10-20 13:00 ` [igt-dev] [PATCH i-g-t v9 6/8] tests/intel/xe_create: use drm helper for GPUs count Kamil Konieczny
2023-10-20 13:00 ` [igt-dev] [PATCH i-g-t v9 7/8] lib/drmtest: create helper for dropping opened paths Kamil Konieczny
2023-10-20 13:00 ` [igt-dev] [PATCH i-g-t v9 8/8] tests/intel/xe_create: print first opened card Kamil Konieczny
2023-10-24  0:23 ` [igt-dev] ✓ Fi.CI.BAT: success for drmtest changes for running tests on multi-gpu (rev8) Patchwork
2023-10-24  1:22 ` [igt-dev] ✓ CI.xeBAT: " 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=20231020130016.86398-5-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox