public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v2 3/3] tests/kms_plane: Use non-blocking commits for pixel format tests
Date: Wed, 26 Feb 2020 22:52:28 +0200	[thread overview]
Message-ID: <20200226205228.14149-1-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20200221205054.19734-3-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@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.

v2: Assert we get got the crc for the correct frame (Martin)
    Due to above add a vblank wait for cursor setplane.
    Make it more robust against the rendering taking a long time
    by grabbing the crc for the last possible frame rather than
    the first possible frame.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tests/kms_plane.c | 88 ++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 72 insertions(+), 16 deletions(-)

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 8a5b89b2ae95..805795cd4ed0 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -519,6 +519,15 @@ static int num_unique_crcs(const igt_crc_t crc[], int num_crc)
 	return num_unique_crc;
 }
 
+static void capture_crc(data_t *data, unsigned int vblank, igt_crc_t *crc)
+{
+	igt_pipe_crc_get_for_frame(data->drm_fd, data->pipe_crc, vblank, crc);
+
+	igt_fail_on_f(crc->has_valid_frame && crc->frame != vblank,
+		      "Got CRC for the wrong frame (got %u, expected %u). CRC buffer overflow?\n",
+		      crc->frame, vblank);
+}
+
 static void capture_format_crcs(data_t *data, enum pipe pipe,
 				igt_plane_t *plane,
 				uint32_t format, uint64_t modifier,
@@ -528,6 +537,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 +547,16 @@ 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));
+			/*
+			 * The last time we saw the crc for
+			 * flip N-2 is when the flip N-1 latched.
+			 */
+			if (i >= 2)
+				vblank[i - 2] = ev.sequence;
+		}
+
 		/*
 		 * The flip issued during frame N will latch
 		 * at the start of frame N+1, and its CRC will
@@ -545,23 +565,61 @@ static void capture_format_crcs(data_t *data, enum pipe pipe,
 		 * is for frame N-2.
 		 */
 		if (i >= 2)
-			igt_pipe_crc_get_for_frame(data->drm_fd, data->pipe_crc,
-						   vblank[i - 2], &crc[i - 2]);
+			capture_crc(data, 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 {
+			/*
+			 * Last moment to grab the previous crc
+			 * is when the next flip latches.
+			 */
+			if (i >= 1)
+				vblank[i - 1] = kmstest_get_vblank(data->drm_fd, pipe, 0) + 1;
+
+			/*
+			 * 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);
+
+			/* setplane for the cursor does not block */
+			if (plane->type == DRM_PLANE_TYPE_CURSOR)
+				igt_wait_for_vblank(data->drm_fd, pipe);
+		}
 
 		igt_remove_fb(data->drm_fd, &old_fb);
 	}
 
+	if (data->display.is_atomic) {
+		igt_assert(read(data->drm_fd, &ev, sizeof(ev)) == sizeof(ev));
+		/*
+		 * The last time we saw the crc for
+		 * flip N-2 is when the flip N-1 latched.
+		 */
+		if (i >= 2)
+			vblank[i - 2] = ev.sequence;
+		/*
+		 * The last crc is available earliest one
+		 * frame after the last flip latched.
+		 */
+		vblank[i - 1] = ev.sequence + 1;
+	} else {
+		/*
+		 * The last crc is available earliest one
+		 * frame after the last flip latched.
+		 */
+		vblank[i - 1] = kmstest_get_vblank(data->drm_fd, pipe, 0) + 1;
+	}
+
 	/*
 	 * Get the remaining two crcs
 	 *
@@ -569,10 +627,8 @@ static void capture_format_crcs(data_t *data, enum pipe pipe,
 	 * between different pixel formats as well? Could get messy.
 	 */
 	if (i >= 2)
-		igt_pipe_crc_get_for_frame(data->drm_fd, data->pipe_crc,
-					   vblank[i - 2], &crc[i - 2]);
-	igt_pipe_crc_get_for_frame(data->drm_fd, data->pipe_crc,
-				   vblank[i - 1], &crc[i - 1]);
+		capture_crc(data, vblank[i - 2], &crc[i - 2]);
+	capture_crc(data, vblank[i - 1], &crc[i - 1]);
 }
 
 static bool test_format_plane_colors(data_t *data, enum pipe pipe,
-- 
2.24.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2020-02-26 20:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-21 20:50 [igt-dev] [PATCH i-g-t 1/3] lib/igt_debugfs: Add igt_crc_get_for_frame() Ville Syrjala
2020-02-21 20:50 ` [igt-dev] [PATCH i-g-t 2/3] tests/kms_plane: Pipeline crc capture and flips Ville Syrjala
2020-02-26 20:51   ` [igt-dev] [PATCH i-g-t v2 " Ville Syrjala
2020-02-21 20:50 ` [igt-dev] [PATCH i-g-t 3/3] tests/kms_plane: Use non-blocking commits for pixel format tests Ville Syrjala
2020-02-26 20:52   ` Ville Syrjala [this message]
2020-02-21 21:21 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/3] lib/igt_debugfs: Add igt_crc_get_for_frame() Patchwork
2020-02-24 12:49 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2020-02-26 21:50 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/3] lib/igt_debugfs: Add igt_crc_get_for_frame() (rev3) Patchwork
2020-02-27 12:01 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2020-02-27 13:59 ` [igt-dev] [PATCH i-g-t 1/3] lib/igt_debugfs: Add igt_crc_get_for_frame() Juha-Pekka Heikkila

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200226205228.14149-1-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox