All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] tests/gem_mmap_gtt: add huge BO test
@ 2015-04-07 12:23 Joonas Lahtinen
  2015-04-07 14:08 ` Chris Wilson
  2015-04-13 11:32 ` [PATCH i-g-t] " Tvrtko Ursulin
  0 siblings, 2 replies; 16+ messages in thread
From: Joonas Lahtinen @ 2015-04-07 12:23 UTC (permalink / raw)
  To: intel-gfx

Add a straightforward test that allocates a BO that is bigger than
(by 1 page currently) the mappable aperture, tests mmap access to it
by CPU directly and through GTT in sequence.

Currently it is expected for the GTT access to gracefully fail as
all objects are attempted to get pinned to GTT completely for mmap
access. Once the partial view support is merged to kernel, the test
should pass for all parts.

Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 tests/gem_mmap_gtt.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/tests/gem_mmap_gtt.c b/tests/gem_mmap_gtt.c
index 55c66a2..bf3627c 100644
--- a/tests/gem_mmap_gtt.c
+++ b/tests/gem_mmap_gtt.c
@@ -41,6 +41,10 @@
 #include "drmtest.h"
 #include "igt_debugfs.h"
 
+#ifndef PAGE_SIZE
+#define PAGE_SIZE 4096
+#endif
+
 static int OBJECT_SIZE = 16*1024*1024;
 
 static void set_domain(int fd, uint32_t handle)
@@ -258,6 +262,68 @@ test_write_gtt(int fd)
 }
 
 static void
+test_huge_bo(int fd)
+{
+	uint32_t bo;
+	char *ptr_cpu;
+	char *ptr_gtt;
+	char *cpu_pattern;
+	uint64_t mappable_aperture_pages = gem_mappable_aperture_size() /
+					   PAGE_SIZE;
+	uint64_t huge_object_size = (mappable_aperture_pages + 1) * PAGE_SIZE;
+	uint64_t last_offset = huge_object_size - PAGE_SIZE;
+
+	cpu_pattern = malloc(PAGE_SIZE);
+	igt_assert(cpu_pattern);
+	memset(cpu_pattern, 0xaa, PAGE_SIZE);
+
+	bo = gem_create(fd, huge_object_size);
+
+	ptr_cpu = gem_mmap__cpu(fd, bo, 0, huge_object_size,
+				PROT_READ | PROT_WRITE);
+	if (!ptr_cpu) {
+		igt_warn("Not enough free memory for huge BO test!\n");
+		goto out;
+	}
+
+	/* Test read/write to first/last page with CPU. */
+	memcpy(ptr_cpu, cpu_pattern, PAGE_SIZE);
+	igt_assert(memcmp(ptr_cpu, cpu_pattern, PAGE_SIZE) == 0);
+
+	memcpy(ptr_cpu + last_offset, cpu_pattern, PAGE_SIZE);
+	igt_assert(memcmp(ptr_cpu + last_offset, cpu_pattern, PAGE_SIZE) == 0);
+
+	igt_assert(memcmp(ptr_cpu, ptr_cpu + last_offset, PAGE_SIZE) == 0);
+
+	munmap(ptr_cpu, huge_object_size);
+	ptr_cpu = NULL;
+
+	ptr_gtt = gem_mmap__gtt(fd, bo, huge_object_size,
+			        PROT_READ | PROT_WRITE);
+	if (!ptr_gtt) {
+		igt_debug("Huge BO GTT mapping not supported!\n");
+		goto out;
+	}
+
+	/* Test read/write to first/last page through GTT. */
+	set_domain(fd, bo);
+
+	igt_assert(memcmp(ptr_gtt, cpu_pattern, PAGE_SIZE) == 0);
+	igt_assert(memcmp(ptr_gtt + last_offset, cpu_pattern, PAGE_SIZE) == 0);
+
+	memset(ptr_gtt, 0x55, PAGE_SIZE);
+	igt_assert(memcmp(ptr_gtt + last_offset, cpu_pattern, PAGE_SIZE) == 0);
+
+	memset(ptr_gtt + last_offset, 0x55, PAGE_SIZE);
+	igt_assert(memcmp(ptr_gtt, ptr_gtt + last_offset, PAGE_SIZE) == 0);
+
+	munmap(ptr_gtt, huge_object_size);
+out:
+	gem_close(fd, bo);
+	free(cpu_pattern);
+}
+
+static void
 test_read(int fd)
 {
 	void *dst;
@@ -395,6 +461,8 @@ igt_main
 		run_without_prefault(fd, test_write_gtt);
 	igt_subtest("write-cpu-read-gtt")
 		test_write_cpu_read_gtt(fd);
+	igt_subtest("huge-bo")
+		test_huge_bo(fd);
 
 	igt_fixture
 		close(fd);
-- 
1.9.3



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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-04-14 16:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-07 12:23 [PATCH i-g-t] tests/gem_mmap_gtt: add huge BO test Joonas Lahtinen
2015-04-07 14:08 ` Chris Wilson
2015-04-08 10:45   ` Joonas Lahtinen
2015-04-08 10:50   ` [PATCH i-g-t v2 1/2] tests/gem_mmap_gtt: Clarify BO domain setting functions Joonas Lahtinen
2015-04-08 10:51   ` [PATCH i-g-t v2 2/2] tests/gem_mmap_gtt: add huge BO test Joonas Lahtinen
2015-04-08 11:00     ` Chris Wilson
2015-04-08 12:55       ` [PATCH i-g-t v3 1/2] tests/gem_mmap_gtt: clarify BO domain setting functions Joonas Lahtinen
2015-04-13  6:03         ` Joonas Lahtinen
2015-04-08 12:57       ` [PATCH i-g-t v3 2/2] tests/gem_mmap_gtt: add huge BO test Joonas Lahtinen
2015-04-13 11:32 ` [PATCH i-g-t] " Tvrtko Ursulin
2015-04-13 14:22   ` Joonas Lahtinen
2015-04-13 14:49     ` Tvrtko Ursulin
2015-04-14 11:14       ` [PATCH i-g-t v5] " Joonas Lahtinen
2015-04-14 11:23         ` Tvrtko Ursulin
2015-04-14 16:51         ` Thomas Wood
2015-04-13 14:22   ` [PATCH i-g-t v4 2/2] " Joonas Lahtinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.