From 6fcc8e8b247661c7950b998e0b95141ffbd6b833 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Wed, 14 Jun 2017 10:17:31 +0200 Subject: tests/kms_cursor_crc: Fix the cursor tests to work on CHV MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On CHV pipe C when the cursor is visible with a negative X coordinate a FIFO Underrun will occur. The kernel worked around this by disallowing cursor updates on pipe C at negative X coordinates when the cursor is visible. This was done in the following kernel commit: commit ef8dd37af85a8f37ca3a29074647511e52c56181 Author: Ville Syrjälä Date: Fri Dec 18 19:24:39 2015 +0200 drm/i915: Workaround CHV pipe C cursor fail kms_chv_cursor_fail was created to test this issue, but it also happens in kms_cursor_crc, so workaround it there too. Signed-off-by: Maarten Lankhorst Cc: Ville Syrjälä Acked-by: Ville Syrjälä Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97960 --- tests/kms_cursor_crc.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests/kms_cursor_crc.c') diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c index 0940752b..4c5e00c0 100644 --- a/tests/kms_cursor_crc.c +++ b/tests/kms_cursor_crc.c @@ -106,6 +106,34 @@ static void cursor_disable(data_t *data) igt_plane_set_fb(cursor, NULL); } +static bool chv_cursor_broken(data_t *data, int x) +{ + /* + * CHV gets a FIFO underrun on pipe C when cursor x coordinate + * is negative and the cursor visible. + * + * i915 is fixed to return -EINVAL on cursor updates with those + * negative coordinates, so require cursor update to fail with + * -EINVAL in that case. + * + * See also kms_chv_cursor_fail.c + */ + if (x >= 0) + return false; + + return IS_CHERRYVIEW(data->devid) && data->pipe == PIPE_C; +} + +static bool cursor_visible(data_t *data, int x, int y) +{ + if (x + data->curw <= 0 || y + data->curh <= 0) + return false; + + if (x >= data->screenw || y >= data->screenh) + return false; + + return true; +} static void do_single_test(data_t *data, int x, int y) { @@ -114,6 +142,7 @@ static void do_single_test(data_t *data, int x, int y) igt_crc_t crc, ref_crc; igt_plane_t *cursor; cairo_t *cr = igt_get_cairo_ctx(data->drm_fd, &data->primary_fb); + int ret = 0; igt_print_activity(); @@ -122,7 +151,17 @@ static void do_single_test(data_t *data, int x, int y) cursor_enable(data); cursor = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_CURSOR); igt_plane_set_position(cursor, x, y); + + if (chv_cursor_broken(data, x) && cursor_visible(data, x, y)) { + ret = igt_display_try_commit2(display, COMMIT_LEGACY); + igt_assert_eq(ret, -EINVAL); + igt_plane_set_position(cursor, 0, y); + + return; + } + igt_display_commit(display); + igt_wait_for_vblank(data->drm_fd, data->pipe); igt_pipe_crc_collect_crc(pipe_crc, &crc); -- cgit v1.2.3