PSR IGT Test Fix-ups
cover PSR IGT Test Fix-ups
These patches, along with the kernel series at
https://patchwork.freedesktop.org/series/24049/ allow our PSR IGT tests to run more predictably on HSW, SKL, and KBL. These patches depend on the kernel series in order to run properly. On the systems I have available the following sets of tests run and pass. I expect that tests would also pass on BDW, but I don't have access to a BDW system with a PSR panel. I still see some very sporadic (every few hundred tests executions or so) failures to read the sink CRC on KBL, but it is much less common than what we were seeing in the past.
HSW:
* kms_psr_sink_crc (all)
* kms_frontbuffer_tracking (subtests psr-1p*, my system doesn't have a FBC panel or a DP port)
* kms_fbcon_fbt (subtests psr*)
SKL and KBL:
* kms_psr_sink_crc (all)
* kms_frontbuffer_tracking (subtests psr* and fbcpsr*)
* kms_fbcon_fbt (all)
Jim Bride (5):
tests/kms_psr_sink_crc: Change assert_or_manual() to a macro
lib: Add PSR utility functions to igt library. tests/kms_psr_sink_crc: Refactor to use new PSR library primitives tests/kms_frontbuffer_tracking: Refactor to use IGT PSR library
functions
tests/kms_fbcon_fbt: Refactor to use IGT PSR library functions
lib/Makefile.sources | 2 + lib/igt.h | 1 + lib/igt_psr.c | 195 +++++++++++++++++++++++++++++++++++++++ lib/igt_psr.h | 40 ++++++++ tests/kms_fbcon_fbt.c | 56 ++++------- tests/kms_frontbuffer_tracking.c | 95 ++----------------- tests/kms_psr_sink_crc.c | 74 ++++++++------- 7 files changed, 310 insertions(+), 153 deletions(-) create mode 100644 lib/igt_psr.c create mode 100644 lib/igt_psr.h
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/5 tests/kms_psr_sink_crc: Change assert_or_manual() to a macro
Make assert_or_manual() a macro so that we get accurate line number information when this assertion fails.
--- tests/kms_psr_sink_crc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tests/kms_psr_sink_crc.c +5 -5
@@ -278,11 +278,11 @@ static bool is_green(char *crc) (bh & mask) == 0); } -static void assert_or_manual (bool condition,const char *expected) -{ -igt_debug_manual_check ("no-crc" , expected); -igt_assert (igt_interactive_debug || condition); -} +#define assert_or_manual (condition, expected) \ +do { \ + igt_debug_manual_check("no-crc", expected); \ + igt_assert(igt_interactive_debug || condition); \ +} while (0)static void run_test (data_t *data) {
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/5 lib: Add PSR utility functions to igt library.
In reply to Jim BrideFactor out some code that was replicated in three test utilities into some new IGT library functions so that we are checking PSR status in a consistent fashion across all of our PSR tests.
--- lib/Makefile.sources | 2 + lib/igt.h | 1 + lib/igt_psr.c | 195 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_psr.h | 40 +++++++++++ 4 files changed, 238 insertions(+) create mode 100644 lib/igt_psr.c create mode 100644 lib/igt_psr.h
lib/Makefile.sources +2 -0
@@ -83,6 +83,8 @@ lib_source_list = \ uwildmat/uwildmat.c \ igt_kmod.c \ igt_kmod.h \ + igt_psr.c \ + igt_psr.h \ $(NULL) if HAVE_CHAMELIUM
lib/igt.h +1 -0
@@ -37,6 +37,7 @@#include "igt_gt.h" #include "igt_kms.h" #include "igt_pm.h" +#include "igt_psr.h" #include "igt_stats.h" #include "igt_chamelium.h" #include "instdone.h"
lib/igt_psr.c new file +195 -0
195 lines not on this page · raw message
lib/igt_psr.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Copyright © 2017 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#ifndef IGT_PSR_H +#define IGT_PSR_H + +#define igt_psr_enable () igt_set_module_param_int("enable_psr", 1) +#define igt_psr_disable () igt_set_module_param_int("enable_psr", 0) + +bool igt_psr_sink_support (int fd); +bool igt_psr_source_support (int fd); +bool igt_psr_possible (int fd); +bool igt_psr_active (int fd); +bool igt_psr_await_status (int fd,bool active); +bool igt_psr_enabled (int fd); +void igt_psr_print_status (int fd); +bool igt_psr_valid_connector (drmModeConnectorPtr connector); +bool igt_psr_find_good_mode (drmModeConnectorPtr connector, +drmModeModeInfoPtr *mode); +#endif /* IGT_PSR_H */
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/5 tests/kms_psr_sink_crc: Refactor to use new PSR library primitives
In reply to Jim Bride--- tests/kms_psr_sink_crc.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-)
tests/kms_psr_sink_crc.c +8 -20
@@ -192,35 +192,22 @@ static void fill_render(data_t *data, uint32_t handle, unsigned char color)gem_bo_busy (data->drm_fd, handle); } -static bool psr_possible (data_t *data) +static inline bool psr_possible (data_t *data) { -char buf[512 ]; - -igt_debugfs_read (data->drm_fd,"i915_edp_psr_status" , buf); -return running_with_psr_disabled || -strstr (buf,"Sink_Support: yes\n" ); +igt_psr_sink_support (data->drm_fd); } -static bool psr_active (data_t *data) +static inline bool psr_active (data_t *data) { -char buf[512 ]; - -igt_debugfs_read (data->drm_fd,"i915_edp_psr_status" , buf); -return running_with_psr_disabled || -strstr (buf,"HW Enabled & Active bit: yes\n" ); +igt_psr_active (data->drm_fd); } -static bool wait_psr_entry (data_t *data) +static inline bool wait_psr_entry (data_t *data) { -int timeout =5 ; -while (timeout--) { -if (psr_active (data)) -return true; -sleep (1 ); - } -return false; +return running_with_psr_disabled || +igt_psr_await_status (data->drm_fd, true); }static void get_sink_crc (data_t *data,char *crc) {
@@ -517,6 +504,7 @@ int main(int argc, char *argv[])drm_intel_bufmgr_gem_enable_reuse (data.bufmgr);display_init (&data); +igt_skip_on (!psr_possible (&data)); } igt_subtest("psr_basic") {
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/5 tests/kms_frontbuffer_tracking: Refactor to use IGT PSR library functions
In reply to Jim Bride--- tests/kms_frontbuffer_tracking.c | 95 +++++----------------------------------- 1 file changed, 10 insertions(+), 85 deletions(-)
tests/kms_frontbuffer_tracking.c +10 -85
@@ -327,28 +327,6 @@ drmModeModeInfo std_1024_mode = { .name = "Custom 1024x768", }; -static drmModeModeInfoPtr get_connector_smallest_mode (drmModeConnectorPtr c) -{ -int i; -drmModeModeInfoPtr smallest =NULL ; - -for (i =0 ; i < c->count_modes; i++) { -drmModeModeInfoPtr mode = &c->modes[i]; - -if (!smallest) - smallest = mode; - -if (mode->hdisplay * mode->vdisplay < - smallest->hdisplay * smallest->vdisplay) - smallest = mode; - } - -if (c->connector_type == DRM_MODE_CONNECTOR_eDP) - smallest = &std_1024_mode; - -return smallest; -} -static drmModeConnectorPtr get_connector (uint32_t id) {int i;
@@ -421,30 +399,6 @@ static void init_mode_params(struct modeset_params *params, uint32_t crtc_id, params->sprite.h =64 ; } -static bool connector_get_mode (drmModeConnectorPtr c,drmModeModeInfoPtr *mode) -{ - *mode =NULL ; - -if (c->connection !=DRM_MODE_CONNECTED || !c->count_modes) -return false; - -if (c->connector_type == DRM_MODE_CONNECTOR_eDP && opt.no_edp) -return false; - -if (opt.small_modes) - *mode =get_connector_smallest_mode (c); -else - *mode = &c->modes[0 ]; - -/* On HSW the CRC WA is so awful that it makes you think everything is -* bugged. */ -if (IS_HASWELL (intel_get_drm_devid (drm.fd)) && - c->connector_type == DRM_MODE_CONNECTOR_eDP) - *mode = &std_1024_mode; - -return true; -} -static bool connector_supports_pipe_a (drmModeConnectorPtr connector) {int i;
@@ -473,7 +427,7 @@ static bool find_connector(bool edp_only, bool pipe_a, uint32_t forbidden_id,continue ;if (c->connector_id == forbidden_id)continue ; -if (!connector_get_mode (c, &mode)) +if (!igt_psr_find_good_mode (c, &mode))continue ; *ret_connector = c;
@@ -804,23 +758,6 @@ static void fbc_print_status(void)igt_info ("FBC status:\n%s\n" , buf); } -static bool psr_is_enabled (void ) -{ -char buf[256 ]; - -debugfs_read ("i915_edp_psr_status" , buf); -return strstr (buf,"\nActive: yes\n" ) && -strstr (buf,"\nHW Enabled & Active bit: yes\n" ); -} - -static void psr_print_status (void ) -{ -char buf[256 ]; - -debugfs_read ("i915_edp_psr_status" , buf); -igt_info ("PSR status:\n%s\n" , buf); -} -static struct timespec fbc_get_last_action (void ) {struct timespec ret = {0 ,0 };
@@ -926,15 +863,8 @@ static bool fbc_wait_until_enabled(void)return igt_wait (fbc_is_enabled (),2000 ,1 ); } -static bool psr_wait_until_enabled (void ) -{ -return igt_wait (psr_is_enabled (),5000 ,1 ); -} -#define fbc_enable () igt_set_module_param_int("enable_fbc", 1)#define fbc_disable () igt_set_module_param_int("enable_fbc", 0) -#define psr_enable () igt_set_module_param_int("enable_psr", 1) -#define psr_disable () igt_set_module_param_int("enable_psr", 0)static void get_sink_crc (sink_crc_t *crc,bool mandatory) {
@@ -1180,7 +1110,7 @@ static void disable_features(const struct test_mode *t)return ;fbc_disable (); -psr_disable (); +igt_psr_disable (); }static void *busy_thread_func (void *data)
@@ -1547,14 +1477,6 @@ static void teardown_fbc(void) { } -static bool psr_sink_has_support (void ) -{ -char buf[256 ]; - -debugfs_read ("i915_edp_psr_status" , buf); -return strstr (buf,"Sink_Support: yes\n" ); -} -static void setup_psr (void ) { if (get_connector(prim_mode_params.connector_id)->connector_type !=
@@ -1563,7 +1485,7 @@ static void setup_psr(void)return ; } -if (!psr_sink_has_support ()) { +if (!igt_psr_sink_support (drm.fd)) {igt_info ("Can't test PSR: not supported by sink.\n" );return ; }
@@ -1717,12 +1639,15 @@ static int adjust_assertion_flags(const struct test_mode *t, int flags) } \ \if (flags_ &ASSERT_PSR_ENABLED ) { \ -if (!psr_wait_until_enabled ()) { \ -psr_print_status (); \ +if (!igt_psr_await_status (drm.fd, true)) { \ +igt_psr_print_status (drm.fd); \igt_assert_f (false,"PSR disabled\n" ); \ } \ }else if (flags_ &ASSERT_PSR_DISABLED ) { \ -igt_assert (!psr_wait_until_enabled ()); \ +if (!igt_psr_await_status (drm.fd, false)) { \ +igt_psr_print_status (drm.fd); \ +igt_assert_f (false,"PSR enabled\n" ); \ + } \ } \ }while (0 )
@@ -1822,7 +1747,7 @@ static void enable_features_for_test(const struct test_mode *t)if (t->feature &FEATURE_FBC )fbc_enable ();if (t->feature &FEATURE_PSR ) -psr_enable (); +igt_psr_enable (); }static void check_test_requirements (const struct test_mode *t)
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/5 tests/kms_fbcon_fbt: Refactor to use IGT PSR library functions
In reply to Jim Bride--- tests/kms_fbcon_fbt.c | 56 ++++++++++++++++-------------------------------- tests/kms_psr_sink_crc.c | 36 +++++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 43 deletions(-)
tests/kms_fbcon_fbt.c +19 -37
@@ -103,8 +103,9 @@ static bool fbc_is_enabled(int fd)return strstr (buf,"FBC enabled\n" ); } -static bool fbc_wait_until_enabled (int fd) +static bool fbc_wait_until_enabled (int fd,bool enabled) { + enabled = enabled;return igt_wait (fbc_is_enabled (fd),5000 ,1 ); }
@@ -124,6 +125,13 @@ static void set_mode_for_one_screen(struct drm_info *drm, struct igt_fb *fb,if (c->connection ==DRM_MODE_CONNECTED && c->count_modes &&connector_possible (c)) { +if (c->connector_type == DRM_MODE_CONNECTOR_eDP) { +bool bret; + + bret =igt_psr_find_good_mode (c, &mode); +if (bret) +break ; + } mode = &c->modes[0 ];break ; }
@@ -147,35 +155,9 @@ static void set_mode_for_one_screen(struct drm_info *drm, struct igt_fb *fb,igt_assert_eq (rc,0 ); } -static bool psr_supported_on_chipset (int fd) -{ -char buf[256 ]; - -igt_debugfs_read (fd,"i915_edp_psr_status" , buf); -return strstr (buf,"Sink_Support: yes\n" ); -} - -static bool connector_can_psr (drmModeConnectorPtr connector) -{ -return (connector->connector_type == DRM_MODE_CONNECTOR_eDP); -} - -static bool psr_is_enabled (int fd) -{ -char buf[256 ]; - -igt_debugfs_read (fd,"i915_edp_psr_status" , buf); -return strstr (buf,"\nActive: yes\n" ); -} - -static bool psr_wait_until_enabled (int fd) -{ -return igt_wait (psr_is_enabled (fd),5000 ,1 ); -} -struct feature {bool (*supported_on_chipset)(int fd); -bool (*wait_until_enabled)(int fd); +bool (*wait_until_enabled)(int fd,bool status);bool (*connector_possible_fn)(drmModeConnectorPtr connector);const char *param_name; } fbc = {
@@ -184,9 +166,9 @@ struct feature { .connector_possible_fn = connector_can_fbc, .param_name ="enable_fbc" , }, psr = { - .supported_on_chipset = psr_supported_on_chipset, - .wait_until_enabled = psr_wait_until_enabled, - .connector_possible_fn = connector_can_psr, + .supported_on_chipset = igt_psr_sink_support, + .wait_until_enabled = igt_psr_await_status, + .connector_possible_fn = igt_psr_valid_connector, .param_name = "enable_psr", };
@@ -210,17 +192,17 @@ static void subtest(struct feature *feature, bool suspend)kmstest_unset_all_crtcs (drm.fd, drm.res);wait_user ("Modes unset." ); -igt_assert (!feature->wait_until_enabled (drm.fd)); +igt_assert (!feature->wait_until_enabled (drm.fd, true));set_mode_for_one_screen (&drm, &fb, feature->connector_possible_fn);wait_user ("Screen set." ); -igt_assert (feature->wait_until_enabled (drm.fd)); +igt_assert (feature->wait_until_enabled (drm.fd, true));if (suspend) {igt_system_suspend_autoresume (SUSPEND_STATE_MEM ,SUSPEND_TEST_NONE );sleep (5 ); -igt_assert (feature->wait_until_enabled (drm.fd)); +igt_assert (feature->wait_until_enabled (drm.fd, true)); }igt_remove_fb (drm.fd, &fb);
@@ -230,13 +212,13 @@ static void subtest(struct feature *feature, bool suspend)sleep (3 );wait_user ("Back to fbcon." ); -igt_assert (!feature->wait_until_enabled (drm.fd)); +igt_assert (!feature->wait_until_enabled (drm.fd, true));if (suspend) {igt_system_suspend_autoresume (SUSPEND_STATE_MEM ,SUSPEND_TEST_NONE );sleep (5 ); -igt_assert (!feature->wait_until_enabled (drm.fd)); +igt_assert (!feature->wait_until_enabled (drm.fd, true)); } }
@@ -266,7 +248,7 @@ igt_mainsubtest (&fbc, true); igt_subtest("psr-suspend")subtest (&psr, true); - +igt_fixture teardown_environment (); }
tests/kms_psr_sink_crc.c +30 -6
@@ -70,7 +70,7 @@ typedef struct {uint32_t crtc_id;igt_display_t display;drm_intel_bufmgr *bufmgr; -struct igt_fb fb_green, fb_white; +struct igt_fb fb_green, fb_white, fb_blue;;igt_plane_t *primary, *sprite, *cursor;int mod_size;int mod_stride;
@@ -78,6 +78,7 @@ typedef struct {igt_output_t *output; } data_t; +static void create_cursor_fb (data_t *data) {cairo_t *cr;
@@ -93,11 +94,11 @@ static void create_cursor_fb(data_t *data)igt_assert (cairo_status (cr) ==0 ); } -static void setup_output (data_t *data) {igt_display_t *display = &data->display;igt_output_t *output; +drmModeModeInfoPtr mode =NULL ;enum pipe pipe;for_each_pipe_with_valid_output (display, pipe, output) {
@@ -106,11 +107,15 @@ static void setup_output(data_t *data)if (c->connector_type != DRM_MODE_CONNECTOR_eDP)continue ; +if (!igt_psr_find_good_mode (c, &mode)) +continue ; + +igt_assert (mode !=NULL ); +igt_output_override_mode (output, mode);igt_output_set_pipe (output, pipe); data->crtc_id = output->config.crtc->crtc_id; data->output = output; - data->mode =igt_output_get_mode (output); - + data->mode = &output->override_mode;return ; } }
@@ -119,10 +124,31 @@ static void display_init(data_t *data) {igt_display_init (&data->display, data->drm_fd);setup_output (data); + +/* We need to be able to do a modeset before we enable PSR to +* ensure that we are running at a mode such that PSR setup can +* complete within a single vblank interval. +*/ +igt_debug ("Selected mode:\n" ); +kmstest_dump_mode (data->mode); +igt_create_color_fb (data->drm_fd, + data->mode->hdisplay, data->mode->vdisplay, +DRM_FORMAT_XRGB8888 , +LOCAL_I915_FORMAT_MOD_X_TILED , +0.0 ,.0 ,1.0 , + &data->fb_blue); + + data->primary =igt_output_get_plane_type (data->output, +DRM_PLANE_TYPE_PRIMARY ); +igt_plane_set_fb (data->primary, &data->fb_blue); +igt_display_commit (&data->display); +igt_set_module_param_int ("enable_psr" , running_with_psr_disabled ? +0 :1 ); }static void display_fini (data_t *data) { +igt_output_override_mode (data->output,NULL );igt_display_fini (&data->display); }
@@ -494,8 +520,6 @@ int main(int argc, char *argv[])kmstest_set_vt_graphics_mode (); data.devid =intel_get_drm_devid (data.drm_fd); -igt_set_module_param_int ("enable_psr" , running_with_psr_disabled ? -0 :1 );igt_skip_on (!psr_possible (&data));
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx