[Intel-gfx] [PATCH 4/5] tests/gem_disable_prefault: add pwrite slow path subtest

Xiong Zhang xiong.y.zhang at intel.com
Fri Jul 19 07:53:11 CEST 2013


First disable prefault, then map src bo to gtt space, so when write src bo
to dst bo, it will run into pwrite_slow path. Finally enable prefault

Signed-off-by: Xiong Zhang <xiong.y.zhang at intel.com>
---
 tests/gem_disable_prefault.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/tests/gem_disable_prefault.c b/tests/gem_disable_prefault.c
index 9e6f0ad..b6b2d59 100644
--- a/tests/gem_disable_prefault.c
+++ b/tests/gem_disable_prefault.c
@@ -43,6 +43,7 @@
 #include "intel_gpu_tools.h"
 
 #define OBJECT_SIZE (16*1024*1024)
+#define TEST_VALUE  0x5a
 
 static void *
 mmap_bo(int fd, uint32_t handle, int size)
@@ -144,6 +145,45 @@ test_disable_prefault_reloc(int fd)
 	gem_close(fd, handle);
 }
 
+static void
+test_disable_prefault_write(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 src object */
+	ptr = gem_mmap__cpu(fd, src, 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_write(fd, dst, 0, ptr, OBJECT_SIZE);
+	munmap(ptr, OBJECT_SIZE);
+	drmtest_enable_prefault();
+
+	/* compare dst object to test_val */
+	ptr = gem_mmap__cpu(fd, dst, 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;
@@ -161,6 +201,9 @@ int main(int argc, char **argv)
 	if (drmtest_run_subtest("reloc"))
 		test_disable_prefault_reloc(fd);
 
+	if (drmtest_run_subtest("write"))
+		test_disable_prefault_write(fd);
+
 	close(fd);
 
 	return 0;
-- 
1.8.3.2




More information about the Intel-gfx mailing list