Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: akash.goel@intel.com
To: intel-gfx@lists.freedesktop.org
Cc: Akash Goel <akash.goel@intel.com>
Subject: [PATCH] igt/gem_mmap_wc: Add the invalid flags subtest
Date: Tue, 25 Nov 2014 14:28:52 +0530	[thread overview]
Message-ID: <1416905932-10566-1-git-send-email-akash.goel@intel.com> (raw)
In-Reply-To: <20141117183634.GG25711@phenom.ffwll.local>

From: Akash Goel <akash.goel@intel.com>

A new subtest added to validate the new version of gem_mmap ioctl,
for creating the wc mappings, on yet to be supported flags.
Older kernel is also checked against the flags field, which should
be treated as a don't care by it.

Signed-off-by: Akash Goel <akash.goel@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/gem_mmap_wc.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/tests/gem_mmap_wc.c b/tests/gem_mmap_wc.c
index 6f91a89..f923553 100644
--- a/tests/gem_mmap_wc.c
+++ b/tests/gem_mmap_wc.c
@@ -41,6 +41,17 @@
 #include "drmtest.h"
 #include "igt_debugfs.h"
 
+struct local_i915_gem_mmap_v2 {
+	uint32_t handle;
+	uint32_t pad;
+	uint64_t offset;
+	uint64_t size;
+	uint64_t addr_ptr;
+	uint64_t flags;
+#define I915_MMAP_WC 0x1
+};
+#define LOCAL_IOCTL_I915_GEM_MMAP_v2 DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct local_i915_gem_mmap_v2)
+
 static int OBJECT_SIZE = 16*1024*1024;
 
 static void set_domain(int fd, uint32_t handle)
@@ -75,6 +86,59 @@ create_pointer(int fd)
 }
 
 static void
+test_invalid_flags(int fd)
+{
+	struct drm_i915_getparam gp;
+	struct local_i915_gem_mmap_v2 arg;
+	uint64_t flag = I915_MMAP_WC;
+	int val = -1;
+
+	memset(&arg, 0, sizeof(arg));
+	arg.handle = gem_create(fd, 4096);
+	arg.offset = 0;
+	arg.size = 4096;
+
+	memset(&gp, 0, sizeof(gp));
+	gp.param = 30; /* MMAP_VERSION */
+	gp.value = &val;
+
+	/* Do we have the new mmap_ioctl? */
+	do_ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+
+	if (val >= 1) {
+		/*
+		 * Only MMAP_WC flag is supported in version 1, so any other
+		 * flag should be rejected.
+		 */
+		flag <<= 1;
+		while (flag) {
+			arg.flags = flag;
+			igt_assert(drmIoctl(fd,
+				   LOCAL_IOCTL_I915_GEM_MMAP_v2,
+				   &arg) == -1);
+			igt_assert_eq(errno, EINVAL);
+			flag <<= 1;
+		}
+	} else {
+		/*
+		 * flags field should be ignored by older kernel
+		 * and so irrespective of the flag value passed,
+		 * mmap call should succeed
+		 */
+		while (flag) {
+			arg.flags = flag;
+			igt_assert(drmIoctl(fd,
+				   LOCAL_IOCTL_I915_GEM_MMAP_v2,
+				   &arg) == 0);
+			munmap(arg.addr_ptr, 4096);
+			flag <<= 1;
+		}
+	}
+
+	gem_close(fd, arg.handle);
+}
+
+static void
 test_copy(int fd)
 {
        void *src, *dst;
@@ -331,6 +395,8 @@ igt_main
        igt_fixture
                fd = drm_open_any();
 
+       igt_subtest("invalid flags")
+               test_invalid_flags(fd);
        igt_subtest("copy")
                test_copy(fd);
        igt_subtest("read")
-- 
1.9.2

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

  reply	other threads:[~2014-11-25  8:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-17 11:37 [PATCH 1/5] igt/gem_mmap_wc: Exercise mmap(wc) interface Chris Wilson
2014-11-17 11:37 ` [PATCH 2/5] igt/gem_tiled_wc: Exercise wc mmaps with swizzling Chris Wilson
2014-11-17 11:37 ` [PATCH 3/5] igt/gem_gtt_speed: compare against WC mmaps Chris Wilson
2014-11-17 11:37 ` [PATCH 4/5] igt/gem_fence_upload: Add comparison against wc mmaps Chris Wilson
2014-11-17 11:37 ` [PATCH 5/5] igt/gem_concurrent_blit: Exercise wc mappings Chris Wilson
2014-11-17 11:40 ` [PATCH 1/5] igt/gem_mmap_wc: Exercise mmap(wc) interface Chris Wilson
2014-11-17 18:36 ` Daniel Vetter
2014-11-25  8:58   ` akash.goel [this message]
2014-11-25 11:30     ` [PATCH] igt/gem_mmap_wc: Add the invalid flags subtest Daniel Vetter
2014-12-03 12:58       ` Akash Goel
2014-12-04  4:41       ` [PATCH v2] " akash.goel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1416905932-10566-1-git-send-email-akash.goel@intel.com \
    --to=akash.goel@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox