[i-g-t 1/2] tests/kms_vrr: Fix test accuracy

Bhanuprakash Modem bhanuprakash.modem at intel.com
Fri Jan 12 16:32:13 UTC 2024


Instead of having 50us of threshold to measure the flip accuracy,
allow 0.5 Hz deviation.

Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
---
 tests/kms_vrr.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/tests/kms_vrr.c b/tests/kms_vrr.c
index 71fc36162..01030ab05 100644
--- a/tests/kms_vrr.c
+++ b/tests/kms_vrr.c
@@ -339,10 +339,24 @@ static uint32_t
 flip_and_measure(data_t *data, igt_output_t *output, enum pipe pipe,
 		 uint64_t rate_ns, uint64_t duration_ns)
 {
-	uint64_t start_ns, last_event_ns, target_ns;
+	uint64_t start_ns, last_event_ns, target_ns, exp_rate_ns;
 	uint32_t total_flip = 0, total_pass = 0;
 	bool front = false;
 	vtest_ns_t vtest_ns = get_test_rate_ns(data->range);
+	uint64_t threshold_hi, threshold_lo, threshold_ns;
+
+	if ((rate_ns <= vtest_ns.min) && (rate_ns >= vtest_ns.max))
+		exp_rate_ns = rate_ns;
+	else
+		exp_rate_ns = vtest_ns.max;
+
+	/* Allow ~0.5 Hz deviation for different reasons causing delay. */
+	threshold_hi = NSECS_PER_SEC / (((float)NSECS_PER_SEC / exp_rate_ns) + 0.5);
+	threshold_lo = NSECS_PER_SEC / (((float)NSECS_PER_SEC / exp_rate_ns) - 0.5);
+	threshold_ns = (threshold_lo - threshold_hi) / 2;
+
+	igt_info("Requested rate: %"PRIu64" ns, Expected rate: %"PRIu64" ns, Threshold: %"PRIu64" ns\n",
+			rate_ns, exp_rate_ns, threshold_ns);
 
 	/* Align with the flip completion event to speed up convergence. */
 	do_flip(data, &data->fb0);
@@ -369,18 +383,10 @@ flip_and_measure(data_t *data, igt_output_t *output, enum pipe pipe,
 		/*
 		 * Check if the difference between the two flip timestamps
 		 * was within the required threshold from the expected rate.
-		 *
-		 * A ~50us threshold is arbitrary, but it's roughly the
-		 * difference between 144Hz and 143Hz which should give this
-		 * enough accuracy for most use cases.
 		 */
-		if ((rate_ns <= vtest_ns.min) && (rate_ns >= vtest_ns.max))
-			diff_ns = rate_ns;
-		else
-			diff_ns = vtest_ns.max;
-		diff_ns -= event_ns - last_event_ns;
+		diff_ns = exp_rate_ns - (event_ns - last_event_ns);
 
-		if (llabs(diff_ns) < 50000ll)
+		if (llabs(diff_ns) < threshold_ns)
 			total_pass += 1;
 
 		last_event_ns = event_ns;
-- 
2.40.0



More information about the Intel-gfx-trybot mailing list