From patchwork Fri Jan 10 21:12:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jeff.mcgee@intel.com X-Patchwork-Id: 3468011 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 15B479F374 for ; Fri, 10 Jan 2014 21:06:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 518992012E for ; Fri, 10 Jan 2014 21:06:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7ABAF20121 for ; Fri, 10 Jan 2014 21:06:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 243DE106AE9; Fri, 10 Jan 2014 13:06:34 -0800 (PST) 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 ESMTP id 3D1C3105792 for ; Fri, 10 Jan 2014 13:06:30 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 10 Jan 2014 13:06:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,640,1384329600"; d="scan'208";a="456898931" Received: from jeffdesk.fso.intel.com ([10.5.53.1]) by fmsmga001.fm.intel.com with ESMTP; 10 Jan 2014 13:06:29 -0800 From: jeff.mcgee@intel.com To: intel-gfx@lists.freedesktop.org Date: Fri, 10 Jan 2014 15:12:33 -0600 Message-Id: <1389388353-29980-5-git-send-email-jeff.mcgee@intel.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1389388353-29980-1-git-send-email-jeff.mcgee@intel.com> References: <1389388353-29980-1-git-send-email-jeff.mcgee@intel.com> Subject: [Intel-gfx] [PATCH 4/4] pm_rps: Use igt exit handler for restore X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeff McGee Signed-off-by: Jeff McGee --- tests/pm_rps.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/tests/pm_rps.c b/tests/pm_rps.c index c968ecb..7c739b6 100644 --- a/tests/pm_rps.c +++ b/tests/pm_rps.c @@ -36,14 +36,6 @@ static bool verbose = false; static int origmin, origmax; -#define restore_assert(COND) do { \ - if (!(COND)) { \ - writeval(stuff[MIN].filp, origmin); \ - writeval(stuff[MAX].filp, origmax); \ - igt_assert(0); \ - } \ -} while (0); - static const char sysfs_base_path[] = "/sys/class/drm/card%d/gt_%s_freq_mhz"; enum { CUR, @@ -112,15 +104,15 @@ static void setfreq(int val) static void checkit(void) { - restore_assert(fmin <= fmax); - restore_assert(fcur <= fmax); - restore_assert(fmin <= fcur); - restore_assert(frpn <= fmin); - restore_assert(fmax <= frp0); - restore_assert(frp1 <= frp0); - restore_assert(frpn <= frp1); - restore_assert(frp0 != 0); - restore_assert(frp1 != 0); + igt_assert(fmin <= fmax); + igt_assert(fcur <= fmax); + igt_assert(fmin <= fcur); + igt_assert(frpn <= fmin); + igt_assert(fmax <= frp0); + igt_assert(frp1 <= frp0); + igt_assert(frpn <= frp1); + igt_assert(frp0 != 0); + igt_assert(frp1 != 0); } static void dumpit(void) @@ -134,6 +126,16 @@ static void dumpit(void) printf("\n"); } +static void pm_rps_exit_handler(int sig) +{ + if (origmin > fmax) { + writeval(stuff[MAX].filp, origmax); + writeval(stuff[MIN].filp, origmin); + } else { + writeval(stuff[MIN].filp, origmin); + writeval(stuff[MAX].filp, origmax); + } +} igt_simple_main { @@ -164,6 +166,8 @@ igt_simple_main origmin = fmin; origmax = fmax; + igt_install_exit_handler(pm_rps_exit_handler); + if (verbose) printf("Original min = %d\nOriginal max = %d\n", origmin, origmax); @@ -174,11 +178,11 @@ igt_simple_main setfreq(origmin); if (verbose) dumpit(); - restore_assert(fcur == fmin); + igt_assert(fcur == fmin); setfreq(origmax); if (verbose) dumpit(); - restore_assert(fcur == fmax); + igt_assert(fcur == fmax); checkit(); /* And some errors */