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/5] tests/kms_tiled_display: Limit the difference in the timestamps to one scanline
Date: Tue, 19 Oct 2021 23:19:38 +0300	[thread overview]
Message-ID: <20211019201940.31729-4-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20211019201940.31729-1-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@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@linux.intel.com>
---
 tests/kms_tiled_display.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/tests/kms_tiled_display.c b/tests/kms_tiled_display.c
index cb4762d7c6b1..7c8852b3496c 100644
--- a/tests/kms_tiled_display.c
+++ b/tests/kms_tiled_display.c
@@ -60,6 +60,7 @@ typedef struct {
 	data_connector_t *conns;
 	enum igt_commit_style commit;
 	struct timeval first_ts;
+	int linetime_us;
 
 	#ifdef HAVE_CHAMELIUM
 	struct chamelium *chamelium;
@@ -67,7 +68,6 @@ typedef struct {
 	int port_count;
 	struct chamelium_edid *edids[IGT_CUSTOM_EDID_COUNT];
 	#endif
-
 } data_t;
 
 void basic_test(data_t *data, drmEventContext *drm_event, struct pollfd *pfd);
@@ -207,6 +207,12 @@ static void test_cleanup(data_t *data)
 	igt_display_commit2(&data->display, data->commit);
 	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;
@@ -263,6 +269,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);
@@ -330,6 +337,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)
@@ -352,8 +364,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;
 
@@ -361,11 +373,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.32.0

  parent reply	other threads:[~2021-10-19 20:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19 20:19 [igt-dev] [PATCH i-g-t 0/5] kms: Run tiled display tests on any set of connectors Ville Syrjala
2021-10-19 20:19 ` [igt-dev] [PATCH i-g-t 1/5] tests/kms_tiled_display: Get rid of DP stuff Ville Syrjala
2021-10-19 20:19 ` [igt-dev] [PATCH i-g-t 2/5] tests/kms_tiled_display: Replace the igt_display pointer with a struct Ville Syrjala
2021-10-19 22:07   ` [igt-dev] [PATCH i-g-t v2 " Ville Syrjala
2021-10-19 20:19 ` Ville Syrjala [this message]
2021-10-19 20:19 ` [igt-dev] [PATCH i-g-t 4/5] lib/edid: Add support for making DisplayID tile blocks Ville Syrjala
2021-10-19 20:19 ` [igt-dev] [PATCH i-g-t 5/5] tests/kms_tiled_display: Override the EDID to fake some tiles Ville Syrjala
2021-10-19 20:48 ` [igt-dev] ✗ Fi.CI.BUILD: failure for kms: Run tiled display tests on any set of connectors Patchwork
2021-10-19 20:51 ` [igt-dev] ✗ GitLab.Pipeline: warning " Patchwork
2021-10-19 22:50 ` [igt-dev] ✓ Fi.CI.BAT: success for kms: Run tiled display tests on any set of connectors (rev2) Patchwork
2021-10-20  3:37 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2020-03-13 16:11 [igt-dev] [PATCH i-g-t 1/5] tests/kms_tiled_display: Get rid of DP stuff Ville Syrjala
2020-03-13 16:11 ` [igt-dev] [PATCH i-g-t 3/5] tests/kms_tiled_display: Limit the difference in the timestamps to one scanline Ville Syrjala

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=20211019201940.31729-4-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