From patchwork Wed Aug 22 10:20:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Latvala X-Patchwork-Id: 10572843 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B8B6109C for ; Wed, 22 Aug 2018 10:21:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFF892AACE for ; Wed, 22 Aug 2018 10:21:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3CBF2AE4D; Wed, 22 Aug 2018 10:21:05 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 71D862AACE for ; Wed, 22 Aug 2018 10:21:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1EBC889E43; Wed, 22 Aug 2018 10:21:01 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 854B889E43; Wed, 22 Aug 2018 10:20:59 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Aug 2018 03:20:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,273,1531810800"; d="scan'208";a="257045336" Received: from thrakatuluk.fi.intel.com (HELO thrakatuluk) ([10.237.68.137]) by fmsmga006.fm.intel.com with ESMTP; 22 Aug 2018 03:20:57 -0700 Received: from platvala by thrakatuluk with local (Exim 4.89) (envelope-from ) id 1fsQG0-0006Kl-BX; Wed, 22 Aug 2018 13:20:56 +0300 From: Petri Latvala To: igt-dev@lists.freedesktop.org Date: Wed, 22 Aug 2018 13:20:38 +0300 Message-Id: <20180822102038.24308-1-petri.latvala@intel.com> X-Mailer: git-send-email 2.14.1 Subject: [Intel-gfx] [PATCH i-g-t v2] Add support for forcing a specific driver X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, Rodrigo Siqueira MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Rodrigo Siqueira Signed-off-by: Petri Latvala Cc: Arkadiusz Hiler Cc: gustavo@padovan.org Reviewed-by: Daniel Vetter --- Did the changes I suggested myself to see what else is lurking there. I'm still unsure whether using IGT_FORCE_DRIVER=something should still accept opening e.g. an i915 device with DRIVER_INTEL, currently this does. Both ways have their merits. I was able to test vkms with this patch, revealing some amount of intelisms still lurking. lib/drmtest.c | 35 +++++++++++++++++++++++++++++++++++ lib/drmtest.h | 2 ++ lib/igt_core.c | 5 +++++ 3 files changed, 42 insertions(+) diff --git a/lib/drmtest.c b/lib/drmtest.c index fae6f86f..e8308b0d 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -146,6 +146,31 @@ static bool has_known_intel_chipset(int fd) return true; } +static char _forced_driver[5] = ""; + +/** + * __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"); + + strncpy(_forced_driver, name, 4); +} + +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: @@ -229,6 +254,16 @@ static int __open_device(const char *base, int offset, unsigned int chipset) if (fd == -1) continue; + // Force options + if (chipset == DRIVER_ANY && forced_driver()) { + if (__is_device(fd, forced_driver())) { + igt_debug("Force option used: Using driver %s\n", forced_driver()); + return fd; + } + + continue; + } + if (chipset & DRIVER_INTEL && is_i915_device(fd) && has_known_intel_chipset(fd)) return fd; diff --git a/lib/drmtest.h b/lib/drmtest.h index 949865ee..62f53ec3 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -51,6 +51,8 @@ */ #define DRIVER_ANY ~(DRIVER_VGEM) +void __set_forced_driver(const char *name); + /** * ARRAY_SIZE: * @arr: static array diff --git a/lib/igt_core.c b/lib/igt_core.c index c52c0818..c17e53c5 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -646,6 +646,11 @@ static void common_init_env(void) igt_frame_dump_path = getenv("IGT_FRAME_DUMP_PATH"); stderr_needs_sentinel = getenv("IGT_SENTINEL_ON_STDERR") != NULL; + + env = getenv("IGT_FORCE_DRIVER"); + if (env) { + __set_forced_driver(env); + } } static int common_init(int *argc, char **argv,