From: Petri Latvala <petri.latvala@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>,
Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>,
gustavo@padovan.org
Subject: [igt-dev] [PATCH i-g-t v3] Add support for forcing a specific driver
Date: Tue, 18 Dec 2018 14:19:42 +0200 [thread overview]
Message-ID: <20181218121941.29174-1-petri.latvala@intel.com> (raw)
This commit adds a new option for forcing the use of a specific driver
indicated via an environment variable.
v2 (Petri):
- Use an environment variable instead of command line
- Refactor the loop in __open_device
- Don't try to load kernel modules
v3 (Petri):
- Rebase and adjust to the driver loading changes
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: gustavo@padovan.org
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> #v2
---
lib/drmtest.c | 32 ++++++++++++++++++++++++++++++++
lib/drmtest.h | 2 ++
lib/igt_core.c | 5 +++++
3 files changed, 39 insertions(+)
diff --git a/lib/drmtest.c b/lib/drmtest.c
index d2aa1c19..35914c50 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -123,6 +123,31 @@ static bool has_known_intel_chipset(int fd)
return true;
}
+static char _forced_driver[16] = "";
+
+/**
+ * __set_forced_driver:
+ * @name: name of driver to forcibly use
+ *
+ * Set the name of a driver to use when calling #drm_open_driver with
+ * the #DRIVER_ANY flag.
+ */
+void __set_forced_driver(const char *name)
+{
+ if (!name)
+ igt_warn("No driver specified, keep default behaviour\n");
+
+ strncpy(_forced_driver, name, sizeof(_forced_driver) - 1);
+}
+
+static const char *forced_driver(void)
+{
+ if (_forced_driver[0])
+ return _forced_driver;
+
+ return NULL;
+}
+
#define LOCAL_I915_EXEC_VEBOX (4 << 0)
/**
* gem_quiescent_gpu:
@@ -212,6 +237,7 @@ static const struct module {
static int open_device(const char *name, unsigned int chipset)
{
+ const char *forced;
char dev_name[16] = "";
int chip = DRIVER_ANY;
int fd;
@@ -223,6 +249,12 @@ static int open_device(const char *name, unsigned int chipset)
if (__get_drm_device_name(fd, dev_name, sizeof(dev_name) - 1) == -1)
goto err;
+ forced = forced_driver();
+ if (forced && chipset == DRIVER_ANY && !strcmp(forced, dev_name)) {
+ igt_debug("Force option used: Using driver %s\n", dev_name);
+ return fd;
+ }
+
for (int start = 0, end = ARRAY_SIZE(modules) - 1; start < end; ){
int mid = start + (end - start) / 2;
int ret = strcmp(modules[mid].module, dev_name);
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 96ee517e..8743b1bb 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -52,6 +52,8 @@
*/
#define DRIVER_ANY ~(DRIVER_VGEM)
+void __set_forced_driver(const char *name);
+
/**
* ARRAY_SIZE:
* @arr: static array
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 64883d64..50d6008f 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -647,6 +647,11 @@ static void common_init_env(void)
igt_frame_dump_path = getenv("IGT_FRAME_DUMP_PATH");
stderr_needs_sentinel = getenv("IGT_SENTINEL_ON_STDERR") != NULL;
+
+ env = getenv("IGT_FORCE_DRIVER");
+ if (env) {
+ __set_forced_driver(env);
+ }
}
static int common_init(int *argc, char **argv,
--
2.19.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next reply other threads:[~2018-12-18 12:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-18 12:19 Petri Latvala [this message]
2018-12-18 12:42 ` [igt-dev] ✓ Fi.CI.BAT: success for Add support for forcing a specific driver (rev2) Patchwork
2018-12-18 12:46 ` [igt-dev] [PATCH i-g-t v3] Add support for forcing a specific driver Rodrigo Siqueira
2018-12-18 17:42 ` [igt-dev] ✓ Fi.CI.IGT: success for Add support for forcing a specific driver (rev2) 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=20181218121941.29174-1-petri.latvala@intel.com \
--to=petri.latvala@intel.com \
--cc=gustavo@padovan.org \
--cc=igt-dev@lists.freedesktop.org \
--cc=rodrigosiqueiramelo@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox