From patchwork Mon Jul 23 11:46:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10540029 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 6358313BB for ; Mon, 23 Jul 2018 11:47:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50D6328640 for ; Mon, 23 Jul 2018 11:47:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44BF22866C; Mon, 23 Jul 2018 11:47:11 +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 DCDB028640 for ; Mon, 23 Jul 2018 11:47:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4FD676E21C; Mon, 23 Jul 2018 11:47:10 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by gabe.freedesktop.org (Postfix) with ESMTPS id D8FEF6E192 for ; Mon, 23 Jul 2018 11:47:05 +0000 (UTC) Received: by mail-wr1-x42b.google.com with SMTP id j5-v6so380808wrr.8 for ; Mon, 23 Jul 2018 04:47:05 -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=zQzdnYjMWZTU19Shzp+t7xAR5DS37sypQWlgAYM7uXw=; b=oAKYXTrZsj5e3IWJe+g6tY+RIAWMYCty2HHDmQCuMfmx/a3LXCvD54motoV5OfHzVg WWblymxAj+DZpzsSLHhQBg/N8ZCV4lWHSu8RhXBH+9tssyR1czacNZ7qwYq76lEOeftb QisQOZJdQb+oyZfI7k7Km2LUmJCfjQafcQNPiN5chNQpK+mCAzvKsVKedQoL8ytIoZKp qKAzbZJBqZcY6maaO0q8dv4UPbLn56lJB6yZk8SvLyf9Pg9I5arIvQEePQ8DgSdOB4/h dM0yJHyCx5AutmGq84F3Vd2PHo+UFPlai12f0SGh6wH0zbZ4qTx2mRkgPEhJNi/6Qv5N SQ9A== X-Gm-Message-State: AOUpUlEWsOAl4a1hYtZis/LLHO9Tlic/q2GUK0r9tKgrIIUs6ytujiak wVkiYVeAOev0MhY5YsKjJyeCKw== X-Google-Smtp-Source: AAOMgpeuzEny6EsVRsbQ/Udv7awJRtQAAy3v2117EFrC0M7MJLkAe8gnXZSg9omlPxFgTqjz5upW7A== X-Received: by 2002:adf:f60a:: with SMTP id t10-v6mr7538764wrp.170.1532346424581; Mon, 23 Jul 2018 04:47:04 -0700 (PDT) Received: from localhost.localdomain ([95.146.151.144]) by smtp.gmail.com with ESMTPSA id l14-v6sm23658407wrw.65.2018.07.23.04.47.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jul 2018 04:47:04 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Mon, 23 Jul 2018 12:46:57 +0100 Message-Id: <20180723114658.13025-3-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723114658.13025-1-tvrtko.ursulin@linux.intel.com> References: <20180723114658.13025-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH i-g-t 3/4] lib/igt_pm: Export function to restore runtime PM status 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 In cases when runtime PM is enabled only from individual subtests and not whole tests it is usable to be able to restore the old runtime PM config and so avoid running subsequent subtests in an unexpected environment. Signed-off-by: Tvrtko Ursulin --- lib/igt_pm.c | 41 +++++++++++++++++++++++++++++++++++++++++ lib/igt_pm.h | 1 + 2 files changed, 42 insertions(+) diff --git a/lib/igt_pm.c b/lib/igt_pm.c index a4c0cf335f6d..a861055d382b 100644 --- a/lib/igt_pm.c +++ b/lib/igt_pm.c @@ -106,6 +106,23 @@ static int __igt_pm_audio_restore_runtime_pm(void) return 0; } +static void igt_pm_audio_restore_runtime_pm(void) +{ + int ret; + + if (!__igt_pm_audio_runtime_power_save[0]) + return; + + igt_debug("Restoring audio power management to '%s' and '%s'\n", + __igt_pm_audio_runtime_power_save, + __igt_pm_audio_runtime_control); + + ret = __igt_pm_audio_restore_runtime_pm(); + if (ret) + igt_warn("Failed to restore runtime audio PM! (errno=%d)\n", + ret); +} + static void __igt_pm_audio_runtime_exit_handler(int sig) { __igt_pm_audio_restore_runtime_pm(); @@ -393,6 +410,30 @@ static int __igt_restore_runtime_pm(void) return 0; } +/** + * 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 ret; + + if (pm_status_fd < 0) + return; + + igt_debug("Restoring runtime PM management to '%s' and '%s'\n", + __igt_pm_runtime_autosuspend, + __igt_pm_runtime_control); + + ret = __igt_restore_runtime_pm(); + if (ret) + igt_warn("Failed to restore runtime PM! (errno=%d)\n", ret); + + igt_pm_audio_restore_runtime_pm(); +} + 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);