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 3/3] tests/kms_plane: Use non-blocking commits for pixel format tests
Date: Fri, 21 Feb 2020 22:50:54 +0200	[thread overview]
Message-ID: <20200221205054.19734-3-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20200221205054.19734-1-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.

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

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

  parent reply	other threads:[~2020-02-21 20:51 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 ` Ville Syrjala [this message]
2020-02-26 20:52   ` [igt-dev] [PATCH i-g-t v2 3/3] tests/kms_plane: Use non-blocking commits for pixel format tests Ville Syrjala
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=20200221205054.19734-3-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