@@ -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);
+}
@@ -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 */
@@ -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);
}
@@ -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)
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@intel.com> --- 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(-)