[PATCH i-g-t v2 4/6] kms_vblank: Add tests implemented in kms_flip

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

 



In kms_flip there are some tests for testing whether the
vblank counter is monotonically increasing. Add these subtests
to kms_vblank, where they belong.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>
---
 tests/kms_vblank.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 80 insertions(+), 4 deletions(-)

diff --git a/tests/kms_vblank.c b/tests/kms_vblank.c
index 959ba46ca30f..362221c03677 100644
--- a/tests/kms_vblank.c
+++ b/tests/kms_vblank.c
@@ -51,10 +51,14 @@ typedef struct {
 	igt_output_t *output;
 	enum pipe pipe;
 	unsigned int flags;
-#define IDLE 1
-#define BUSY 2
-#define FORKED 4
-#define NOHANG 8
+#define IDLE	0x1
+#define BUSY	0x2
+#define FORKED	0x4
+#define NOHANG	0x8
+#define MODESET 0x10
+#define DPMS	0x20
+#define SUSPEND 0x40
+#define RPM	0x80
 } data_t;
 
 static double elapsed(const struct timespec *start,
@@ -124,6 +128,9 @@ static void run_test(data_t *data, int fd, void (*testfunc)(data_t *, int, int))
 
 	prepare_crtc(data, fd, output);
 
+	if (data->flags & RPM)
+		igt_require(igt_setup_runtime_pm());
+
 	igt_info("Beginning %s on pipe %s, connector %s (%d threads)\n",
 		 igt_subtest_name(), kmstest_pipe_name(data->pipe),
 		 igt_output_name(output), nchildren);
@@ -315,6 +322,69 @@ static void vblank_wait(data_t *data, int fd, int nchildren)
 		 elapsed(&start, &end, count));
 }
 
+static int get_vblank(int fd, enum pipe pipe, unsigned flags)
+{
+	union drm_wait_vblank vbl;
+
+	memset(&vbl, 0, sizeof(vbl));
+	vbl.request.type = DRM_VBLANK_RELATIVE | kmstest_get_vbl_flag(pipe) | flags;
+	do_or_die(igt_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl));
+
+	return vbl.reply.sequence;
+}
+
+static void vblank_ts_cont(data_t *data, int fd, int nchildren)
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output = data->output;
+	int seq1, seq2;
+	union drm_wait_vblank vbl;
+
+	seq1 = get_vblank(fd, data->pipe, 0);
+
+	if (data->flags & DPMS) {
+		igt_output_set_prop_value(output, IGT_CONNECTOR_DPMS, DRM_MODE_DPMS_OFF);
+		igt_display_commit(display);
+	}
+
+	if (data->flags & MODESET) {
+		igt_output_set_pipe(output, PIPE_NONE);
+		igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
+	}
+
+	if (data->flags & RPM)
+		igt_assert(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_SUSPENDED));
+
+	if (data->flags & SUSPEND)
+		igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
+					      SUSPEND_TEST_NONE);
+
+	if (data->flags & (MODESET | DPMS)) {
+		/* Attempting to do a vblank while disabled should return -EINVAL */
+		memset(&vbl, 0, sizeof(vbl));
+		vbl.request.type = DRM_VBLANK_RELATIVE;
+		vbl.request.type |= kmstest_get_vbl_flag(data->pipe);
+		igt_assert_eq(wait_vblank(fd, &vbl), -EINVAL);
+	}
+
+	if (data->flags & DPMS) {
+		igt_output_set_prop_value(output, IGT_CONNECTOR_DPMS, DRM_MODE_DPMS_ON);
+		igt_display_commit(display);
+	}
+
+	if (data->flags & MODESET) {
+		igt_output_set_pipe(output, data->pipe);
+		igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
+	}
+
+	seq2 = get_vblank(fd, data->pipe, 0);
+
+	igt_debug("testing ts continuity: Current frame %u, old frame %u\n", seq2, seq1);
+
+	igt_assert_f(seq2 - seq1 >= 0, "unexpected vblank seq %u, should be >= %u\n", seq2, seq1);
+	igt_assert_f(seq2 - seq1 <= 150, "unexpected vblank seq %u, should be < %u\n", seq2, seq1 + 150);
+}
+
 igt_main
 {
 	int fd;
@@ -327,6 +397,7 @@ igt_main
 		{ "accuracy", accuracy, IDLE },
 		{ "query", vblank_query, IDLE | FORKED | BUSY },
 		{ "wait", vblank_wait, IDLE | FORKED | BUSY },
+		{ "ts-continuation", vblank_ts_cont, IDLE | SUSPEND | MODESET | DPMS | RPM },
 		{ }
 	}, *f;
 	enum pipe p;
@@ -339,6 +410,11 @@ igt_main
 		{ "forked", IDLE | FORKED },
 		{ "busy", BUSY },
 		{ "forked-busy", BUSY | FORKED },
+		{ "dpms-rpm", DPMS | RPM | NOHANG },
+		{ "dpms-suspend", DPMS | SUSPEND | NOHANG},
+		{ "suspend", SUSPEND | NOHANG },
+		{ "modeset", MODESET },
+		{ "modeset-rpm", MODESET | RPM | NOHANG},
 		{ }
 	}, *m;
 
-- 
2.15.1

_______________________________________________
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