lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1467682622-24945-1-git-send-email-pei.zhan.tan@intel.com>
Date:	Tue,  5 Jul 2016 09:37:02 +0800
From:	peizhant <pei.zhan.tan@...el.com>
To:	linux-kernel@...r.kernel.org, pei.zhan.tan@...el.com
Subject: [PATCH] test/kms_atomic:Added allow_modeset flag

From: Tan Pei Zhan <pei.zhan.tan@...el.com>

added two subtests :
i) igt_subtest "allow_modeset"
added a DRM_MODE_ATOMIC_ALLOW_MODESET flag to the flags at
ioc.flag, and verify that it still fails

ii) igt_subtest "plane_primary_allow_modeset"
added ioc.flags in the  plane_primary function

Signed-off-by: Tan Pei Zhan <pei.zhan.tan@...el.com>
---
 tests/kms_atomic.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 112 insertions(+), 2 deletions(-)

diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
index f27ee46..62ee8cc 100644
--- a/tests/kms_atomic.c
+++ b/tests/kms_atomic.c
@@ -219,7 +219,7 @@ static uint32_t blob_duplicate(int fd, uint32_t id_orig)
 #define crtc_set_prop(req, crtc, prop, value) \
 	igt_assert_lt(0, drmModeAtomicAddProperty(req, crtc->obj, \
 						  crtc->state->desc->props_crtc[prop], \
-						  value));
+						  value)); 
 
 #define plane_set_prop(req, plane, prop, value) \
 	igt_assert_lt(0, drmModeAtomicAddProperty(req, plane->obj, \
@@ -227,7 +227,7 @@ static uint32_t blob_duplicate(int fd, uint32_t id_orig)
 						  value));
 
 #define do_atomic_commit(fd, req, flags) \
-	do_or_die(drmModeAtomicCommit(fd, req, flags, NULL));
+	do_or_die(drmModeAtomicCommit(fd, req, flags, NULL)); 
 
 #define do_atomic_commit_err(fd, req, flags, err) { \
 	igt_assert_neq(drmModeAtomicCommit(fd, req, flags, NULL), 0); \
@@ -1280,6 +1280,88 @@ static void atomic_invalid_params(struct kms_atomic_crtc_state *crtc,
 	do_ioctl_err(desc->fd, DRM_IOCTL_MODE_ATOMIC, &ioc, EFAULT);
 }
 
+static void allow_modeset(struct kms_atomic_crtc_state *crtc,
+				  struct kms_atomic_plane_state *plane,
+				  struct kms_atomic_connector_state *connector)
+{
+	struct kms_atomic_desc *desc = crtc->state->desc;
+	struct drm_mode_atomic ioc;
+
+	memset(&ioc, 0, sizeof(ioc));
+
+	/* Valid pointers, but still should copy nothing. */
+	do_ioctl(desc->fd, DRM_IOCTL_MODE_ATOMIC, &ioc);
+
+	/* Specifically forbidden combination. */
+	ioc.flags = DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_ATOMIC_ALLOW_MODESET;
+	do_ioctl_err(desc->fd, DRM_IOCTL_MODE_ATOMIC, &ioc, EINVAL);
+
+	ioc.flags = 0;
+	/* Safety check that flags is reset properly. */
+	do_ioctl(desc->fd, DRM_IOCTL_MODE_ATOMIC, &ioc);
+}
+
+static void plane_primary_allow_modeset(struct kms_atomic_crtc_state *crtc,
+			  struct kms_atomic_plane_state *plane_old)
+{
+	struct kms_atomic_desc *desc = crtc->state->desc;
+	struct drm_mode_modeinfo *mode = crtc->mode.data;
+	struct drm_mode_atomic ioc;
+	struct kms_atomic_plane_state plane = *plane_old;
+	uint32_t format = plane_get_igt_format(&plane);
+	drmModeAtomicReq *req = drmModeAtomicAlloc();
+	struct igt_fb fb;
+	memset(&ioc, 0, sizeof(ioc));
+
+	/* An empty request should do nothing. */
+	do_ioctl(desc->fd, DRM_IOCTL_MODE_ATOMIC, &ioc);
+
+	/* Specifically forbidden combination. */
+	ioc.flags = DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET | DRM_MODE_PAGE_FLIP_EVENT;
+	do_ioctl_err(desc->fd, DRM_IOCTL_MODE_ATOMIC, &ioc, EINVAL);
+
+	igt_require(format != 0);
+
+	plane.src_x = 0;
+	plane.src_y = 0;
+	plane.src_w = mode->hdisplay << 16;
+	plane.src_h = mode->vdisplay << 16;
+	plane.crtc_x = 0;
+	plane.crtc_y = 0;
+	plane.crtc_w = mode->hdisplay;
+	plane.crtc_h = mode->vdisplay;
+	plane.crtc_id = crtc->obj;
+	plane.fb_id = igt_create_pattern_fb(plane.state->desc->fd,
+					    plane.crtc_w, plane.crtc_h,
+					    format, I915_TILING_NONE, &fb);
+
+	/* Flip the primary plane using the atomic API, and double-check
+	 * state is what we think it should be. */
+	crtc_commit_atomic(crtc, &plane, req, ATOMIC_RELAX_NONE);
+
+	/* Restore the primary plane and check the state matches the old. */
+	crtc_commit_atomic(crtc, plane_old, req, ATOMIC_RELAX_NONE);
+
+	/* Re-enable the plane through the legacy CRTC/primary-plane API, and
+	 * verify through atomic. */
+	crtc_commit_legacy(crtc, &plane, CRTC_RELAX_MODE);
+
+	/* Restore the plane to its original settings through the legacy CRTC
+	 * API, and verify through atomic. */
+	crtc_commit_legacy(crtc, plane_old, CRTC_RELAX_MODE);
+
+	/* Finally, restore to the original state. */
+	crtc_commit_atomic(crtc, plane_old, req, ATOMIC_RELAX_NONE);
+	
+	ioc.flags = 0;
+	/* Safety check that flags is reset properly. */
+	do_ioctl(desc->fd, DRM_IOCTL_MODE_ATOMIC, &ioc);
+
+	drmModeAtomicFree(req);
+}
+
+
+
 igt_main
 {
 	struct kms_atomic_desc desc;
@@ -1372,9 +1454,37 @@ igt_main
 		atomic_invalid_params(crtc, plane, conn);
 		atomic_state_free(scratch);
 	}
+	
+	//do a modeset by setting the flag
+	igt_subtest("allow_modeset") {
+		struct kms_atomic_state *scratch = atomic_state_dup(current);
+		struct kms_atomic_crtc_state *crtc = find_crtc(scratch, true);
+		struct kms_atomic_plane_state *plane =
+			find_plane(scratch, NUM_PLANE_TYPE_PROPS, crtc);
+		struct kms_atomic_connector_state *conn =
+			find_connector(scratch, crtc);
 
+		igt_require(plane);
+		igt_require(conn);
+		allow_modeset(crtc, plane, conn);
+		atomic_state_free(scratch);
+	}
+	
+	//do a modeset with primary plane
+	igt_subtest("plane_primary_allow_modeset") {
+		struct kms_atomic_state *scratch = atomic_state_dup(current);
+		struct kms_atomic_crtc_state *crtc = find_crtc(scratch, true);
+		struct kms_atomic_plane_state *plane =
+			find_plane(scratch, PLANE_TYPE_PRIMARY, crtc);
+			
+		igt_require(crtc);
+		igt_require(plane);
+		plane_primary_allow_modeset(crtc, plane);
+		atomic_state_free(scratch);
+	}
 	atomic_state_free(current);
 
 	igt_fixture
 		close(desc.fd);
 }
+
-- 
2.5.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ