[PATCH libdrm] tests: Test mapping different caching types on etnaviv

Guido Günther agx at sigxcpu.org
Fri Sep 14 12:05:53 UTC 2018


This makes it simple to test if all cache types are mappable.

Signed-off-by: Guido Günther <guido.gunther at puri.sm>
---
Prompted by 

  https://lists.freedesktop.org/archives/etnaviv/2018-September/001946.html

 tests/etnaviv/etnaviv_bo_cache_test.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/tests/etnaviv/etnaviv_bo_cache_test.c b/tests/etnaviv/etnaviv_bo_cache_test.c
index 7fb06293..0ad37e19 100644
--- a/tests/etnaviv/etnaviv_bo_cache_test.c
+++ b/tests/etnaviv/etnaviv_bo_cache_test.c
@@ -28,6 +28,7 @@
 #include <assert.h>
 
 #include <fcntl.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
@@ -78,6 +79,28 @@ static void test_size_rounding(struct etna_device *dev)
 	printf("ok\n");
 }
 
+
+static void test_write(struct etna_device *dev, uint32_t flags)
+{
+	struct etna_bo *bo;
+	uint32_t *buf;
+
+	/* allocate, map, write to, and free of a bo */
+	printf("testing bo map with flags 0x%"PRIx32"... ", flags);
+	fflush(stdout);
+
+	bo = etna_bo_new(dev, 0x100, flags);
+	assert(bo);
+	buf = etna_bo_map(bo);
+	assert(buf);
+	assert(!etna_bo_cpu_prep(bo, DRM_ETNA_PREP_WRITE));
+	memset(buf, 0, 0x100);
+	etna_bo_cpu_fini(bo);
+	etna_bo_del(bo);
+
+	printf("ok\n");
+}
+
 int main(int argc, char *argv[])
 {
 	struct etna_device *dev;
@@ -107,6 +130,9 @@ int main(int argc, char *argv[])
 
 	test_cache(dev);
 	test_size_rounding(dev);
+	test_write(dev, ETNA_BO_CACHED);
+	test_write(dev, ETNA_BO_WC);
+	test_write(dev, ETNA_BO_UNCACHED);
 
 	etna_device_del(dev);
 
-- 
2.18.0


More information about the dri-devel mailing list