igt: Move read_rc6_residency function to lib
PATCH 1/2 igt: Move read_rc6_residency function to lib
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.
--- 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(-)
lib/igt_aux.c +8 -0
@@ -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); +}
lib/igt_aux.h +5 -0
@@ -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 */
tests/gem_mocs_settings.c +2 -8
@@ -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); }
tests/pm_rc6_residency.c +4 -15
@@ -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 )
Signature · 6 lines
2.13.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 tests/drv_suspend: Add subtests to check that forcewake is kept after resume
In some cases we observed that forcewake isn't kept after resume and checking RC6 residency is a simple way to verify that. If forcewake is kept after resume residency should be constant.
--- tests/drv_suspend.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-)
tests/drv_suspend.c +32 -4
@@ -36,6 +36,9 @@#include <errno.h> #include <sys/stat.h> #include <sys/ioctl.h> +#include "igt_sysfs.h" +#include "igt_aux.h" +#include <time.h> #include <drm.h>
@@ -160,8 +163,9 @@ test_sysfs_reader(bool hibernate)igt_stop_helper (&reader); } +#define SLEEP_DURATION 3static void -test_forcewake (int fd,bool hibernate) +test_forcewake (int fd,bool hibernate,bool residency) {int fw_fd;
@@ -174,8 +178,26 @@ test_forcewake(int fd, bool hibernate)else igt_system_suspend_autoresume (SUSPEND_STATE_MEM ,SUSPEND_TEST_NONE ); +if (residency) + { +int sysfs; +uint32_t residency_pre, residency_post; -close (fw_fd); + sysfs =igt_sysfs_open (fd,NULL ); +igt_assert_lte (0 , sysfs); +sleep (1 );// time to fully resume + +// forcewake should keep residency constant after resume + residency_pre =read_residency (sysfs,"rc6" ); +sleep (SLEEP_DURATION ); + residency_post =read_residency (sysfs,"rc6" ); + +igt_assert_eq (residency_pre, residency_post); + +close (sysfs); + } + +close (fw_fd); }int fd;
@@ -200,7 +222,10 @@ igt_maintest_sysfs_reader (false); igt_subtest("forcewake") -test_forcewake (fd, false); +test_forcewake (fd, false, false); + + igt_subtest("rc6-forcewake") +test_forcewake (fd, false, true); igt_subtest("fence-restore-tiled2untiled-hibernate")test_fence_restore (fd, true, true);
@@ -215,7 +240,10 @@ igt_maintest_sysfs_reader (true); igt_subtest("forcewake-hibernate") -test_forcewake (fd, true); +test_forcewake (fd, true, false); + + igt_subtest("rc6-forcewake-hibernate") +test_forcewake (fd, true, true);igt_fixture close (fd );
Signature · 6 lines
2.13.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 2/2] tests/drv_suspend: Add subtests to check that forcewake is kept after resume
Quoting Ewelina Musial (2017-07-25 16:26:09)
Quoted 40 lines
In some cases we observed that forcewake isn't kept after resume and checking RC6 residency is a simple way to verify that. If forcewake is kept after resume residency should be constant.
Cc Lukasz Fiedorowicz <[email protected]>Cc Radoslaw Szwichtenberg <[email protected]>Cc Michal Winiarski <[email protected]>Signed-off-by Ewelina Musial <[email protected]>--- tests/drv_suspend.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-)tests/drv_suspend.c +5
-1@@ -36,6 +36,9 @@#include <errno.h> #include <sys/stat.h> #include <sys/ioctl.h> +#include "igt_sysfs.h" +#include "igt_aux.h" +#include <time.h> #include <drm.h> @@ -160,8 +163,9 @@ test_sysfs_reader(bool hibernate)igt_stop_helper (&reader); } +#define SLEEP_DURATION 3static void -test_forcewake (int fd,bool hibernate) +test_forcewake (int fd,bool hibernate,bool residency) {int fw_fd;@@ -174,8 +178,26 @@ test_forcewake(int fd, bool hibernate)else igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
tests/drv_suspend.c test_forcewake(int fd, bool hibernate) · line 188
Quoted 10 lines
tests/drv_suspend.c +7
-1SUSPEND_TEST_NONE); +if (residency) + { +int sysfs; +uint32_t residency_pre, residency_post; -close (fw_fd); + sysfs =igt_sysfs_open (fd,NULL ); +igt_assert_lte (0 , sysfs); +sleep (1 );// time to fully resume
rc6 is not universal, failing just because it is not supported after suspending/hibernate does not make for happy users.
You have the power to add additional sanity checks to the kernel and report the failure via close() without resorting to indirect checks and fragile assumptions.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 5 lines · Ewelina Musial
Gem_mocs_settingsandpm_rc6_residencytests are defining the same functionality to read residency from sysfs. Moving that function tolib/igt_auxand updating tests.Signed-off-by Ewelina Musial <[email protected]>
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx