[igt-dev] [PATCH i-g-t 3/5] tests/kms_tiled_display: Limit the difference in the timestamps to one scanline

Ville Syrjala ville.syrjala at linux.intel.com
Fri Mar 13 16:11:31 UTC 2020


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

The 10 usec limit is rather abitrary. Let's choose another (perhaps a
bit less) arbitrary value of single scanline. The timestamp could be off
by some significant fraction of a scanline anyway since that's often the
precision the hardware gives us for tracking the scanout position.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 tests/kms_tiled_display.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/tests/kms_tiled_display.c b/tests/kms_tiled_display.c
index 0671ac6c2249..66b5944e0158 100644
--- a/tests/kms_tiled_display.c
+++ b/tests/kms_tiled_display.c
@@ -59,6 +59,7 @@ typedef struct {
 	data_connector_t *conns;
 	enum igt_commit_style commit;
 	struct timeval first_ts;
+	int linetime_us;
 } data_t;
 
 static int drm_property_is_tile(drmModePropertyPtr prop)
@@ -200,6 +201,11 @@ static void test_cleanup(data_t *data)
 	memset(conns, 0, sizeof(data_connector_t) * data->num_h_tiles);
 }
 
+static int mode_linetime_us(const drmModeModeInfo *mode)
+{
+	return 1000 * mode->htotal / mode->clock;
+}
+
 static void setup_mode(data_t *data)
 {
 	int count = 0, prev = 0, i = 0;
@@ -256,6 +262,7 @@ static void setup_mode(data_t *data)
 		}
 		igt_require(found);
 		igt_output_override_mode(output, mode);
+		data->linetime_us = mode_linetime_us(mode);
 	}
 	igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET,
 				  NULL);
@@ -323,6 +330,11 @@ static data_connector_t *conn_for_crtc(data_t *data, unsigned int crtc_id)
 	return NULL;
 }
 
+static float timeval_float(const struct timeval *tv)
+{
+	return tv->tv_sec + tv->tv_usec / 1000000.0f;
+}
+
 static void page_flip_handler(int fd, unsigned int seq,
 			      unsigned int tv_sec, unsigned int tv_usec,
 			      unsigned int crtc_id, void *_data)
@@ -345,8 +357,8 @@ static void page_flip_handler(int fd, unsigned int seq,
 	igt_assert_f(!conn->got_page_flip, "Got two page-flips for CRTC %u\n",
 		     crtc_id);
 
-	igt_debug("Page Flip Event received from CRTC:%d at %u:%u\n", crtc_id,
-		  tv_sec, tv_usec);
+	igt_debug("Page Flip Event received from CRTC:%d at %.6f\n",
+		  crtc_id, timeval_float(&current_ts));
 
 	conn->got_page_flip = true;
 
@@ -354,11 +366,12 @@ static void page_flip_handler(int fd, unsigned int seq,
 	usec = diff.tv_sec * 1000000 + diff.tv_usec;
 
 	/*
-	 * For seamless tear-free display, the page flip event timestamps
-	 * from all the tiles should not differ by more than 10us.
+	 * We arbitrarily choose to say that the difference
+	 * should be no more than a single scanline.
 	 */
-	igt_fail_on_f(labs(usec) >= 10, "Delayed page flip event from CRTC:%d at %u:%u\n",
-		      crtc_id, tv_sec, tv_usec);
+	igt_fail_on_f(labs(usec) > data->linetime_us,
+		      "Mistimed page flip event from CRTC:%d at %.6f (diff %ld usec, max %d usec)\n",
+		      crtc_id, timeval_float(&current_ts), usec, data->linetime_us);
 }
 
 static bool got_all_page_flips(data_t *data)
-- 
2.24.1



More information about the igt-dev mailing list