summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarius Vlad <marius.c.vlad@intel.com>2016-12-01 14:23:56 +0200
committerChris Wilson <chris@chris-wilson.co.uk>2016-12-01 21:47:29 +0000
commitf4361523cb35b95417eda3a0957d312127204c34 (patch)
tree07d2021050b9b85dc25e0d4d6bfe2e5d7c6b03a9 /lib
parent0268d73b0b267c6f5acdd4bf40ae917b3afff96c (diff)
lib/igt_gvt: Make use of libkmod helpers and fix reading gvt parameter.
v2: - use igt_sysfs_get_boolean() to get gvt status (Chris Wilson) - do not hard-fail when i915 module could not be loaded/unloaded (Chris Wilson) Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_gvt.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/lib/igt_gvt.c b/lib/igt_gvt.c
index 8bbf9bd9..4ab74332 100644
--- a/lib/igt_gvt.c
+++ b/lib/igt_gvt.c
@@ -24,35 +24,30 @@
#include "igt.h"
#include "igt_gvt.h"
#include "igt_sysfs.h"
+#include "igt_kmod.h"
+#include <signal.h>
#include <dirent.h>
#include <unistd.h>
#include <fcntl.h>
static bool is_gvt_enabled(void)
{
- FILE *file;
- int value;
bool enabled = false;
+ int dir, fd;
- file = fopen("/sys/module/i915/parameters/enable_gvt", "r");
- if (!file)
+ fd = __drm_open_driver(DRIVER_INTEL);
+ dir = igt_sysfs_open_parameters(fd);
+ if (dir < 0)
return false;
- if (fscanf(file, "%d", &value) == 1)
- enabled = value;
- fclose(file);
+ enabled = igt_sysfs_get_boolean(dir, "enable_gvt");
- errno = 0;
- return enabled;
-}
+ close(dir);
+ close(fd);
-static void unload_i915(void)
-{
- kick_fbcon(false);
- /* pkill alsact */
+ return enabled;
- igt_ignore_warn(system("/sbin/modprobe -s -r i915"));
}
bool igt_gvt_load_module(void)
@@ -60,8 +55,11 @@ bool igt_gvt_load_module(void)
if (is_gvt_enabled())
return true;
- unload_i915();
- igt_ignore_warn(system("/sbin/modprobe -s i915 enable_gvt=1"));
+ if (igt_i915_driver_unload())
+ return false;
+
+ if (igt_i915_driver_load("enable_gvt=1"))
+ return false;
return is_gvt_enabled();
}
@@ -71,8 +69,9 @@ void igt_gvt_unload_module(void)
if (!is_gvt_enabled())
return;
- unload_i915();
- igt_ignore_warn(system("/sbin/modprobe -s i915 enable_gvt=0"));
+ igt_i915_driver_unload();
+
+ igt_i915_driver_load(NULL);
igt_assert(!is_gvt_enabled());
}