summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-09-08 10:28:41 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2014-09-08 10:29:16 +0100
commitb76f1d8b03aa506624a8a9d7fab915758bd0dec5 (patch)
treebfc4414c8630bad71f96f1e3dcdaa1a9f35154c7
parentac3d06094a635bfeb0c6d6752f7f7bfbc21ecf2a (diff)
igt/gem_mmap_gtt: Check coherency between GTT and CPU mmappings with LLC
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--lib/ioctl_wrappers.c16
-rw-r--r--lib/ioctl_wrappers.h1
-rw-r--r--tests/gem_mmap_gtt.c27
3 files changed, 44 insertions, 0 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index c4e10808..39afc874 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -643,6 +643,22 @@ int gem_available_fences(int fd)
return val;
}
+bool gem_has_llc(int fd)
+{
+ struct drm_i915_getparam gp;
+ int val = 0;
+
+ memset(&gp, 0, sizeof(gp));
+ gp.param = I915_PARAM_HAS_LLC;
+ gp.value = &val;
+
+ if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
+ return 0;
+
+ errno = 0;
+ return val;
+}
+
/**
* gem_get_num_rings:
* @fd: open i915 drm file descriptor
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 310d82ea..b1deedf5 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -78,6 +78,7 @@ void gem_sw_finish(int fd, uint32_t handle);
bool gem_bo_busy(int fd, uint32_t handle);
/* feature test helpers */
+bool gem_has_llc(int fd);
int gem_get_num_rings(int fd);
bool gem_has_enable_ring(int fd,int param);
bool gem_has_bsd(int fd);
diff --git a/tests/gem_mmap_gtt.c b/tests/gem_mmap_gtt.c
index 6fad80a3..35c856f4 100644
--- a/tests/gem_mmap_gtt.c
+++ b/tests/gem_mmap_gtt.c
@@ -273,6 +273,31 @@ test_read(int fd)
munmap(dst, OBJECT_SIZE);
}
+static void
+test_write_cpu_read_gtt(int fd)
+{
+ uint32_t handle;
+ uint32_t *src, *dst;
+
+ igt_require(gem_has_llc(fd));
+
+ handle = gem_create(fd, OBJECT_SIZE);
+
+ dst = gem_mmap(fd, handle, OBJECT_SIZE, PROT_READ);
+ igt_assert(dst != (uint32_t *)MAP_FAILED);
+
+ src = gem_mmap__cpu(fd, handle, OBJECT_SIZE, PROT_WRITE);
+ igt_assert(src != (uint32_t *)MAP_FAILED);
+
+ gem_close(fd, handle);
+
+ memset(src, 0xaa, OBJECT_SIZE);
+ igt_assert(memcmp(dst, src, OBJECT_SIZE) == 0);
+
+ munmap(src, OBJECT_SIZE);
+ munmap(dst, OBJECT_SIZE);
+}
+
struct thread_fault_concurrent {
pthread_t thread;
int id;
@@ -368,6 +393,8 @@ igt_main
run_without_prefault(fd, test_write);
igt_subtest("write-gtt-no-prefault")
run_without_prefault(fd, test_write_gtt);
+ igt_subtest("write-cpu-read-gtt")
+ test_write_cpu_read_gtt(fd);
igt_fixture
close(fd);