Skip to contentSkip to conversation

igt/kms_flip: Mark frame_time() as coming from the mode

PATCH New Chris Wilson 1 participant 2 messages Nov 1, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 igt/kms_flip: Mark frame_time() as coming from the mode

---
 tests/kms_flip.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
tests/kms_flip.c +12 -12
index 9829b35..74754d1 100644
@@ -574,7 +574,7 @@ static void page_flip_handler(int fd, unsigned int frame, unsigned int sec,
 		event_handler(&o->flip_state, frame, sec, usec);
 }
 
-static double frame_time(const struct test_output *o)
+static double mode_frame_time(const struct test_output *o)
 {
 	return 1000.0 * o->kmode[0].htotal * o->kmode[0].vtotal / o->kmode[0].clock;
 }
@@ -588,7 +588,7 @@ static void *vblank_wait_thread_func(void *data)
 	for (i = 0; i < 32; i++) {
 		unsigned long start = gettime_us();
 		__wait_for_vblank(TEST_VBLANK_BLOCK, o->pipe, 20, (unsigned long)o, &reply);
-		if (gettime_us() - start > 2 * frame_time(o))
+		if (gettime_us() - start > 2 * mode_frame_time(o))
 			return (void*)1;
 	}
 
@@ -692,7 +692,7 @@ static void check_state(const struct test_output *o, const struct event_state *e
 
 		timersub(&es->current_ts, &es->last_ts, &diff);
 		elapsed = 1e6*diff.tv_sec + diff.tv_usec;
-		expected = (es->current_seq - es->last_seq) * frame_time(o);
+		expected = (es->current_seq - es->last_seq) * mode_frame_time(o);
 
 		igt_debug("%s ts/seq: last %ld.%06ld/%u, current %ld.%06ld/%u: elapsed=%.1fus expected=%.1fus +- %.1fus, error %.1f%%\n",
 			  es->name, es->last_ts.tv_sec, es->last_ts.tv_usec, es->last_seq,
@@ -729,7 +729,7 @@ static void check_state_correlation(struct test_output *o,
 	usec_diff = tv_diff.tv_sec * USEC_PER_SEC + tv_diff.tv_usec;
 
 	seq_diff = es2->current_seq - es1->current_seq;
-	ftime = frame_time(o);
+	ftime = mode_frame_time(o);
 	usec_diff -= seq_diff * ftime;
 
 	igt_assert_f(fabs(usec_diff) / ftime <= 0.005,
@@ -940,10 +940,10 @@ static unsigned int run_test_step(struct test_output *o)
 		 * we waited for two vblanks, so verify that
 		 * we were blocked for ~1-2 frames.
 		 */
-		igt_assert_f(end - start > 0.9 * frame_time(o) &&
-			     end - start < 2.1 * frame_time(o),
+		igt_assert_f(end - start > 0.9 * mode_frame_time(o) &&
+			     end - start < 2.1 * mode_frame_time(o),
 			     "wait for two vblanks took %lu usec (frame time %f usec)\n",
-			     end - start, frame_time(o));
+			     end - start, mode_frame_time(o));
 		join_vblank_wait_thread();
 	}
 
@@ -1194,15 +1194,15 @@ static void check_final_state(const struct test_output *o,
 	 * those use some funny fake timings behind userspace's back. */
 	if (o->flags & TEST_CHECK_TS && !analog_tv_connector(o)) {
 		int count = es->count * o->seq_step;
-		unsigned int min = frame_time(o) * (count - 1);
-		unsigned int max = frame_time(o) * (count + 1);
+		unsigned int min = mode_frame_time(o) * (count - 1);
+		unsigned int max = mode_frame_time(o) * (count + 1);
 
 		igt_debug("expected %d, counted %d, encoder type %d\n",
-			  (int)(elapsed / frame_time(o)), count,
+			  (int)(elapsed / mode_frame_time(o)), count,
 			  o->kencoder[0]->encoder_type);
 		igt_assert_f(elapsed >= min && elapsed <= max,
 			     "dropped frames, expected %d, counted %d, encoder type %d\n",
-			     (int)(elapsed / frame_time(o)), count,
+			     (int)(elapsed / mode_frame_time(o)), count,
 			     o->kencoder[0]->encoder_type);
 	}
 }
@@ -1352,7 +1352,7 @@ static void calibrate_ts(struct test_output *o, int crtc_idx)
 		last_seq = ev.sequence;
 	}
 
-	expected = frame_time(o);
+	expected = mode_frame_time(o);
 
 	mean = igt_stats_get_mean(&stats);
 	stddev = igt_stats_get_std_deviation(&stats);
Signature · 6 lines
2.10.2

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/2 igt/kms_flip: Use the computed vblank interval for TS checking

Since the modeline may differ from actual hardware timings, do not rely upon it but instead measure the actual and verify that it does not change across the various flip/vblank configurations.

---
 tests/kms_flip.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)
tests/kms_flip.c +22 -11
index 74754d1..6a1549e 100644
@@ -177,6 +177,8 @@ struct test_output {
 	int seq_step;
 	unsigned int pending_events;
 	int flip_count;
+
+	double vblank_interval;
 };
 
 
@@ -579,6 +581,12 @@ static double mode_frame_time(const struct test_output *o)
 	return 1000.0 * o->kmode[0].htotal * o->kmode[0].vtotal / o->kmode[0].clock;
 }
 
+static double actual_frame_time(const struct test_output *o)
+{
+	igt_assert(o->flags & TEST_CHECK_TS);
+	return o->vblank_interval;
+}
+
 static void *vblank_wait_thread_func(void *data)
 {
 	struct test_output *o = data;
@@ -687,12 +695,12 @@ static void check_state(const struct test_output *o, const struct event_state *e
 			  es->current_seq, es->last_seq);
 	}
 
-	if ((o->flags & TEST_CHECK_TS) && (!analog_tv_connector(o))) {
+	if (o->flags & TEST_CHECK_TS) {
 		double elapsed, expected;
 
 		timersub(&es->current_ts, &es->last_ts, &diff);
 		elapsed = 1e6*diff.tv_sec + diff.tv_usec;
-		expected = (es->current_seq - es->last_seq) * mode_frame_time(o);
+		expected = (es->current_seq - es->last_seq) * actual_frame_time(o);
 
 		igt_debug("%s ts/seq: last %ld.%06ld/%u, current %ld.%06ld/%u: elapsed=%.1fus expected=%.1fus +- %.1fus, error %.1f%%\n",
 			  es->name, es->last_ts.tv_sec, es->last_ts.tv_usec, es->last_seq,
@@ -1192,17 +1200,17 @@ static void check_final_state(const struct test_output *o,
 
 	/* Verify we drop no frames, but only if it's not a TV encoder, since
 	 * those use some funny fake timings behind userspace's back. */
-	if (o->flags & TEST_CHECK_TS && !analog_tv_connector(o)) {
+	if (o->flags & TEST_CHECK_TS) {
 		int count = es->count * o->seq_step;
-		unsigned int min = mode_frame_time(o) * (count - 1);
-		unsigned int max = mode_frame_time(o) * (count + 1);
+		unsigned int min = actual_frame_time(o) * (count - 1);
+		unsigned int max = actual_frame_time(o) * (count + 1);
 
 		igt_debug("expected %d, counted %d, encoder type %d\n",
-			  (int)(elapsed / mode_frame_time(o)), count,
+			  (int)(elapsed / actual_frame_time(o)), count,
 			  o->kencoder[0]->encoder_type);
 		igt_assert_f(elapsed >= min && elapsed <= max,
 			     "dropped frames, expected %d, counted %d, encoder type %d\n",
-			     (int)(elapsed / mode_frame_time(o)), count,
+			     (int)(elapsed / actual_frame_time(o)), count,
 			     o->kencoder[0]->encoder_type);
 	}
 }
@@ -1361,10 +1369,13 @@ static void calibrate_ts(struct test_output *o, int crtc_idx)
 		 expected, mean, stddev, 100 * 6 * stddev / mean);
 	igt_assert(6 * stddev / mean < 0.005); /* 99% accuracy within 0.5% */
 
-	igt_require_f(fabs(mean - expected) < 2*stddev,
-		      "vblank interval differs from modeline! expected %.1fus, measured %1.fus +- %.3fus, difference %.1fus (%.1f sigma)\n",
-		      expected, mean, stddev,
-		      fabs(mean - expected), fabs(mean - expected) / stddev);
+	if (fabs(mean - expected) > 2*stddev) {
+		igt_warn("vblank interval differs from modeline! expected %.1fus, measured %1.fus +- %.3fus, difference %.1fus (%.1f sigma)\n",
+				expected, mean, stddev,
+				fabs(mean - expected), fabs(mean - expected) / stddev);
+	}
+
+	o->vblank_interval = mean;
 }
 
 static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,
Signature · 6 lines
2.10.2

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx