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 <ewelina.musial@xxxxxxxxx> --- 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) -- 2.13.3 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx