From patchwork Tue Jul 25 14:32:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Musial, Ewelina" X-Patchwork-Id: 9862121 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 10514602B1 for ; Tue, 25 Jul 2017 14:34:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 007C8274D2 for ; Tue, 25 Jul 2017 14:34:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E95C227F8F; Tue, 25 Jul 2017 14:34:19 +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=-4.2 required=2.0 tests=BAYES_00, 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 EEC8C274D2 for ; Tue, 25 Jul 2017 14:34:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2A9266E522; Tue, 25 Jul 2017 14:34:18 +0000 (UTC) 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 ESMTPS id 66EB96E522 for ; Tue, 25 Jul 2017 14:34:17 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2017 07:34:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,411,1496127600"; d="scan'208";a="111791928" Received: from emusial-desk.igk.intel.com ([172.28.171.24]) by orsmga004.jf.intel.com with ESMTP; 25 Jul 2017 07:34:16 -0700 From: Ewelina Musial To: intel-gfx@lists.freedesktop.org Date: Tue, 25 Jul 2017 16:32:25 +0200 Message-Id: <20170725143225.1010-1-ewelina.musial@intel.com> X-Mailer: git-send-email 2.13.3 Subject: [Intel-gfx] [PATCH i-g-t] igt: Move read_rc6_residency function to lib 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-Virus-Scanned: ClamAV using ClamSMTP Gem_mocs_settings and pm_rc6_residency tests are defining the same functionality to read residency from sysfs. Moving that function to lib/igt_aux and updating tests. Signed-off-by: Ewelina Musial --- lib/igt_aux.c | 8 ++++++++ lib/igt_aux.h | 5 +++++ tests/gem_mocs_settings.c | 10 ++-------- tests/pm_rc6_residency.c | 19 ++++--------------- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index 86a213c2..224da4b6 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -1680,3 +1680,11 @@ double igt_stop_siglatency(struct igt_mean *result) return mean; } + +uint32_t read_residency(int dir, const char *name) +{ + char path[128]; + + sprintf(path, "power/%s_residency_ms", name); + return igt_sysfs_get_u32(dir, path); +} diff --git a/lib/igt_aux.h b/lib/igt_aux.h index 499a1679..8cc06f8c 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -386,4 +386,9 @@ static inline bool igt_list_empty(const struct igt_list *list) &pos->member != (head); \ pos = tmp, tmp = igt_list_next_entry(pos, member)) +/** + * Helper to read RC6 and MC6 residencies from sysfs + */ +uint32_t read_residency(int dir, const char *name); + #endif /* IGT_AUX_H */ diff --git a/tests/gem_mocs_settings.c b/tests/gem_mocs_settings.c index 05dfc637..67a52f50 100644 --- a/tests/gem_mocs_settings.c +++ b/tests/gem_mocs_settings.c @@ -328,12 +328,6 @@ static void check_l3cc_registers(int fd, gem_close(fd, dst_handle); } - -static uint32_t rc6_residency(int dir) -{ - return igt_sysfs_get_u32(dir, "power/rc6_residency_ms"); -} - static void rc6_wait(int fd) { int sysfs; @@ -342,8 +336,8 @@ static void rc6_wait(int fd) sysfs = igt_sysfs_open(fd, NULL); igt_assert_lte(0, sysfs); - residency = rc6_residency(sysfs); - igt_require(igt_wait(rc6_residency(sysfs) != residency, 10000, 2)); + residency = read_residency(sysfs, "rc6"); + igt_require(igt_wait(read_residency(sysfs, "rc6") != residency, 10000, 2)); close(sysfs); } diff --git a/tests/pm_rc6_residency.c b/tests/pm_rc6_residency.c index bdb9747a..ac6e019a 100644 --- a/tests/pm_rc6_residency.c +++ b/tests/pm_rc6_residency.c @@ -61,17 +61,6 @@ static unsigned long get_rc6_enabled_mask(void) return rc6_mask; } -static unsigned long read_rc6_residency(const char *name) -{ - unsigned long residency; - char path[128]; - - residency = 0; - sprintf(path, "power/%s_residency_ms", name); - igt_assert(igt_sysfs_scanf(sysfs, path, "%lu", &residency) == 1); - return residency; -} - static void residency_accuracy(unsigned int diff, unsigned int duration, const char *name_of_rc6_residency) @@ -90,17 +79,17 @@ static void read_residencies(int devid, unsigned int rc6_mask, struct residencies *res) { if (rc6_mask & RC6_ENABLED) - res->rc6 = read_rc6_residency("rc6"); + res->rc6 = read_residency(sysfs, "rc6"); if ((rc6_mask & RC6_ENABLED) && (IS_VALLEYVIEW(devid) || IS_CHERRYVIEW(devid))) - res->media_rc6 = read_rc6_residency("media_rc6"); + res->media_rc6 = read_residency(sysfs, "media_rc6"); if (rc6_mask & RC6P_ENABLED) - res->rc6p = read_rc6_residency("rc6p"); + res->rc6p = read_residency(sysfs, "rc6p"); if (rc6_mask & RC6PP_ENABLED) - res->rc6pp = read_rc6_residency("rc6pp"); + res->rc6pp = read_residency(sysfs, "rc6pp"); } static unsigned long gettime_ms(void)