public inbox for igt-dev@lists.freedesktop.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/7] lib/igt_core: store GPU string or opened device name
Date: Fri,  2 Dec 2022 21:57:00 +0100	[thread overview]
Message-ID: <20221202205705.58879-3-kamil.konieczny@linux.intel.com> (raw)
In-Reply-To: <20221202205705.58879-1-kamil.konieczny@linux.intel.com>

From: Mauro Carvalho Chehab <mchehab@kernel.org>

This is helpful on tests that run with multiple GPUs.
The name will be automatically filled when a device will
be opened.

v2: reorganized code, changed commit message to note that
  it will be filled with pathname of opended device, also
  correct static initialization [Kamil]

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
 lib/drmtest.c  |  4 +++-
 lib/igt_core.c | 30 ++++++++++++++++++++++++++++++
 lib/igt_core.h |  6 ++++++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 16e80bdf..5eb98272 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -222,8 +222,10 @@ static int open_device(const char *name, unsigned int chipset)
 			break;
 		}
 	}
-	if ((chipset & chip) == chip)
+	if ((chipset & chip) == chip) {
+		set_gpu_string(name);
 		return fd;
+	}
 
 err:
 	close(fd);
diff --git a/lib/igt_core.c b/lib/igt_core.c
index dca380d0..68ae7289 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1576,6 +1576,36 @@ static void kill_and_wait(pid_t *pids, int size, int signum)
 	}
 }
 
+static __thread char *gpu_string;
+
+void set_gpu_string(const char *fname)
+{
+	char sysfs[PATH_MAX], *path, *p;
+
+	if (gpu_string) {
+		free(gpu_string);
+		gpu_string = NULL;
+	}
+
+	if (!fname)
+		return;
+
+	p = strrchr(fname, '/');
+	if (!p) {
+		path = strdup(fname);
+	} else {
+		p++;
+
+		strcpy(sysfs, "/sys/class/drm/");
+		strcat(sysfs, p);
+		path = realpath(sysfs, NULL);
+		igt_debug("opened %s as %s\n", fname, path);
+	}
+
+	gpu_string = path;
+	igt_assert(gpu_string);
+}
+
 __noreturn static void exit_subtest(const char *result)
 {
 	struct timespec now;
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 5d5593e0..1f7e3652 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -1519,4 +1519,10 @@ static inline void igt_pci_system_cleanup(void)
 {
 }
 
+/**
+ * set_gpu_string():
+ * Sets a string to describe the GPU being tested
+ */
+void set_gpu_string(const char *string);
+
 #endif /* IGT_CORE_H */
-- 
2.34.1

       reply	other threads:[~2022-12-02 20:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20221202205705.58879-1-kamil.konieczny@linux.intel.com>
2022-12-02 20:57 ` Kamil Konieczny [this message]
2022-12-07 10:32   ` [igt-dev] [PATCH i-g-t 2/7] lib/igt_core: store GPU string or opened device name Petri Latvala
2022-12-02 20:57 ` [igt-dev] [PATCH i-g-t 3/7] lib/igt_core: add prefix to logging Kamil Konieczny
2022-12-05  6:12   ` Mauro Carvalho Chehab
2022-12-02 20:57 ` [igt-dev] [PATCH i-g-t 4/7] lib/tests/igt_fork: add tests for igt_multi_fork Kamil Konieczny
2022-12-05  6:15   ` Mauro Carvalho Chehab
2022-12-02 20:57 ` [igt-dev] [PATCH i-g-t 6/7] tests/i915/gem_exec_gttfill: add new subtest multigpu-basic Kamil Konieczny
2022-12-05  6:28   ` Mauro Carvalho Chehab
2022-12-02 20:57 ` [igt-dev] [PATCH i-g-t 7/7] tests/i915/gem_close_race: add multiGPU subtests Kamil Konieczny
2022-12-05  6:30   ` Mauro Carvalho Chehab
2022-12-02 21:38 ` [igt-dev] ✗ Fi.CI.BAT: failure for Add few multi-GPU subtests with the help of igt_multi_fork macro Patchwork
2022-12-05 14:33   ` Kamil Konieczny
     [not found] ` <20221202205705.58879-6-kamil.konieczny@linux.intel.com>
2022-12-05  6:10   ` [igt-dev] [PATCH i-g-t 5/7] tests/i915/gem_basic: add multigpu-create-close subtest Mauro Carvalho Chehab
     [not found] ` <20221202205705.58879-2-kamil.konieczny@linux.intel.com>
2022-12-05  6:32   ` [igt-dev] [PATCH i-g-t 1/7] lib/igt_core: add igt_multi_fork for parallel tests Mauro Carvalho Chehab

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=20221202205705.58879-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox