[PATCH 5/5] tests/gem_disable_prefault: add pread slow path subtest

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

 



First disable prefault, then map src bo to gtt map, so pread from dst bo to
src bo, it will run pread_slow path, finally enable prefault

Signed-off-by: Xiong Zhang <xiong.y.zhang@xxxxxxxxx>
---
 tests/gem_disable_prefault.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/tests/gem_disable_prefault.c b/tests/gem_disable_prefault.c
index b6b2d59..76663ec 100644
--- a/tests/gem_disable_prefault.c
+++ b/tests/gem_disable_prefault.c
@@ -184,6 +184,45 @@ test_disable_prefault_write(int fd)
 	gem_close(fd, src);
 }
 
+static void
+test_disable_prefault_read(int fd)
+{
+	uint32_t src, dst;
+	void *ptr;
+	int  i;
+	uint8_t *tmp;
+
+	src = gem_create(fd, OBJECT_SIZE);
+	dst = gem_create(fd, OBJECT_SIZE);
+
+	/* write test_val to dst object */
+	ptr = gem_mmap__cpu(fd, dst, OBJECT_SIZE, PROT_READ | PROT_WRITE);
+	assert(ptr != NULL);
+	tmp = (uint8_t *)ptr;
+	memset(tmp, TEST_VALUE, OBJECT_SIZE);
+
+	drmtest_disable_prefault();
+	ptr = mmap_bo(fd, src, OBJECT_SIZE);
+	gem_read(fd, dst, 0, ptr, OBJECT_SIZE);
+	munmap(ptr, OBJECT_SIZE);
+	drmtest_enable_prefault();
+
+	/* compare src object to test_val */
+	ptr = gem_mmap__cpu(fd, src, OBJECT_SIZE, PROT_READ | PROT_WRITE);
+	assert(ptr != NULL);
+	tmp = (uint8_t *)ptr;
+	for (i = 0; i < OBJECT_SIZE; i++) {
+		if (tmp[i] != TEST_VALUE) {
+			printf("mismatch at %i, got: %i\n",
+					i, tmp[i]);
+			break;
+		}
+	}
+
+	gem_close(fd, dst);
+	gem_close(fd, src);
+}
+
 int main(int argc, char **argv)
 {
 	int fd;
@@ -204,6 +243,9 @@ int main(int argc, char **argv)
 	if (drmtest_run_subtest("write"))
 		test_disable_prefault_write(fd);
 
+	if (drmtest_run_subtest("read"))
+		test_disable_prefault_read(fd);
+
 	close(fd);
 
 	return 0;
-- 
1.8.3.2

_______________________________________________
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