From patchwork Sat Jul 7 23:25:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10512983 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 41AC5600CA for ; Sat, 7 Jul 2018 23:25:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DB4C288E1 for ; Sat, 7 Jul 2018 23:25:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F637288EA; Sat, 7 Jul 2018 23:25:14 +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 ABEE4288E1 for ; Sat, 7 Jul 2018 23:25:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 21E566E369; Sat, 7 Jul 2018 23:25:13 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qt0-x242.google.com (mail-qt0-x242.google.com [IPv6:2607:f8b0:400d:c0d::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 004886E368; Sat, 7 Jul 2018 23:25:11 +0000 (UTC) Received: by mail-qt0-x242.google.com with SMTP id z6-v6so12816096qti.2; Sat, 07 Jul 2018 16:25:11 -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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=FApvTLt4nnKzPsLpiQa1+UaUpCoUo5RoTH4Ugo2swYA=; b=Zss3n9o53U7Eep0k5gP+rr3YTfIsJ1AKTX2WHKY/uSXI8ybHV5TS1wzjyTWoK9u2vt PGBXUuWmBRJMjs/L6WxbGi+OO/96rAizdUMYbp33cN9UZQCayXz8yJKlEmJiQbBb77nc VJJzyF+IP6MWT5DQEbNzHJz50yMWdA3X/iRlmMldzwEG36lgp9E5pLza+2jdr4CS5WiH 6rnjk7FcaeiFbj5/K3LB5t80ff/CQH8LKk56a0bQZhe5D9EiuefAOmN9ShOoNcX3qSXl +IHVe8+/Qmlr0UphQ/z+O0Em1+DLE0Ik9ME1fBCSIQgFjUkz9VUVir921J1rRHwoqwzx yT5Q== X-Gm-Message-State: APt69E2BaUiOxQzzHBrElOlEaNIfjq6RfC/HrsMaMhyY3zyc53J+9MUC CNjvP2/62fwnzQwQJmJ2LsivJQ== X-Google-Smtp-Source: AAOMgpf13pyj97VlmGZhbTkAUqx/kMyjaqaRcQe6Fo/Jw3jHa2LsJ6taKgiC3G+0oEKvgH9YaLJHuQ== X-Received: by 2002:a0c:b525:: with SMTP id d37-v6mr13424648qve.34.1531005911127; Sat, 07 Jul 2018 16:25:11 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id q83-v6sm6456332qki.67.2018.07.07.16.25.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 16:25:10 -0700 (PDT) Date: Sat, 7 Jul 2018 20:25:07 -0300 From: Rodrigo Siqueira To: Petri Latvala , Arkadiusz Hiler Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180622 Subject: [Intel-gfx] [PATCH i-g-t 2/2] 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 module indicated via command line. The force command expects a module name which will be used on the target test (changing the standard behavior). Signed-off-by: Rodrigo Siqueira --- lib/drmtest.c | 33 +++++++++++++++++++++++++++------ lib/igt_core.c | 23 +++++++++++++++++++++++ lib/igt_core.h | 4 ++++ scripts/run-tests.sh | 4 +++- 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/lib/drmtest.c b/lib/drmtest.c index eee733eb..a77e2231 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -247,6 +247,20 @@ static int __open_device(const char *base, int offset, unsigned int chipset) if (chipset & DRIVER_AMDGPU && is_amd_device(fd)) return fd; + // Force options + if (get_target_module() && chipset == DRIVER_ANY) { + if (__is_device(fd, get_target_module())) { + return fd; + } + else { + memset(name, 0, sizeof(name)); + __get_drm_device_name(fd, name); + close(fd); + igt_kmod_unload(name, 0); + return -1; + } + } + /* Only VGEM-specific tests should be run on VGEM */ if (chipset == DRIVER_ANY && !is_vgem_device(fd)) return fd; @@ -260,6 +274,7 @@ static int __open_device(const char *base, int offset, unsigned int chipset) static int __open_driver(const char *base, int offset, unsigned int chipset) { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + const char* target; static const struct module { unsigned int bit; const char *module; @@ -278,13 +293,19 @@ static int __open_driver(const char *base, int offset, unsigned int chipset) if (fd != -1) return fd; + target = get_target_module(); + pthread_mutex_lock(&mutex); - for (const struct module *m = modules; m->module; m++) { - if (chipset & m->bit) { - if (m->modprobe) - m->modprobe(m->module); - else - modprobe(m->module); + if (target) { + modprobe(target); + } else { + for (const struct module *m = modules; m->module; m++) { + if (chipset & m->bit) { + if (m->modprobe) + m->modprobe(m->module); + else + modprobe(m->module); + } } } pthread_mutex_unlock(&mutex); diff --git a/lib/igt_core.c b/lib/igt_core.c index 5092a3f0..ee085e2a 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -286,6 +286,7 @@ enum { OPT_DESCRIPTION, OPT_DEBUG, OPT_INTERACTIVE_DEBUG, + OPT_FORCE_MODULE, OPT_HELP = 'h' }; @@ -303,6 +304,23 @@ static pthread_mutex_t log_buffer_mutex = PTHREAD_MUTEX_INITIALIZER; GKeyFile *igt_key_file; #endif +char *target_module = NULL; + +void set_target_module(char *target) +{ + if (!target) + igt_warn("No module specified, keep default behaviour"); + + target_module = target; +} + +const char *get_target_module(void) +{ + if (target_module) + return target_module; + return NULL; +} + char *igt_frame_dump_path; const char *igt_test_name(void) @@ -555,6 +573,7 @@ static void print_usage(const char *help_str, bool output_on_stderr) " --debug[=log-domain]\n" " --interactive-debug[=domain]\n" " --help-description\n" + " --force-module \n" " --help\n"); if (help_str) fprintf(f, "%s\n", help_str); @@ -666,6 +685,7 @@ static int common_init(int *argc, char **argv, {"debug", optional_argument, 0, OPT_DEBUG}, {"interactive-debug", optional_argument, 0, OPT_INTERACTIVE_DEBUG}, {"help", 0, 0, OPT_HELP}, + {"force-module", required_argument, 0, OPT_FORCE_MODULE}, {0, 0, 0, 0} }; char *short_opts; @@ -763,6 +783,9 @@ static int common_init(int *argc, char **argv, print_test_description(); ret = -1; goto out; + case OPT_FORCE_MODULE: + set_target_module(strdup(optarg)); + break; case OPT_HELP: print_usage(help_str, false); ret = -1; diff --git a/lib/igt_core.h b/lib/igt_core.h index bf8cd66c..6d635ebd 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -50,6 +50,10 @@ extern const char* __igt_test_description __attribute__((weak)); extern bool __igt_plain_output; extern char *igt_frame_dump_path; +extern char *target_module; +void set_target_module(char *target); +const char *get_target_module(void); + /** * IGT_TEST_DESCRIPTION: * @str: description string diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh index 4209dd8c..29aa50a8 100755 --- a/scripts/run-tests.sh +++ b/scripts/run-tests.sh @@ -80,6 +80,7 @@ function print_help { echo " (can be used more than once)" echo " -T run tests listed in testlist" echo " (overrides -t and -x)" + echo " -f force specific module load" echo " -v enable verbose mode" echo " -x exclude tests that match the regular expression" echo " (can be used more than once)" @@ -91,7 +92,7 @@ function print_help { echo "Useful patterns for test filtering are described in the API documentation." } -while getopts ":dhlr:st:T:vx:Rn" opt; do +while getopts ":dhlr:st:T:m:vx:Rn" opt; do case $opt in d) download_piglit; exit ;; h) print_help; exit ;; @@ -100,6 +101,7 @@ while getopts ":dhlr:st:T:vx:Rn" opt; do s) SUMMARY="html" ;; t) FILTER="$FILTER -t $OPTARG" ;; T) FILTER="$FILTER --test-list $OPTARG" ;; + f) FILTER="$FILTER --force-module $OPTARG" ;; v) VERBOSE="-v" ;; x) EXCLUDE="$EXCLUDE -x $OPTARG" ;; R) RESUME="true" ;;