lib: extract igt_open_forcewake_handle
PATCH 1/3 lib: extract igt_open_forcewake_handle
... and I immediately regret that I've killed the return value for igt_debugfs_init, since we have callers which need to work without the forcewake stuff, e.g. the reg dumper needs to work without i915 loaded.
Put this new helper to good use in the mmio code and the pm_pc8 testcase.
Cc Paulo Zanoni <[email protected]>
Signed-off-by Daniel Vetter <[email protected]>
--- lib/igt_debugfs.c | 45 ++++++++++++++++++++++++++++++++++++--------- lib/igt_debugfs.h | 1 + lib/intel_mmio.c | 52 +++++----------------------------------------------- tests/pm_pc8.c | 5 +++-- 4 files changed, 45 insertions(+), 58 deletions(-)
lib/igt_debugfs.c +36 -9
@@ -76,13 +76,7 @@* General debugfs helpers */ -/** -* igt_debugfs_init: -* @debugfs: debugfs access structure to initialize -* -* Initializes the debugfs access helper library. -*/ -void igt_debugfs_init (igt_debugfs_t *debugfs) +static bool __igt_debugfs_init (igt_debugfs_t *debugfs) {const char *path ="/sys/kernel/debug" ;struct stat st;
@@ -107,13 +101,24 @@ find_minor:sprintf (debugfs->dri_path + len,"/i915_error_state" );if (stat (debugfs->dri_path, &st) ==0 ) { debugfs->dri_path[len] ='\0' ; -return ; +return true; } } debugfs->dri_path[0 ] ='\0' ; -igt_fail (4 ); +return false; +} + +/** +* igt_debugfs_init: +* @debugfs: debugfs access structure to initialize +* +* Initializes the debugfs access helper library. +*/ +void igt_debugfs_init (igt_debugfs_t *debugfs) +{ +igt_assert (__igt_debugfs_init (debugfs)); }/**
@@ -578,3 +583,25 @@ void igt_enable_prefault(void) {igt_prefault_control (true); } + +/** +* igt_open_forcewake_handle: +* +* This functions opens the debugfs forcewake file and so prevents the GT from +* suspending. The reference is automatically dropped when the is closed. +* +* Returns: The file descriptor of the forcewake handle or -1 if that didn't +* work out. +*/ +int igt_open_forcewake_handle (void ) +{ +igt_debugfs_t debugfs; +int fd; + +if (!__igt_debugfs_init (&debugfs)) +return -1 ; + + fd =igt_debugfs_open (&debugfs,"i915_forcewake_user" ,O_WRONLY ); + +return fd; +}
lib/igt_debugfs.h +1 -0
@@ -154,5 +154,6 @@ void igt_drop_caches_set(uint64_t val);void igt_disable_prefault (void );void igt_enable_prefault (void ); +int igt_open_forcewake_handle (void );#endif /* __IGT_DEBUGFS_H__ */
lib/intel_mmio.c +5 -47
77 lines not on this page · raw message
tests/pm_pc8.c +3 -2
@@ -46,6 +46,7 @@#include "intel_gpu_tools.h" #include "i915_drm.h" #include "igt_kms.h" +#include "igt_debugfs.h" #define MSR_PC8_RES 0x630#define MSR_PC9_RES 0x631
@@ -1009,8 +1010,8 @@ static void debugfs_forcewake_user_subtest(void)disable_all_screens (&ms_data);igt_assert (wait_for_suspended ()); - fd =open ("/sys/kernel/debug/dri/0/i915_forcewake_user" ,O_RDONLY ); -igt_require (fd); + fd =igt_open_forcewake_handle (); +igt_require (fd >=0 );if (has_runtime_pm) {igt_assert (wait_for_active ());
Signature · 1 line
1.8.4.rc3
PATCH 2/3 lib/igt_core: add printf attribute to igt_vlog
I didn't know that this also works for the varargs versions of format strings. But gcc was kind enough to let me know.
Signed-off-by Daniel Vetter <[email protected]>
--- lib/igt_core.h | 1 + 1 file changed, 1 insertion(+)
lib/igt_core.h +1 -0
@@ -389,6 +389,7 @@ enum igt_log_level { }; __attribute__((format (printf,2 ,3 )))void igt_log (enum igt_log_level level,const char *format, ...); +__attribute__((format (printf,2 ,0 )))void igt_vlog (enum igt_log_level level,const char *format,va_list args);/**
Signature · 1 line
1.8.4.rc3
PATCH 3/3 tests/drv_suspend: new forcewake subtest
In reply to Daniel VetterI suspect that currently we have an issue in there with the runtime PM refcounting, but silly me developed this on a machine with runtime PM support ...
Cc Chris Wilson <[email protected]>
Signed-off-by Daniel Vetter <[email protected]>
--- tests/drv_suspend.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
tests/drv_suspend.c +15 -0
@@ -37,6 +37,7 @@#include "drm.h" #include "i915_drm.h" #include "drmtest.h" +#include "igt_debugfs.h" #define OBJECT_SIZE (16*1024*1024)
@@ -145,6 +146,17 @@ test_sysfs_reader(void)igt_stop_helper (&reader); } +static void +test_forcewake (void ) +{ +int fw_fd; + + fw_fd =igt_open_forcewake_handle (); +igt_assert (fw_fd >=0 ); +igt_system_suspend_autoresume (); +close (fw_fd); +} +int fd; igt_main
@@ -166,6 +178,9 @@ igt_main igt_subtest("sysfs-reader")test_sysfs_reader (); + igt_subtest("forcewake") +test_forcewake (); +igt_fixture close (fd ); }
Signature · 1 line
1.8.4.rc3