From patchwork Fri Jul 20 09:42:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10536381 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 4B1906053F for ; Fri, 20 Jul 2018 09:43:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 129622927D for ; Fri, 20 Jul 2018 09:43:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 069DE2970D; Fri, 20 Jul 2018 09:43: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 A69832927D for ; Fri, 20 Jul 2018 09:43:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E03EF6EF3D; Fri, 20 Jul 2018 09:43:03 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 50C836EF3B for ; Fri, 20 Jul 2018 09:43:02 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id s9-v6so8875822wmh.3 for ; Fri, 20 Jul 2018 02:43:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nFCYKjM6tRpze83aEh9r1av+JCbba8PxYh2gfNzL/pw=; b=d6a4c2baXyyzgOCAE3LmkfLb8okeXGTBaiqw7aOQcMIa9CpinddRFA/1aP6pkwFjd5 UvEgS4X6Ab6NnspXHS4FRynNmpyBXOVDhWLF1VBZ0hKD4DZT9awY/uN4n6tsmvEBFsUr HcC2SiCJ1U+vLxnHdH1TzMQmll2jQZaELlTnGx/2kq6PhdkL9BXTxdg63qk6+1wXpPio mUImHZmVwUzlOCHQAisrc0PCLYoDX4MuUE/FqZwqY00tcZ4nkfKeADnFZ25puUyOoYNY WWw3uYAKOCaeDnEW/+yWsLXC35L9nAMHVt/p3AnkcvuNxOehCycWSA5j2U0um9NgJGSV QMcg== X-Gm-Message-State: AOUpUlGQ3OobrAtJ1m8mb/AvCJSHnH4A7KlK2P06hrloWbi45mWRvCAp r8WBnS5GY32nmAL/q4tvjiSq8CAiLuI= X-Google-Smtp-Source: AAOMgpe5ulwWLYWRrKpz4HzgiMz/eaRxZytMqkpHJZMej33htPwW772aW/auA3GgR1eYxMMeZe1Mew== X-Received: by 2002:a1c:5f82:: with SMTP id t124-v6mr1083703wmb.14.1532079780867; Fri, 20 Jul 2018 02:43:00 -0700 (PDT) Received: from localhost.localdomain ([95.146.151.144]) by smtp.gmail.com with ESMTPSA id j9-v6sm4668350wrv.5.2018.07.20.02.42.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Jul 2018 02:43:00 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Fri, 20 Jul 2018 10:42:55 +0100 Message-Id: <20180720094255.22668-1-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <153201892009.24818.7035937748047758201@skylake-alporthouse-com> References: <153201892009.24818.7035937748047758201@skylake-alporthouse-com> Subject: [Intel-gfx] [PATCH i-g-t v2] tests/perf_pmu: Restore runtime PM at subtest exit 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 MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin Restore runtime PM state (via a newly added library function) when the test which sets it up exit. This was we avoid running all subsequent sub- tests in the aggressive runtime PM mode. v2: * Skip double restore. (Chris Wilson) * Close previously leaked fd. Signed-off-by: Tvrtko Ursulin Reviewed-by: Chris Wilson --- lib/igt_pm.c | 20 ++++++++++++++++++-- lib/igt_pm.h | 1 + tests/perf_pmu.c | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/igt_pm.c b/lib/igt_pm.c index 8ac132269d79..512ad9b31951 100644 --- a/lib/igt_pm.c +++ b/lib/igt_pm.c @@ -291,16 +291,24 @@ void igt_pm_restore_sata_link_power_management(int8_t *pm_data) free(file_name); } #define POWER_DIR "/sys/devices/pci0000:00/0000:00:02.0/power" -/* We just leak this on exit ... */ int pm_status_fd = -1; static char __igt_pm_runtime_autosuspend[64]; static char __igt_pm_runtime_control[64]; -static void __igt_pm_runtime_exit_handler(int sig) +/** + * igt_restore_runtime_pm: + * + * Restores the runtime PM configuration as it was before the call to + * igt_setup_runtime_pm. + */ +void igt_restore_runtime_pm(void) { int fd; + if (pm_status_fd < 0) + return; + igt_debug("Restoring runtime management to '%s' and '%s'\n", __igt_pm_runtime_autosuspend, __igt_pm_runtime_control); @@ -324,6 +332,14 @@ static void __igt_pm_runtime_exit_handler(int sig) igt_warn("Failed to restore runtime pm control to '%s'\n", __igt_pm_runtime_control); close(fd); + + close(pm_status_fd); + pm_status_fd = -1; +} + +static void __igt_pm_runtime_exit_handler(int sig) +{ + igt_restore_runtime_pm(); } /** diff --git a/lib/igt_pm.h b/lib/igt_pm.h index eced39f8801a..10cc6794e4e7 100644 --- a/lib/igt_pm.h +++ b/lib/igt_pm.h @@ -47,6 +47,7 @@ enum igt_runtime_pm_status { }; bool igt_setup_runtime_pm(void); +void igt_restore_runtime_pm(void); enum igt_runtime_pm_status igt_get_runtime_pm_status(void); bool igt_wait_for_pm_status(enum igt_runtime_pm_status status); diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c index a1d36ac4fa9d..9a20abb6b95c 100644 --- a/tests/perf_pmu.c +++ b/tests/perf_pmu.c @@ -1441,6 +1441,9 @@ test_rc6(int gem_fd, unsigned int flags) close(fw); close(fd); + if (flags & TEST_RUNTIME_PM) + igt_restore_runtime_pm(); + assert_within_epsilon(busy - prev, 0.0, tolerance); }