summaryrefslogtreecommitdiff
path: root/lib/drmtest.c
diff options
context:
space:
mode:
authorPetri Latvala <petri.latvala@intel.com>2018-12-18 14:19:42 +0200
committerPetri Latvala <petri.latvala@intel.com>2018-12-20 11:01:34 +0200
commit47f5a57a81b66c21d06695e263a22b87f5a33009 (patch)
treed44ffa68a4097e8cc32c766fd782136a8044b89b /lib/drmtest.c
parentf05c8c2739dce89185349703062784a7745cab14 (diff)
Add support for forcing a specific driver
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> Reviewed-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Diffstat (limited to 'lib/drmtest.c')
-rw-r--r--lib/drmtest.c32
1 files changed, 32 insertions, 0 deletions
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);