summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2015-04-26 10:13:49 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2015-04-26 10:17:18 +0100
commitbe6e32b9254f2740da0a287caf2eaa1d745b77a3 (patch)
tree8295e7a5ad9e6ad3f1fcbc505f90d8dfbff2bf92
parentdfda0b6aeccef464cc6f1af60d8ea16c11fb13f7 (diff)
igt/gem_pwrite: Test handling of larger than mappable buffers
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--tests/gem_pwrite.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/tests/gem_pwrite.c b/tests/gem_pwrite.c
index 6378b0a4..420653dc 100644
--- a/tests/gem_pwrite.c
+++ b/tests/gem_pwrite.c
@@ -39,6 +39,7 @@
#include "drm.h"
#include "ioctl_wrappers.h"
#include "drmtest.h"
+#include "igt_aux.h"
#define OBJECT_SIZE 16384
@@ -80,6 +81,59 @@ static const char *bytes_per_sec(char *buf, double v)
return buf;
}
+static void test_big_cpu(int fd)
+{
+ uint32_t handle;
+ uint32_t *ptr;
+ uint64_t offset, size;
+
+ size = 3 * gem_aperture_size(fd) / 4;
+ intel_require_memory(1, size, CHECK_RAM);
+
+ igt_require(gem_mmap__has_wc(fd));
+
+ handle = gem_create(fd, size);
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
+
+ ptr = gem_mmap__wc(fd, handle, 0, size, PROT_READ);
+ for (offset = 0; offset < size; offset += 4096) {
+ int suboffset = (offset >> 12) % (4096 - sizeof(offset));
+ uint64_t tmp;
+
+ gem_write(fd, handle, offset + suboffset , &offset, sizeof(offset));
+ gem_read(fd, handle, offset + suboffset, &tmp, sizeof(tmp));
+ igt_assert_eq(offset, tmp);
+ }
+
+ munmap(ptr, size);
+ gem_close(fd, handle);
+}
+
+static void test_big_gtt(int fd)
+{
+ uint64_t offset, size;
+ uint64_t *ptr;
+ uint32_t handle;
+
+ size = 3 * gem_aperture_size(fd) / 4;
+ intel_require_memory(1, size, CHECK_RAM);
+
+ igt_require(gem_mmap__has_wc(fd));
+
+ handle = gem_create(fd, size);
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
+
+ ptr = gem_mmap__wc(fd, handle, 0, size, PROT_READ);
+ for (offset = 0; offset < size; offset += 4096) {
+ int suboffset = (offset >> 12) % (4096 / sizeof(offset) - 1) * sizeof(offset);
+
+ gem_write(fd, handle, offset + suboffset, &offset, sizeof(offset));
+ igt_assert_eq(ptr[(offset + suboffset)/sizeof(offset)], offset);
+ }
+
+ munmap(ptr, size);
+ gem_close(fd, handle);
+}
uint32_t *src, dst;
int fd;
@@ -153,9 +207,15 @@ int main(int argc, char **argv)
igt_fixture {
free(src);
gem_close(fd, dst);
+ }
+ igt_subtest("big-cpu")
+ test_big_cpu(fd);
+ igt_subtest("big-gtt")
+ test_big_gtt(fd);
+
+ igt_fixture
close(fd);
- }
igt_exit();
}