From 4fb21789eb0f04a61033c85d2888db0e904716c2 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Wed, 7 Sep 2016 17:00:39 +0200 Subject: kms_cursor_legacy: Add cursor crc tests. On skylake there's a add_all_affected_planes call that will make atomic commit use the old cursor state. Add a test that first does a page flip then cursor update to expose the issue. The test currently fails on the vblank wait, but that's a common issue affecting all the tests. Signed-off-by: Maarten Lankhorst --- tests/kms_cursor_legacy.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'tests/kms_cursor_legacy.c') diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c index c9eef27b..373873a8 100644 --- a/tests/kms_cursor_legacy.c +++ b/tests/kms_cursor_legacy.c @@ -867,6 +867,72 @@ cleanup: igt_skip("Nonblocking modeset is not supported by this kernel\n"); } +static void flip_vs_cursor_crc(igt_display_t *display, bool atomic) +{ + struct drm_mode_cursor arg[2]; + struct drm_event_vblank vbl; + struct igt_fb fb_info, cursor_fb; + unsigned vblank_start; + enum pipe pipe = find_connected_pipe(display, false); + igt_pipe_crc_t *pipe_crc; + igt_crc_t crcs[3]; + + if (atomic) + igt_require(display->is_atomic); + + igt_require(set_fb_on_crtc(display, pipe, &fb_info)); + + igt_create_color_fb(display->drm_fd, 64, 64, DRM_FORMAT_ARGB8888, 0, 1., 1., 1., &cursor_fb); + populate_cursor_args(display, pipe, arg, &cursor_fb); + + arg[0].flags = arg[1].flags = DRM_MODE_CURSOR_BO; + arg[1].handle = 0; + arg[1].width = arg[1].height = 0; + + igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); + + pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + + /* Collect reference crc with cursor disabled. */ + igt_pipe_crc_collect_crc(pipe_crc, &crcs[1]); + + set_cursor_on_pipe(display, pipe, &cursor_fb); + igt_display_commit2(display, COMMIT_UNIVERSAL); + + do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]); + + get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); + + /* Collect reference crc with cursor enabled. */ + igt_pipe_crc_collect_crc(pipe_crc, &crcs[0]); + + /* Disable cursor, and immediately queue a flip. Check if resulting crc is correct. */ + for (int i = 1; i >= 0; i--) { + vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS); + + flip_nonblocking(display, pipe, atomic, &fb_info); + do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[i]); + + igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start); + + igt_set_timeout(1, "Stuck page flip"); + igt_ignore_warn(read(display->drm_fd, &vbl, sizeof(vbl))); + igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start + 1); + igt_reset_timeout(); + + igt_debug("Checking for cursor %s\n", i ? "disabled" : "enabled"); + igt_pipe_crc_collect_crc(pipe_crc, &crcs[2]); + + igt_assert_crc_equal(&crcs[i], &crcs[2]); + } + + do_cleanup_display(display); + igt_remove_fb(display->drm_fd, &fb_info); + igt_remove_fb(display->drm_fd, &cursor_fb); + igt_pipe_crc_free(pipe_crc); +} + + igt_main { const int ncpus = sysconf(_SC_NPROCESSORS_ONLN); @@ -947,6 +1013,12 @@ igt_main igt_subtest("2x-long-cursor-vs-nonblocking-modeset-atomic") two_screens_cursor_vs_flip(&display, 150, true); + igt_subtest("flip-vs-cursor-crc-legacy") + flip_vs_cursor_crc(&display, false); + + igt_subtest("flip-vs-cursor-crc-atomic") + flip_vs_cursor_crc(&display, true); + for (i = 0; i <= flip_test_last; i++) { const char *modes[flip_test_last+1] = { "legacy", -- cgit v1.2.3