[PATCH igt v2] tests/kms_cursor_legacy: Boost timing sensitive subtests to RT prio

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Even in an otherwise quiescent system there may be user/kernel threads
independent of the test that add enough latency to make timing sensitive
subtests fail. Boost the priority of such subtests to avoid these
failures.

This got rid of sporadic failures in basic-cursor-vs-flip-legacy and
basic-cursor-vs-flip-varying-size with 'missed 1 frame' error message
APL and BSW.

v2:
- Boost the priority in flip_vs_cursor_crc() too.

CC: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
CC: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>
Signed-off-by: Imre Deak <imre.deak@xxxxxxxxx>
---
 tests/kms_cursor_legacy.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c
index 373873a..47dbac9 100644
--- a/tests/kms_cursor_legacy.c
+++ b/tests/kms_cursor_legacy.c
@@ -450,6 +450,39 @@ static unsigned get_vblank(int fd, int pipe, unsigned flags)
 	return vbl.reply.sequence;
 }
 
+struct sched_info {
+	int policy;
+	int prio;
+};
+
+static void boost_to_rt_sched_prio(struct sched_info *old_info)
+{
+	struct sched_param new_param = {
+		.sched_priority = 99,
+	};
+	struct sched_param param;
+	int pid = getpid();
+
+	igt_info("Boosting to RT scheduler priority\n");
+
+	old_info->policy = sched_getscheduler(pid);
+	igt_assert(old_info->policy >= 0);
+	igt_assert(sched_getparam(pid, &param) == 0);
+	old_info->prio = param.sched_priority;
+
+	igt_assert(sched_setscheduler(pid, SCHED_FIFO | SCHED_RESET_ON_FORK,
+				      &new_param) == 0);
+}
+
+static void restore_sched_prio(struct sched_info *info)
+{
+	struct sched_param param = {
+		.sched_priority = info->prio,
+	};
+
+	igt_assert(sched_setscheduler(getpid(), info->policy, &param) == 0);
+}
+
 static void basic_flip_vs_cursor(igt_display_t *display, enum flip_test mode, int nloops)
 {
 	struct drm_mode_cursor arg[2];
@@ -458,6 +491,7 @@ static void basic_flip_vs_cursor(igt_display_t *display, enum flip_test mode, in
 	unsigned vblank_start;
 	int target;
 	enum pipe pipe = find_connected_pipe(display, false);
+	struct sched_info old_sched_info;
 
 	if (mode >= flip_test_atomic)
 		igt_require(display->is_atomic);
@@ -489,6 +523,8 @@ static void basic_flip_vs_cursor(igt_display_t *display, enum flip_test mode, in
 	} else
 		target = 1;
 
+	boost_to_rt_sched_prio(&old_sched_info);
+
 	vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS);
 	igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start);
 	for (int n = 0; n < target; n++)
@@ -524,6 +560,8 @@ static void basic_flip_vs_cursor(igt_display_t *display, enum flip_test mode, in
 		igt_reset_timeout();
 	} while (nloops--);
 
+	restore_sched_prio(&old_sched_info);
+
 	do_cleanup_display(display);
 	igt_remove_fb(display->drm_fd, &fb_info);
 	igt_remove_fb(display->drm_fd, &cursor_fb);
@@ -565,6 +603,7 @@ static void two_screens_flip_vs_cursor(igt_display_t *display, int nloops, bool
 	enum pipe pipe2 = find_connected_pipe(display, true);
 	igt_output_t *output2;
 	bool skip_test = false;
+	struct sched_info old_sched_info;
 
 	if (modeset)
 		igt_require(display->is_atomic);
@@ -592,6 +631,8 @@ static void two_screens_flip_vs_cursor(igt_display_t *display, int nloops, bool
 
 	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
 
+	boost_to_rt_sched_prio(&old_sched_info);
+
 	vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS);
 	igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start);
 	do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]);
@@ -636,6 +677,8 @@ static void two_screens_flip_vs_cursor(igt_display_t *display, int nloops, bool
 		}
 	}
 
+	restore_sched_prio(&old_sched_info);
+
 cleanup:
 	do_cleanup_display(display);
 	igt_remove_fb(display->drm_fd, &fb_info);
@@ -657,6 +700,7 @@ static void basic_cursor_vs_flip(igt_display_t *display, enum flip_test mode, in
 	enum pipe pipe = find_connected_pipe(display, false);
 	igt_output_t *output;
 	uint32_t vrefresh;
+	struct sched_info old_sched_info;
 
 	if (mode >= flip_test_atomic)
 		igt_require(display->is_atomic);
@@ -690,6 +734,8 @@ static void basic_cursor_vs_flip(igt_display_t *display, enum flip_test mode, in
 	igt_debug("Using a target of %ld cursor updates per half-vblank (%u)\n",
 		  target, vrefresh);
 
+	boost_to_rt_sched_prio(&old_sched_info);
+
 	for (int i = 0; i < nloops; i++) {
 		shared[0] = 0;
 		igt_fork(child, 1) {
@@ -738,6 +784,8 @@ static void basic_cursor_vs_flip(igt_display_t *display, enum flip_test mode, in
 			     shared[0], 2ul*vrefresh*target, vrefresh*target);
 	}
 
+	restore_sched_prio(&old_sched_info);
+
 	do_cleanup_display(display);
 	igt_remove_fb(display->drm_fd, &fb_info);
 	igt_remove_fb(display->drm_fd, &cursor_fb);
@@ -760,6 +808,7 @@ static void two_screens_cursor_vs_flip(igt_display_t *display, int nloops, bool
 	enum pipe pipe2 = find_connected_pipe(display, true);
 	igt_output_t *output2;
 	bool skip_test = false;
+	struct sched_info old_sched_info;
 
 	shared = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
 	igt_assert(shared != MAP_FAILED);
@@ -790,6 +839,8 @@ static void two_screens_cursor_vs_flip(igt_display_t *display, int nloops, bool
 
 	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
 
+	boost_to_rt_sched_prio(&old_sched_info);
+
 	target = 4096;
 	do {
 		vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS);
@@ -856,6 +907,8 @@ static void two_screens_cursor_vs_flip(igt_display_t *display, int nloops, bool
 			     shared[0], 2*60ul*target, 60ul*target);
 	}
 
+	restore_sched_prio(&old_sched_info);
+
 cleanup:
 	do_cleanup_display(display);
 	igt_remove_fb(display->drm_fd, &fb_info);
@@ -876,6 +929,7 @@ static void flip_vs_cursor_crc(igt_display_t *display, bool atomic)
 	enum pipe pipe = find_connected_pipe(display, false);
 	igt_pipe_crc_t *pipe_crc;
 	igt_crc_t crcs[3];
+	struct sched_info old_sched_info;
 
 	if (atomic)
 		igt_require(display->is_atomic);
@@ -906,6 +960,8 @@ static void flip_vs_cursor_crc(igt_display_t *display, bool atomic)
 	/* Collect reference crc with cursor enabled. */
 	igt_pipe_crc_collect_crc(pipe_crc, &crcs[0]);
 
+	boost_to_rt_sched_prio(&old_sched_info);
+
 	/* Disable cursor, and immediately queue a flip. Check if resulting crc is correct. */
 	for (int i = 1; i >= 0; i--) {
 		vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS);
@@ -926,6 +982,8 @@ static void flip_vs_cursor_crc(igt_display_t *display, bool atomic)
 		igt_assert_crc_equal(&crcs[i], &crcs[2]);
 	}
 
+	restore_sched_prio(&old_sched_info);
+
 	do_cleanup_display(display);
 	igt_remove_fb(display->drm_fd, &fb_info);
 	igt_remove_fb(display->drm_fd, &cursor_fb);
-- 
2.5.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux