From patchwork Thu Dec 1 12:23:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marius Vlad X-Patchwork-Id: 9455927 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 3E8916074E for ; Thu, 1 Dec 2016 12:18:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31C2A284CB for ; Thu, 1 Dec 2016 12:18:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2427B284DA; Thu, 1 Dec 2016 12:18:33 +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 AEF97284CB for ; Thu, 1 Dec 2016 12:18:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A3F366E78F; Thu, 1 Dec 2016 12:18:30 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1BB6A6E1B5 for ; Thu, 1 Dec 2016 12:18:29 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 01 Dec 2016 04:18:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,282,1477983600"; d="scan'208";a="793024329" Received: from mcvlad-wk.rb.intel.com ([10.237.105.57]) by FMSMGA003.fm.intel.com with ESMTP; 01 Dec 2016 04:18:05 -0800 From: Marius Vlad To: intel-gfx@lists.freedesktop.org Date: Thu, 1 Dec 2016 14:23:56 +0200 Message-Id: <20161201122358.1124-3-marius.c.vlad@intel.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161201122358.1124-1-marius.c.vlad@intel.com> References: <20161201122358.1124-1-marius.c.vlad@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 2/4 v7] 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 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 --- 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 #include #include #include 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");