From patchwork Fri Oct 28 09:31:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marius Vlad X-Patchwork-Id: 9401711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 549D760588 for ; Fri, 28 Oct 2016 09:25:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 422EC2A6DB for ; Fri, 28 Oct 2016 09:25:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 374882A6DE; Fri, 28 Oct 2016 09:25:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E5BBA2A6DB for ; Fri, 28 Oct 2016 09:25:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CEDD96EAF6; Fri, 28 Oct 2016 09:25:22 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 78B1C6EAD2 for ; Fri, 28 Oct 2016 09:25:20 +0000 (UTC) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP; 28 Oct 2016 02:25:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,557,1473145200"; d="scan'208";a="24683403" Received: from mcvlad-wk.rb.intel.com ([10.237.105.57]) by fmsmga006.fm.intel.com with ESMTP; 28 Oct 2016 02:25:18 -0700 From: Marius Vlad To: intel-gfx@lists.freedesktop.org Date: Fri, 28 Oct 2016 12:31:27 +0300 Message-Id: <20161028093129.13275-3-marius.c.vlad@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161028093129.13275-1-marius.c.vlad@intel.com> References: <20161028093129.13275-1-marius.c.vlad@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 2/4 v4] lib/igt_gvt: Make use of libkmod helpers and fix reading gvt parameter. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Marius Vlad --- lib/igt_gvt.c | 42 +++++++++++++++++++++++++++++++++++------- tests/gvt_basic.c | 2 +- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/lib/igt_gvt.c b/lib/igt_gvt.c index 8bbf9bd..d868cb3 100644 --- a/lib/igt_gvt.c +++ b/lib/igt_gvt.c @@ -24,23 +24,26 @@ #include "igt.h" #include "igt_gvt.h" #include "igt_sysfs.h" +#include "igt_kmod.h" +#include #include #include #include +#include static bool is_gvt_enabled(void) { FILE *file; - int value; + char value; bool enabled = false; file = fopen("/sys/module/i915/parameters/enable_gvt", "r"); if (!file) return false; - if (fscanf(file, "%d", &value) == 1) - enabled = value; + if (fscanf(file, "%c", &value) == 1) + enabled = (value == 'Y' ? true : false); fclose(file); errno = 0; @@ -50,9 +53,20 @@ static bool is_gvt_enabled(void) static void unload_i915(void) { kick_fbcon(false); - /* pkill alsact */ - igt_ignore_warn(system("/sbin/modprobe -s -r i915")); + + if (igt_kmod_is_loaded("i915")) { + + if (igt_kmod_is_loaded("snd_hda_intel")) { + igt_assert(!igt_pkill(SIGTERM, "alsactl")); + igt_assert(!igt_kmod_unload("snd_hda_intel", 0)); + } + + igt_assert(!igt_kmod_unload("i915", 0)); + igt_assert(!igt_kmod_unload("drm_kms_helper", 0)); + igt_assert(!igt_kmod_unload("drm", 0)); + } + } bool igt_gvt_load_module(void) @@ -61,8 +75,15 @@ bool igt_gvt_load_module(void) return true; unload_i915(); - igt_ignore_warn(system("/sbin/modprobe -s i915 enable_gvt=1")); + igt_assert(!igt_kmod_load("drm", NULL)); + igt_assert(!igt_kmod_load("drm_kms_helper", NULL)); + + igt_assert(!igt_kmod_load("i915", "enable_gvt=1")); + + kick_fbcon(true); + + igt_assert(!igt_kmod_load("snd_hda_intel", NULL)); return is_gvt_enabled(); } @@ -72,7 +93,14 @@ void igt_gvt_unload_module(void) return; unload_i915(); - igt_ignore_warn(system("/sbin/modprobe -s i915 enable_gvt=0")); + + igt_assert(!igt_kmod_load("drm", NULL)); + igt_assert(!igt_kmod_load("drm_kms_helper", NULL)); + + igt_assert(!igt_kmod_load("i915", "enable_gvt=0")); igt_assert(!is_gvt_enabled()); + + kick_fbcon(true); + igt_assert(!igt_kmod_load("snd_hda_intel", NULL)); } 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");