[igt-dev] [PATCH i-g-t 3/3] tests/kms_plane: Use non-blocking commits for pixel format tests

Ville Syrjala ville.syrjala at linux.intel.com
Fri Feb 21 20:50:54 UTC 2020


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

Use non-blocking commits when testing pixel formats so that we
can start preparing the next fb even before the current fb has been
latched by the hardware. Eliminates an extra frame for each color
in cases where preparing the next fb takes longer than a frame.

For non-atomic drivers we can't do this as drmModePageFlip()
won't allow us to change pixel formats, or set any of the YUV
color encoding/range propeties. Hence we must stick to plain
old blocking setplane/setprop there.

On KBL w/ 2048x1080 plane size:
time kms_plane --r pixel-format-pipe-A-planes --extended
- real	2m8,529s
+ real	1m52,078s

time kms_plane --r pixel-format-pipe-A-planes
- real	0m44,135s
+ real	0m40,116s

Won't help modern platforms since they always use a 64x64 plane,
but older platforms may benefit as they can't reduce the primary
plane size.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 tests/kms_plane.c | 43 +++++++++++++++++++++++++++++++++----------
 1 file changed, 33 insertions(+), 10 deletions(-)

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 550b6ad3d81d..083b7ea1c98f 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -528,6 +528,7 @@ static void capture_format_crcs(data_t *data, enum pipe pipe,
 				igt_crc_t crc[], struct igt_fb *fb)
 {
 	unsigned int vblank[ARRAY_SIZE(colors_extended)];
+	struct drm_event_vblank ev;
 	int i;
 
 	for (i = 0; i < data->num_colors; i++) {
@@ -537,6 +538,12 @@ static void capture_format_crcs(data_t *data, enum pipe pipe,
 		prepare_format_color(data, pipe, plane, format, modifier,
 				     width, height, encoding, range, c, fb);
 
+		if (data->display.is_atomic && i >= 1) {
+			igt_assert(read(data->drm_fd, &ev, sizeof(ev)) == sizeof(ev));
+			/* crc is available one frame after the flip latches */
+			vblank[i - 1] = ev.sequence + 1;
+		}
+
 		/*
 		 * The flip issued during frame N will latch
 		 * at the start of frame N+1, and its CRC will
@@ -548,20 +555,36 @@ static void capture_format_crcs(data_t *data, enum pipe pipe,
 			igt_pipe_crc_get_for_frame(data->drm_fd, data->pipe_crc,
 						   vblank[i - 2], &crc[i - 2]);
 
-		igt_display_commit2(&data->display, data->display.is_atomic ? COMMIT_ATOMIC : COMMIT_UNIVERSAL);
-		/*
-		 * TODO: Use flip events to get this. Would also allow
-		 * switching to non-blocking commits so that the next
-		 * fb can be prepared in parallel to waiting for the
-		 * flip to complete.
-		 *
-		 * crc is available one frame after the flip latches
-		 */
-		vblank[i] = kmstest_get_vblank(data->drm_fd, pipe, 0) + 1;
+		if (data->display.is_atomic) {
+			/*
+			 * Use non-blocking commits to allow the next fb
+			 * to be prepared in parallel while the current fb
+			 * awaits to be latched.
+			 */
+			igt_display_commit_atomic(&data->display,
+						  DRM_MODE_ATOMIC_NONBLOCK |
+						  DRM_MODE_PAGE_FLIP_EVENT, NULL);
+		} else {
+			/*
+			 * Can't use drmModePageFlip() since we need to
+			 * change pixel format and potentially update some
+			 * properties as well.
+			 */
+			igt_display_commit2(&data->display, COMMIT_UNIVERSAL);
+
+			/* crc is available one frame after the flip latches */
+			vblank[i] = kmstest_get_vblank(data->drm_fd, pipe, 0) + 1;
+		}
 
 		igt_remove_fb(data->drm_fd, &old_fb);
 	}
 
+	if (data->display.is_atomic) {
+		igt_assert(read(data->drm_fd, &ev, sizeof(ev)) == sizeof(ev));
+		/* crc is available one frame after the flip latches */
+		vblank[i - 1] = ev.sequence + 1;
+	}
+
 	/*
 	 * Get the remaining two crcs
 	 *
-- 
2.24.1



More information about the igt-dev mailing list