summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkash Goel <akash.goel@intel.com>2015-01-02 16:33:34 +0530
committerDaniel Vetter <daniel.vetter@ffwll.ch>2015-01-06 09:29:45 +0100
commitf3e1a3d9f8cc366a1e0dbda42f3da9d37064fcd0 (patch)
tree9d030978e24ac85fd1420f803de4c2e5c6983c1d
parentf2a045f851fa46b2674d455fd5560bdc1fe21a0c (diff)
igt/gem_mmap_wc: Add the invalid flags subtest
A new subtest added to validate the new version of gem_mmap ioctl, for creating the wc mappings, on yet to be supported flags. v2: Removed the flags checking for older kernels (Daniel) Signed-off-by: Akash Goel <akash.goel@intel.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--tests/gem_mmap_wc.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/gem_mmap_wc.c b/tests/gem_mmap_wc.c
index 87140ff1..4881ab73 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)
@@ -76,6 +87,45 @@ 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;
+ }
+ }
+
+ gem_close(fd, arg.handle);
+}
+
+static void
test_copy(int fd)
{
void *src, *dst;
@@ -336,6 +386,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")