From patchwork Mon May 18 15:35:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 6430031 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4EDCBC0432 for ; Mon, 18 May 2015 15:35:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 70E3D205E7 for ; Mon, 18 May 2015 15:35:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 86D5120571 for ; Mon, 18 May 2015 15:35:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E94FF6E4BE; Mon, 18 May 2015 08:35:52 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B26E6E4BE for ; Mon, 18 May 2015 08:35:52 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 18 May 2015 08:35:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,453,1427785200"; d="scan'208";a="495100151" Received: from ideak-desk.fi.intel.com ([10.237.72.74]) by FMSMGA003.fm.intel.com with ESMTP; 18 May 2015 08:35:50 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Mon, 18 May 2015 18:35:37 +0300 Message-Id: <1431963339-23914-5-git-send-email-imre.deak@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1431963339-23914-1-git-send-email-imre.deak@intel.com> References: <1431963339-23914-1-git-send-email-imre.deak@intel.com> Subject: [Intel-gfx] [PATCH 5/7] tests/pm_rc6_residency: remove redundant idle loops X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 Currently the test runs a separate idle loop when reading out each RC6 counter. But there is no need for this, we can have a signle idle loop and read out all the counters at once. This prepares for an upcoming patch where we need to consider the RC6P and RC6PP counters as well when checking RC6. Signed-off-by: Imre Deak --- tests/pm_rc6_residency.c | 49 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/tests/pm_rc6_residency.c b/tests/pm_rc6_residency.c index 276fd41..7c89362 100644 --- a/tests/pm_rc6_residency.c +++ b/tests/pm_rc6_residency.c @@ -82,26 +82,18 @@ static unsigned long get_rc6_enabled_mask(void) static int read_rc6_residency(const char *name_of_rc6_residency) { - unsigned int i; + unsigned int residency; const int device = drm_get_card(); char *path ; int ret; - int value[2]; - /* For some reason my ivb isn't idle even after syncing up with the gpu. - * Let's add a sleept just to make it happy. */ - sleep(5); - - for(i = 0; i < 2; i++) - { - sleep(SLEEP_DURATION / 1000); - ret = asprintf(&path, "/sys/class/drm/card%d/power/%s_residency_ms",device,name_of_rc6_residency); - igt_assert_neq(ret, -1); - value[i] = readit(path); - } + ret = asprintf(&path, "/sys/class/drm/card%d/power/%s_residency_ms", + device, name_of_rc6_residency); + igt_assert_neq(ret, -1); + residency = readit(path); free(path); - return value[1] - value[0]; + return residency; } static void residency_accuracy(unsigned int diff, @@ -117,8 +109,8 @@ static void residency_accuracy(unsigned int diff, "Sysfs RC6 residency counter is inaccurate.\n"); } -static void measure_residencies(int devid, unsigned int rc6_mask, - struct residencies *res) +static void read_residencies(int devid, unsigned int rc6_mask, + struct residencies *res) { if (rc6_mask & RC6_ENABLED) res->rc6 = read_rc6_residency("rc6"); @@ -134,6 +126,31 @@ static void measure_residencies(int devid, unsigned int rc6_mask, res->rc6pp = read_rc6_residency("rc6pp"); } +static void measure_residencies(int devid, unsigned int rc6_mask, + struct residencies *res) +{ + struct residencies start = { }; + struct residencies end = { }; + + if (!rc6_mask) + return; + + /* + * For some reason my ivb isn't idle even after syncing up with the gpu. + * Let's add a sleep just to make it happy. + */ + sleep(8); + + read_residencies(devid, rc6_mask, &start); + sleep(SLEEP_DURATION / 1000); + read_residencies(devid, rc6_mask, &end); + + res->rc6 = end.rc6 - start.rc6; + res->rc6p = end.rc6p - start.rc6p; + res->rc6pp = end.rc6pp - start.rc6pp; + res->media_rc6 = end.media_rc6 - start.media_rc6; +} + igt_main { unsigned int rc6_mask;