[PATCH i-g-t] tests/gem_mmap_gtt(huge_bo): Use pread more to verify domain transfer.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use pread right after moving out of CPU domain to verify all
writes flushed correctly.

Due to extended usage, add own buffer.

Signed-off-by: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>
---
 tests/gem_mmap_gtt.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/tests/gem_mmap_gtt.c b/tests/gem_mmap_gtt.c
index 92fa644..e53ab13 100644
--- a/tests/gem_mmap_gtt.c
+++ b/tests/gem_mmap_gtt.c
@@ -291,6 +291,7 @@ test_huge_bo(int fd)
 	char *ptr_gtt;
 	char *cpu_pattern;
 	char *gtt_pattern;
+	char *pread_buffer;
 	uint64_t mappable_aperture_pages = gem_mappable_aperture_size() /
 					   PAGE_SIZE;
 	uint64_t huge_object_size = (mappable_aperture_pages + 1) * PAGE_SIZE;
@@ -298,7 +299,8 @@ test_huge_bo(int fd)
 
 	cpu_pattern = malloc(PAGE_SIZE);
 	gtt_pattern = malloc(PAGE_SIZE);
-	igt_assert(cpu_pattern && gtt_pattern);
+	pread_buffer = malloc(PAGE_SIZE);
+	igt_assert(cpu_pattern && gtt_pattern && pread_buffer);
 	memset(cpu_pattern,  0xaa, PAGE_SIZE);
 	memset(gtt_pattern, ~0xaa, PAGE_SIZE);
 
@@ -334,6 +336,17 @@ test_huge_bo(int fd)
 
 	set_domain_gtt(fd, bo);
 
+	/* Verify the page contents via pread after domain transfer.
+	 * This is to make sure the transfer actually flushed everything.
+	 */
+	memset(pread_buffer, 0, PAGE_SIZE);
+	pread_bo(fd, bo, pread_buffer, 0, PAGE_SIZE);
+	igt_assert(memcmp(pread_buffer, cpu_pattern, PAGE_SIZE) == 0);
+
+	memset(pread_buffer, 0, PAGE_SIZE);
+	pread_bo(fd, bo, pread_buffer, last_offset, PAGE_SIZE);
+	igt_assert(memcmp(pread_buffer, cpu_pattern, PAGE_SIZE) == 0);
+
 	/* Access through GTT should still provide the CPU written values. */
 	igt_assert(memcmp(ptr_gtt              , cpu_pattern, PAGE_SIZE) == 0);
 	igt_assert(memcmp(ptr_gtt + last_offset, cpu_pattern, PAGE_SIZE) == 0);
@@ -356,17 +369,18 @@ test_huge_bo(int fd)
 	/* Verify the page contents after GTT writes by reading without mapping.
 	 * Mapping to CPU domain is avoided not to cause a huge flush.
 	 */
-	pread_bo(fd, bo, cpu_pattern, 0, PAGE_SIZE);
-	igt_assert(memcmp(cpu_pattern, gtt_pattern, PAGE_SIZE) == 0);
-
-	memset(cpu_pattern, 0x00, PAGE_SIZE);
+	memset(pread_buffer, 0x00, PAGE_SIZE);
+	pread_bo(fd, bo, pread_buffer, 0, PAGE_SIZE);
+	igt_assert(memcmp(pread_buffer, gtt_pattern, PAGE_SIZE) == 0);
 
-	pread_bo(fd, bo, cpu_pattern, last_offset, PAGE_SIZE);
-	igt_assert(memcmp(cpu_pattern, gtt_pattern, PAGE_SIZE) == 0);
+	memset(pread_buffer, 0x00, PAGE_SIZE);
+	pread_bo(fd, bo, pread_buffer, last_offset, PAGE_SIZE);
+	igt_assert(memcmp(pread_buffer, gtt_pattern, PAGE_SIZE) == 0);
 
 	gem_close(fd, bo);
 	free(cpu_pattern);
 	free(gtt_pattern);
+	free(pread_buffer);
 }
 
 static void
-- 
1.9.3





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





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux