[igt-dev] [PATCH 1/2] i915/gem_exec_blt: Verify data after blitter copy

Vanshidhar Konda vanshidhar.r.konda at intel.com
Fri Nov 1 17:44:12 UTC 2019


Verify the data after the blitter engine has copied data from source to
destination.

Signed-off-by: Vanshidhar Konda <vanshidhar.r.konda at intel.com>
---
 tests/i915/gem_exec_blt.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/tests/i915/gem_exec_blt.c b/tests/i915/gem_exec_blt.c
index ffb60d0c..6be73f53 100644
--- a/tests/i915/gem_exec_blt.c
+++ b/tests/i915/gem_exec_blt.c
@@ -182,6 +182,18 @@ static int dcmp(const void *A, const void *B)
 		return 0;
 }
 
+static void init_buffer_data(void *addr, int object_size, uint32_t base_dword)
+{
+	uint32_t *base_addr = (uint32_t *)addr;
+	int num_itr = object_size/sizeof(uint32_t);
+
+	for (int i = 0; i < num_itr; i++)
+		base_addr[i] = base_dword + i;
+}
+
+#define verify_data(src__, dst__, size) \
+	igt_assert_eq(memcmp(src__, dst__, size), 0)
+
 static void run(int fd, int object_size, bool dumb)
 {
 	struct drm_i915_gem_execbuffer2 execbuf;
@@ -191,6 +203,7 @@ static void run(int fd, int object_size, bool dumb)
 	uint32_t handle, src, dst;
 	int len, count;
 	int ring;
+	void *src_buffer, *dst_buffer;
 
 	if (dumb)
 		handle = kmstest_dumb_create(fd, 32, 32, 32, NULL, NULL);
@@ -200,6 +213,12 @@ static void run(int fd, int object_size, bool dumb)
 	src = gem_create(fd, object_size);
 	dst = gem_create(fd, object_size);
 
+	src_buffer = gem_mmap__wc(fd, src, 0, object_size, PROT_WRITE);
+	dst_buffer = gem_mmap__wc(fd, src, 0, object_size,
+				PROT_READ | PROT_WRITE);
+
+	init_buffer_data(src_buffer, object_size, 0xcafe);
+
 	len = gem_linear_blt(fd, buf, 0, 1, object_size, reloc);
 	gem_write(fd, handle, 0, buf, len);
 
@@ -235,6 +254,8 @@ static void run(int fd, int object_size, bool dumb)
 	}
 	gem_sync(fd, handle);
 
+	verify_data(src_buffer, dst_buffer, object_size);
+
 	for (count = 1; count <= 1<<12; count <<= 1) {
 		struct timeval start, end;
 		const int reps = 9;
@@ -242,11 +263,13 @@ static void run(int fd, int object_size, bool dumb)
 		int n;
 
 		for (n = 0; n < reps; n++) {
+			memset(dst_buffer, 0, object_size);
 			gettimeofday(&start, NULL);
 			for (int loop = 0; loop < count; loop++)
 				gem_execbuf(fd, &execbuf);
 			gem_sync(fd, handle);
 			gettimeofday(&end, NULL);
+			verify_data(src_buffer, dst_buffer, object_size);
 			t[n] = elapsed(&start, &end, count);
 		}
 		qsort(t, n, sizeof(double), dcmp);
@@ -259,6 +282,10 @@ static void run(int fd, int object_size, bool dumb)
 			 bytes_per_sec((char *)buf, object_size/sum*1e6));
 		fflush(stdout);
 	}
+
+	munmap(src_buffer, object_size);
+	munmap(dst_buffer, object_size);
+
 	gem_close(fd, handle);
 }
 
-- 
2.23.0



More information about the igt-dev mailing list