Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: James Shargo <jshargo@chromium.org>
To: Development mailing list for IGT GPU Tools
	<igt-dev@lists.freedesktop.org>
Subject: [igt-dev] [PATCH i-g-t 1/3] lib/drmtest: Add VKMS as a known driver type
Date: Fri, 23 Jun 2023 19:09:52 -0400	[thread overview]
Message-ID: <20230623230954.115437-2-jshargo@chromium.org> (raw)
In-Reply-To: <20230623230954.115437-1-jshargo@chromium.org>

From: Jim Shargo <jshargo@chromium.org>

Signed-off-by: Jim Shargo <jshargo@chromium.org>
---
 lib/drmtest.c | 26 ++++++++++++++++++++++++++
 lib/drmtest.h |  7 ++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 220cfb64d..ad8cbe302 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -150,6 +150,16 @@ bool is_intel_device(int fd)
 	return is_i915_device(fd) || is_xe_device(fd);
 }
 
+bool is_vkms_device(int fd)
+{
+	char name[64] = "";
+
+	if (__get_drm_device_name(fd, name, sizeof(name) - 1))
+		return false;
+
+	return strncmp("vkms", name, strlen("vkms")) == 0;
+}
+
 static char _forced_driver[16] = "";
 
 /**
@@ -734,3 +744,19 @@ void igt_require_xe(int fd)
 {
 	igt_require(is_xe_device(fd));
 }
+
+void igt_require_vkms(void)
+{
+	// Since VKMS can create and destroy virtual drivers at will,
+	// instead look to make sure the driver is installed.
+	struct stat s = {};
+	int ret;
+	char *vkms_module_dir = "/sys/module/vkms";
+
+	ret = stat(vkms_module_dir, &s);
+
+	igt_require_f(ret == 0, "VKMS stat of %s returned %d (%s)\n",
+		      vkms_module_dir, ret, strerror(ret));
+	igt_require_f(S_ISDIR(s.st_mode),
+		      "VKMS stat of %s was not a directory\n", vkms_module_dir);
+}
diff --git a/lib/drmtest.h b/lib/drmtest.h
index ae86ee19a..1d418e1f6 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -53,14 +53,17 @@
 #define DRIVER_MSM	(1 << 6)
 #define DRIVER_XE	(1 << 7)
 #define DRIVER_VMWGFX   (1 << 8)
+#define DRIVER_VKMS	(1 << 9)
 
 /*
  * Exclude DRVER_VGEM from DRIVER_ANY since if you run on a system
  * with vgem as well as a supported driver, you can end up with a
  * near-100% skip rate if you don't explicitly specify the device,
  * depending on device-load ordering.
+ *
+ * Exclude VKMS to prefer hardware drivers.
  */
-#define DRIVER_ANY 	~(DRIVER_VGEM)
+#define DRIVER_ANY ~(DRIVER_VGEM | DRIVER_VKMS)
 
 /*
  * Compile friendly enum for i915/xe.
@@ -114,6 +117,7 @@ void igt_require_i915(int fd);
 void igt_require_nouveau(int fd);
 void igt_require_vc4(int fd);
 void igt_require_xe(int fd);
+void igt_require_vkms(void);
 
 bool is_amdgpu_device(int fd);
 bool is_i915_device(int fd);
@@ -123,6 +127,7 @@ bool is_nouveau_device(int fd);
 bool is_vc4_device(int fd);
 bool is_xe_device(int fd);
 bool is_intel_device(int fd);
+bool is_vkms_device(int fd);
 
 /**
  * do_or_die:
-- 
2.41.0.162.gfafddb0af9-goog

  reply	other threads:[~2023-06-23 23:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-23 23:09 [igt-dev] [PATCH i-g-t 0/3] Add tests and support for VKMS's new ConfigFS features James Shargo
2023-06-23 23:09 ` James Shargo [this message]
2023-06-28 18:50   ` [igt-dev] [PATCH i-g-t 1/3] lib/drmtest: Add VKMS as a known driver type Kamil Konieczny
2023-06-23 23:09 ` [igt-dev] [PATCH i-g-t 2/3] lib/igt_aux: Make "is_mountpoint" public ("igt_is_mountpoint") James Shargo
2023-06-28 18:57   ` Kamil Konieczny
2023-06-23 23:09 ` [igt-dev] [PATCH i-g-t 3/3] tests/vkms: Adds VKMS tests and library functions to support them James Shargo
2023-06-28 19:27   ` Kamil Konieczny
2023-06-24  0:49 ` [igt-dev] ✗ GitLab.Pipeline: warning for Add tests and support for VKMS's new ConfigFS features Patchwork
2023-06-24  1:23 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-06-24  3:36 ` [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=20230623230954.115437-2-jshargo@chromium.org \
    --to=jshargo@chromium.org \
    --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