From patchwork Wed Sep 5 20:38:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10589445 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 433D613BB for ; Wed, 5 Sep 2018 20:38:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 315C52ABB0 for ; Wed, 5 Sep 2018 20:38:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23C852ABB8; Wed, 5 Sep 2018 20:38:38 +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,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,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 7E3E32ABB0 for ; Wed, 5 Sep 2018 20:38:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 486E36E0DC; Wed, 5 Sep 2018 20:38:36 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F5DB6E0DC; Wed, 5 Sep 2018 20:38:35 +0000 (UTC) Received: by mail-ed1-x52d.google.com with SMTP id h4-v6so7150946edi.6; Wed, 05 Sep 2018 13:38:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:user-agent; bh=Tc7UF2dNodKDUBvTgYBfRp50qBezqIzPJIz1M7sC1U4=; b=W4ijD0+kLm9ZvkAUqW3iAgM1Wb/018xeZpF+a2nKWMMSzDoomJc5MaMQmn+gf/SG4s jL6Bth4cwi3V5fr9vkylIHQ6mwl6pMdkaQtCycev4p5Zo1Z1Kg5r9qYPzlJuywvSrMaS kQpUUnrg1fh0TuAjj94TqPlmC6y8EuP0yl6IlMlYJrkmJiEaG1BxslIaj/vpOLMVuTc6 YqGNbvoaoJUgX7yeMQEfPjg/cApS2lSTB71Hx5OWgx9q3UzZKFPS1bDKk26g3VX5ym9F h19t9xuS65N2pxuQJ5rlEO+4KKWutH0xPwQoya9cz76C5b+ixdp3eq6pdUxp3+ShwEe/ o0Yw== X-Gm-Message-State: APzg51DOmSxSmpJGETON4zk0rou8F46NHlJ93oBuvMLDSxLLkbc418El hXkg5xfhLbdOk3AG7vbDCQ7w+JFH X-Google-Smtp-Source: ANB0VdYTT9zV4S5czoP0bHIDUrHh3IOhTieoNWonuCugXU8Zz32+jkKF3V92zzeEenkORVjHM9Mk0Q== X-Received: by 2002:a50:94c4:: with SMTP id t4-v6mr88059eda.306.1536179914010; Wed, 05 Sep 2018 13:38:34 -0700 (PDT) Received: from smtp.gmail.com ([201.87.240.102]) by smtp.gmail.com with ESMTPSA id d35-v6sm1565388eda.25.2018.09.05.13.38.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Sep 2018 13:38:33 -0700 (PDT) Date: Wed, 5 Sep 2018 17:38:27 -0300 From: Rodrigo Siqueira To: Petri Latvala , Arkadiusz Hiler Message-ID: <20180905203827.n7vpugbs6bjvijpg@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180716 Subject: [Intel-gfx] [PATCH i-g-t v2] Add support for forcing specific module 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: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org 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. Changes since V1: Petri: - Use an environment variable instead of command line - Refactor the loop in __search_and_open to accept forced module - Don't try to load kernel modules Signed-off-by: Rodrigo Siqueira --- lib/drmtest.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- lib/drmtest.h | 2 ++ lib/igt_core.c | 5 +++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/lib/drmtest.c b/lib/drmtest.c index bfa2e0f0..6e35d1be 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -123,6 +123,36 @@ 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 (!strcmp(name, "")) { + igt_warn("IGT_FORCE_DRIVER flag specified without a value," + "ignoring force option\n"); + return; + } + + igt_info("Attempt to force module %s\n", name); + + 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: @@ -250,8 +280,18 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset) sprintf(name, "%s%u", base, i + offset); fd = open_device(name, chipset); - if (fd != -1) - return fd; + if (fd == -1) + continue; + + // Force module + if (chipset == DRIVER_ANY && forced_driver()) { + if (__is_device(fd, forced_driver())) + return fd; + close(fd); + continue; + } + + return fd; } return -1; 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 23bb858f..8e65b5e3 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -647,6 +647,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,