[igt-dev] [PATCH i-g-t 8/9] tests/kms_lease: validate implicitly added planes

Daniel Vetter daniel.vetter at ffwll.ch
Wed Feb 20 16:25:29 UTC 2019


Without universal planes the kernel should auto-add the (in that case
hidden) primary and cursor planes. Check this works and all the error
handling is there for evil userspace.

Cc: Keith Packard <keithp at keithp.com>
Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
---
 tests/kms_lease.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/tests/kms_lease.c b/tests/kms_lease.c
index e064b6274789..d082a7988eaa 100644
--- a/tests/kms_lease.c
+++ b/tests/kms_lease.c
@@ -929,6 +929,53 @@ static void multimaster_lease(data_t *data)
 	close(lease_fd);
 }
 
+static void implicit_plane_lease(data_t *data)
+{
+	uint32_t object_ids[3];
+	struct local_drm_mode_create_lease mcl;
+	struct local_drm_mode_get_lease mgl;
+
+	uint32_t cursor_id = igt_pipe_get_plane_type(&data->master.display.pipes[0],
+						     DRM_PLANE_TYPE_CURSOR)->drm_plane->plane_id;
+
+	object_ids[0] = data->master.display.pipes[0].crtc_id;
+	object_ids[1] = data->master.display.outputs[0].id;
+	object_ids[2] = igt_pipe_get_plane_type(&data->master.display.pipes[0],
+						DRM_PLANE_TYPE_PRIMARY)->drm_plane->plane_id;
+	mcl.object_ids = (uint64_t) (uintptr_t) object_ids;
+	mcl.object_count = 3;
+	mcl.flags = 0;
+
+	/* sanity check */
+	igt_assert_eq(create_lease(data->master.fd, &mcl), 0);
+	close(mcl.fd);
+	drmSetClientCap(data->master.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 0);
+
+	/* non universal plane automatically adds primary/cursor plane */
+	mcl.object_count = 2;
+	igt_assert_eq(create_lease(data->master.fd, &mcl), 0);
+
+	mgl.pad = 0;
+	mgl.count_objects = 0;
+	mgl.objects_ptr = 0;
+	igt_assert_eq(get_lease(mcl.fd, &mgl), 0);
+
+	igt_assert_eq(mgl.count_objects, 3 + (cursor_id ? 1 : 0));
+
+	close(mcl.fd);
+
+	/* check that implicit lease doesn't lead to confusion when
+	 * explicitly adding primary plane */
+	mcl.object_count = 3;
+	igt_assert_eq(create_lease(data->master.fd, &mcl), -ENOSPC);
+
+	/* same for the cursor */
+	object_ids[2] = cursor_id;
+	igt_assert_eq(create_lease(data->master.fd, &mcl), -ENOSPC);
+
+	drmSetClientCap(data->master.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
+}
+
 igt_main
 {
 	data_t data;
@@ -973,4 +1020,7 @@ igt_main
 
 	igt_subtest("multimaster-lease")
 		multimaster_lease(&data);
+
+	igt_subtest("implicit-plane-lease")
+		implicit_plane_lease(&data);
 }
-- 
2.14.4



More information about the igt-dev mailing list