From 2c64f11f38f44d21419dc15adc7162bd83f65664 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 13 Mar 2017 15:58:26 +0000 Subject: igt/kms_pipe_crc_basic: Tighten timings for CRC readback The number of vblanks that pass whilst we read back the CRCs is depended upon CPU scheduling -- we may take longer than expected and end up reading more CRCs. Align the start of the loop to a vblank. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100132 Signed-off-by: Chris Wilson --- tests/kms_pipe_crc_basic.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'tests/kms_pipe_crc_basic.c') diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c index b0622cfb..79f3747f 100644 --- a/tests/kms_pipe_crc_basic.c +++ b/tests/kms_pipe_crc_basic.c @@ -96,7 +96,6 @@ test_read_crc_for_output(data_t *data, int pipe, igt_output_t *output, igt_display_t *display = &data->display; igt_plane_t *primary; drmModeModeInfo *mode; - igt_pipe_crc_t *pipe_crc; igt_crc_t *crcs = NULL; int c, j; @@ -124,30 +123,35 @@ test_read_crc_for_output(data_t *data, int pipe, igt_output_t *output, igt_display_commit(display); - if (flags & TEST_NONBLOCK) - pipe_crc = igt_pipe_crc_new_nonblock(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); - else - pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); - - igt_pipe_crc_start(pipe_crc); - /* wait for N_CRCS vblanks and the corresponding N_CRCS CRCs */ if (flags & TEST_NONBLOCK) { - int i; + igt_pipe_crc_t *pipe_crc; + + pipe_crc = igt_pipe_crc_new_nonblock(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + igt_wait_for_vblank(data->drm_fd, pipe); + igt_pipe_crc_start(pipe_crc); - for (i = 0; i < N_CRCS; i++) - igt_wait_for_vblank(data->drm_fd, pipe); + igt_wait_for_vblank_count(data->drm_fd, pipe, N_CRCS); + n_crcs = igt_pipe_crc_get_crcs(pipe_crc, N_CRCS+1, &crcs); + igt_pipe_crc_stop(pipe_crc); + igt_pipe_crc_free(pipe_crc); - n_crcs = igt_pipe_crc_get_crcs(pipe_crc, N_CRCS * 3, &crcs); /* allow a one frame difference */ - igt_assert_lte(n_crcs, N_CRCS + 1); - igt_assert_lte(N_CRCS, n_crcs + 1); + igt_assert_lte(N_CRCS, n_crcs); } else { + igt_pipe_crc_t *pipe_crc; + + pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + igt_pipe_crc_start(pipe_crc); + n_crcs = igt_pipe_crc_get_crcs(pipe_crc, N_CRCS, &crcs); + + igt_pipe_crc_stop(pipe_crc); + igt_pipe_crc_free(pipe_crc); + igt_assert_eq(n_crcs, N_CRCS); } - igt_pipe_crc_stop(pipe_crc); /* * save the CRC in colors so it can be compared to the CRC of @@ -168,7 +172,6 @@ test_read_crc_for_output(data_t *data, int pipe, igt_output_t *output, igt_assert_eq(crcs[j].frame + 1, crcs[j + 1].frame); free(crcs); - igt_pipe_crc_free(pipe_crc); igt_remove_fb(data->drm_fd, &data->fb); igt_plane_set_fb(primary, NULL); -- cgit v1.2.3