[Intel-gfx] [PATCH i-g-t 2/4 v5] lib/igt_gvt: Make use of libkmod helpers and fix reading gvt parameter.
Zhenyu Wang
zhenyuw at linux.intel.com
Thu Nov 10 02:30:08 UTC 2016
On 2016.11.03 18:28:11 +0200, Marius Vlad wrote:
> 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 at intel.com>
Looks fine to me.
Acked-by: Zhenyu Wang <zhenyuw at linux.intel.com>
> ---
> lib/igt_gvt.c | 37 ++++++++++++++++++-------------------
> tests/gvt_basic.c | 2 +-
> 2 files changed, 19 insertions(+), 20 deletions(-)
>
> diff --git a/lib/igt_gvt.c b/lib/igt_gvt.c
> index 8bbf9bd..4ab7433 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());
> }
> diff --git a/tests/gvt_basic.c b/tests/gvt_basic.c
> index 48b853a..4e909a5 100644
> --- a/tests/gvt_basic.c
> +++ b/tests/gvt_basic.c
> @@ -32,7 +32,7 @@ igt_main
>
> igt_fixture {
> igt_require(igt_gvt_load_module());
> - fd = drm_open_driver(DRIVER_INTEL);
> + fd = __drm_open_driver(DRIVER_INTEL);
> }
>
> igt_subtest_f("invalid-placeholder-test");
> --
> 2.7.4
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Open Source Technology Center, Intel ltd.
$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gfx/attachments/20161110/b9b60f43/attachment.sig>
More information about the Intel-gfx
mailing list