summaryrefslogtreecommitdiff
path: root/tests/gem_mmap.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2015-08-14 13:40:01 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2015-08-14 14:08:05 +0100
commitd568f69d5da9e4cc7bb7f1c405b3b8a17ac77fe3 (patch)
tree4c02bfbed987194e5db71fb4b2c4b672f8757eb5 /tests/gem_mmap.c
parent8af62be2ada2d4a2c618a48548f4248ef397582f (diff)
igt/gem_mmap: Add one more extra large bo
Daniel complained that all the tests in gem_mmap.c were too quick. This one aims to rectify that by double checking that if we mmap a buffer larger enough to force swapping, everything still works. Also fix the test to exercise the different object sizes! Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/gem_mmap.c')
-rw-r--r--tests/gem_mmap.c60
1 files changed, 41 insertions, 19 deletions
diff --git a/tests/gem_mmap.c b/tests/gem_mmap.c
index 095f5b9f..822c97e3 100644
--- a/tests/gem_mmap.c
+++ b/tests/gem_mmap.c
@@ -44,13 +44,14 @@
int fd;
static void
-test_huge_bo(int huge, int tiling)
+test_huge_bo(int huge)
{
- uint64_t huge_object_size, last_offset;
+ uint64_t huge_object_size, last_offset, i;
+ unsigned check = CHECK_RAM;
char *ptr_cpu;
char *cpu_pattern;
uint32_t bo;
- int i;
+ int loop;
switch (huge) {
case -1:
@@ -59,11 +60,17 @@ test_huge_bo(int huge, int tiling)
case 0:
huge_object_size = gem_mappable_aperture_size() + PAGE_SIZE;
break;
- default:
+ case 1:
huge_object_size = gem_aperture_size(fd) + PAGE_SIZE;
break;
+ case 2:
+ huge_object_size = (intel_get_total_ram_mb() + 1) << 20;
+ check |= CHECK_SWAP;
+ break;
+ default:
+ return;
}
- intel_require_memory(1, huge_object_size, CHECK_RAM);
+ intel_require_memory(1, huge_object_size, check);
last_offset = huge_object_size - PAGE_SIZE;
@@ -77,22 +84,35 @@ test_huge_bo(int huge, int tiling)
/* Obtain CPU mapping for the object. */
ptr_cpu = gem_mmap__cpu(fd, bo, 0, huge_object_size,
PROT_READ | PROT_WRITE);
- igt_assert(ptr_cpu);
+ igt_require(ptr_cpu);
gem_set_domain(fd, bo, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
gem_close(fd, bo);
- /* Write first page through the mapping and assert reading it back
- * works. */
- memcpy(ptr_cpu, cpu_pattern, PAGE_SIZE);
- igt_assert(memcmp(ptr_cpu, cpu_pattern, PAGE_SIZE) == 0);
+ igt_debug("Exercising %'llu bytes\n", (long long)huge_object_size);
+
+ loop = 0;
+ do {
+ /* Write first page through the mapping and
+ * assert reading it back works.
+ */
+ memcpy(ptr_cpu, cpu_pattern, PAGE_SIZE);
+ igt_assert(memcmp(ptr_cpu, cpu_pattern, PAGE_SIZE) == 0);
+ memset(ptr_cpu, 0xcc, PAGE_SIZE);
+
+ /* Write last page through the mapping and
+ * assert reading it back works.
+ */
+ memcpy(ptr_cpu + last_offset, cpu_pattern, PAGE_SIZE);
+ igt_assert(memcmp(ptr_cpu + last_offset, cpu_pattern, PAGE_SIZE) == 0);
+ memset(ptr_cpu + last_offset, 0xcc, PAGE_SIZE);
- /* Write last page through the mapping and assert reading it back
- * works. */
- memcpy(ptr_cpu + last_offset, cpu_pattern, PAGE_SIZE);
- igt_assert(memcmp(ptr_cpu + last_offset, cpu_pattern, PAGE_SIZE) == 0);
+ /* Cross check that accessing two simultaneous pages works. */
+ igt_assert(memcmp(ptr_cpu, ptr_cpu + last_offset, PAGE_SIZE) == 0);
- /* Cross check that accessing two simultaneous pages works. */
- igt_assert(memcmp(ptr_cpu, ptr_cpu + last_offset, PAGE_SIZE) == 0);
+ /* Force every page to be faulted and retest */
+ for (i = 0; i < huge_object_size; i += 4096)
+ ptr_cpu[i] = i >> 12;
+ } while (loop++ == 0);
munmap(ptr_cpu, huge_object_size);
free(cpu_pattern);
@@ -155,11 +175,13 @@ igt_main
}
igt_subtest("small-bo")
- test_huge_bo(fd, -1);
+ test_huge_bo(-1);
igt_subtest("big-bo")
- test_huge_bo(fd, 0);
+ test_huge_bo(0);
igt_subtest("huge-bo")
- test_huge_bo(fd, 1);
+ test_huge_bo(1);
+ igt_subtest("swap-bo")
+ test_huge_bo(2);
igt_fixture
close(fd);