Skip to contentSkip to conversation

configure.ac: Test for libdrm_vc4 and build vc4 tests based on it.

PATCH In review Eric Anholt 2 participants 11 messages Feb 3, 2016 – Feb 4, 2016 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/9 configure.ac: Test for libdrm_vc4 and build vc4 tests based on it.

---
 configure.ac | 12 ++++++++++++
 1 file changed, 12 insertions(+)
configure.ac +12 -0
index ecbfacd..cfbcbf3 100644
@@ -149,6 +149,18 @@ if test "x$NOUVEAU" = xyes; then
 fi
 AM_CONDITIONAL(HAVE_NOUVEAU, [test "x$NOUVEAU" = xyes])
 
+AC_ARG_ENABLE(vc4, AS_HELP_STRING([--disable-vc4],
+	      [Enable building of vc4 tests (default: auto)]),
+	      [VC4=$enableval], [VC4=auto])
+if test "x$VC4" = xauto; then
+	PKG_CHECK_EXISTS([libdrm_vc4], [VC4=yes], [VC4=no])
+fi
+if test "x$VC4" = xyes; then
+	PKG_CHECK_MODULES(DRM_VC4, [libdrm_vc4])
+	AC_DEFINE(HAVE_VC4, 1, [Have vc4 support])
+fi
+AM_CONDITIONAL(HAVE_VC4, [test "x$VC4" = xyes])
+
 # Define a configure option for the shader debugger
 AC_ARG_ENABLE(shader-debugger, AS_HELP_STRING([--enable-shader-debugger],
 	      [Enable shader debugging support [autodetected]]),
Signature · 6 lines
2.7.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/9 igt: Add support for DRIVER_VC4 flags on tests.

---
 lib/drmtest.c | 16 ++++++++++++++--
 lib/drmtest.h |  1 +
 2 files changed, 15 insertions(+), 2 deletions(-)
lib/drmtest.c +14 -2
index 2896af0..7b2227f 100644
@@ -100,6 +100,16 @@ static bool is_i915_device(int fd)
 	return !ret && strcmp("i915", name) == 0;
 }
 
+static bool is_vc4_device(int fd)
+{
+	int ret;
+	char name[5] = "";
+
+	ret = __get_drm_device_name(fd, name);
+
+	return !ret && strcmp("vc4", name) == 0;
+}
+
 static bool is_intel(int fd)
 {
 	struct drm_i915_getparam gp;
@@ -237,7 +247,7 @@ int __drm_open_driver(int chipset)
 	for (int i = 0; i < 16; i++) {
 		char name[80];
 		int fd;
-		bool found_intel;
+		bool found_intel, found_vc4;
 
 		sprintf(name, "/dev/dri/card%u", i);
 		fd = open(name, O_RDWR);
@@ -246,7 +256,9 @@ int __drm_open_driver(int chipset)
 
 		found_intel =  is_i915_device(fd) && is_intel(fd) && (chipset & DRIVER_INTEL);
 
-		if ((chipset & DRIVER_ANY) || found_intel)
+		found_vc4 = is_vc4_device(fd) && (chipset & DRIVER_VC4);
+
+		if ((chipset & DRIVER_ANY) || found_intel || found_vc4)
 			return fd;
 
 		close(fd);
lib/drmtest.h +1 -0
index ed384ff..9fcab93 100644
@@ -40,6 +40,7 @@
 
 #define DRIVER_ANY 0x1
 #define DRIVER_INTEL (0x1 << 1)
+#define DRIVER_VC4 (0x1 << 2)
 
 #ifdef ANDROID
 #if (!(defined HAVE_MMAP64)) && (!(defined __x86_64__))
Signature · 6 lines
2.7.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 3/9 igt/vc4_wait_seqno: Add a test for VC4's wait-for-seqno ioctl.

In reply to Eric Anholt
---
 tests/Makefile.am      |  6 +++++
 tests/Makefile.sources |  4 +++
 tests/vc4_wait_seqno.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+)
 create mode 100644 tests/vc4_wait_seqno.c
tests/Makefile.am +6 -0
index 02d52c9..fbc0d62 100644
@@ -4,6 +4,10 @@ if HAVE_NOUVEAU
     TESTS_progs_M += $(NOUVEAU_TESTS_M)
 endif
 
+if HAVE_VC4
+    TESTS_progs_M += $(VC4_TESTS_M)
+endif
+
 if BUILD_TESTS
 test-list.txt: Makefile.sources
 	@echo TESTLIST > $@
@@ -97,5 +101,7 @@ prime_nv_api_CFLAGS = $(AM_CFLAGS) $(DRM_NOUVEAU_CFLAGS)
 prime_nv_api_LDADD = $(LDADD) $(DRM_NOUVEAU_LIBS)
 prime_nv_pcopy_CFLAGS = $(AM_CFLAGS) $(DRM_NOUVEAU_CFLAGS)
 prime_nv_pcopy_LDADD = $(LDADD) $(DRM_NOUVEAU_LIBS)
+vc4_wait_seqno_CFLAGS = $(AM_CFLAGS) $(DRM_VC4_CFLAGS)
+vc4_wait_seqno_LDADD = $(LDADD) $(DRM_VC4_LIBS)
 endif
 
tests/Makefile.sources +4 -0
index d431ebf..87cdd71 100644
@@ -4,6 +4,10 @@ NOUVEAU_TESTS_M = \
 	prime_nv_test \
 	$(NULL)
 
+VC4_TESTS_M = \
+	vc4_wait_seqno \
+	$(NULL)
+
 TESTS_progs_M = \
 	core_get_client_auth \
 	drv_getparams_basic \
tests/vc4_wait_seqno.c new file +69 -0

69 lines not on this page · raw message

Signature · 6 lines
2.7.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH 4/9 igt/vc4_wait_bo: Add a test for VC4's wait-for-BO ioctl.

In reply to Eric Anholt

The pad subtest fails currently.

---
 tests/Makefile.am      |  2 ++
 tests/Makefile.sources |  1 +
 tests/vc4_wait_bo.c    | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 96 insertions(+)
 create mode 100644 tests/vc4_wait_bo.c
tests/Makefile.am +2 -0
index fbc0d62..791564d 100644
@@ -101,6 +101,8 @@ prime_nv_api_CFLAGS = $(AM_CFLAGS) $(DRM_NOUVEAU_CFLAGS)
 prime_nv_api_LDADD = $(LDADD) $(DRM_NOUVEAU_LIBS)
 prime_nv_pcopy_CFLAGS = $(AM_CFLAGS) $(DRM_NOUVEAU_CFLAGS)
 prime_nv_pcopy_LDADD = $(LDADD) $(DRM_NOUVEAU_LIBS)
+vc4_wait_bo_CFLAGS = $(AM_CFLAGS) $(DRM_VC4_CFLAGS)
+vc4_wait_bo_LDADD = $(LDADD) $(DRM_VC4_LIBS)
 vc4_wait_seqno_CFLAGS = $(AM_CFLAGS) $(DRM_VC4_CFLAGS)
 vc4_wait_seqno_LDADD = $(LDADD) $(DRM_VC4_LIBS)
 endif
tests/Makefile.sources +1 -0
index 87cdd71..49dd61e 100644
@@ -5,6 +5,7 @@ NOUVEAU_TESTS_M = \
 	$(NULL)
 
 VC4_TESTS_M = \
+	vc4_wait_bo \
 	vc4_wait_seqno \
 	$(NULL)
 
tests/vc4_wait_bo.c new file +93 -0

93 lines not on this page · raw message

Signature · 6 lines
2.7.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 4/9
#4 lore raw

Re: [PATCH igt 4/9] igt/vc4_wait_bo: Add a test for VC4's wait-for-BO ioctl.

Hi,

Review

Quoted 2 lines · Eric Anholt
(quoted diff) +2 -0
+               ret = ioctl(fd, DRM_IOCTL_VC4_WAIT_BO, &arg);
+               igt_assert(ret == -1 && errno == EINVAL);

A couple of nitpicks: all these should be either do_ioctl() for success, or do_ioctl_err() for failure, which not only cuts down the number of lines a bit, but also shows you the exact condition which occurred (e.g. it'll show that errno was -EBUSY rather than expected -EINVAL without having to round-trip through the reporter). Similarly, all your igt_assert(x == y) should be igt_assert_eq(x, y), or any of the igt_assert_{eq,neq} variants, e.g. _u32 for comparing uint32_t. You can also use do_or_die(foo) as shorthand for igt_assert_eq(foo, 0).

With those addressed:

Cheers,
Daniel
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

Re: [PATCH igt 4/9] igt/vc4_wait_bo: Add a test for VC4's wait-for-BO ioctl.

Quoted 16 lines · Daniel Stone

Hi,

Review

Quoted 2 lines · Eric Anholt
(quoted diff) +2 -0
+               ret = ioctl(fd, DRM_IOCTL_VC4_WAIT_BO, &arg);
+               igt_assert(ret == -1 && errno == EINVAL);

A couple of nitpicks: all these should be either do_ioctl() for success, or do_ioctl_err() for failure, which not only cuts down the number of lines a bit, but also shows you the exact condition which occurred (e.g. it'll show that errno was -EBUSY rather than expected -EINVAL without having to round-trip through the reporter). Similarly, all your igt_assert(x == y) should be igt_assert_eq(x, y), or any of the igt_assert_{eq,neq} variants, e.g. _u32 for comparing uint32_t. You can also use do_or_die(foo) as shorthand for igt_assert_eq(foo, 0).

Quoted 2 lines

With those addressed:

I converted everything but one of the ones in wait_bo, and pushed the updated series to the vc4 branch of my tree. I'll give it another couple of days in case anyone else has review to do on the series.

Thanks!

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw

PATCH 5/9 igt: Add a helper function for getting a VC4 BO that's been drawn to.

In reply to Eric Anholt
---
 lib/Makefile.sources |   2 +
 lib/igt_vc4.c        | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_vc4.h        |  29 ++++++++++++++
 3 files changed, 137 insertions(+)
 create mode 100644 lib/igt_vc4.c
 create mode 100644 lib/igt_vc4.h
lib/Makefile.sources +2 -0
index 4999868..8a8143f 100644
@@ -16,6 +16,8 @@ libintel_tools_la_SOURCES = 	\
 	igt_gt.h		\
 	igt_stats.c		\
 	igt_stats.h		\
+	igt_vc4.c		\
+	igt_vc4.h		\
 	instdone.c		\
 	instdone.h		\
 	intel_batchbuffer.c	\
lib/igt_vc4.c new file +106 -0

106 lines not on this page · raw message

lib/igt_vc4.h new file +29 -0
new file mode 100644
index 0000000..4622034
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2016 Broadcom
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef IGT_VC4_H
+#define IGT_VC4_H
+
+uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval);
+
+#endif /* IGT_VC4_H */
Signature · 6 lines
2.7.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

PATCH 6/9 igt: Add a helper function for mapping VC4 BOs.

In reply to Eric Anholt
---
 lib/igt_vc4.c | 20 ++++++++++++++++++++
 lib/igt_vc4.h |  1 +
 2 files changed, 21 insertions(+)
lib/igt_vc4.c +20 -0
index 62e1345..15804e9 100644
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <signal.h>
 #include <errno.h>
+#include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
@@ -104,3 +105,22 @@ uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval)
 
 	return create.handle;
 }
+
+void *
+igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot)
+{
+	struct drm_vc4_mmap_bo mmap_bo = {
+		.handle = handle,
+	};
+	int ret;
+	void *ptr;
+
+	ret = ioctl(fd, DRM_IOCTL_VC4_MMAP_BO, &mmap_bo);
+	igt_assert(ret == 0);
+
+	ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_bo.offset);
+	if (ptr == MAP_FAILED)
+		return NULL;
+	else
+		return ptr;
+}
lib/igt_vc4.h +1 -0
index 4622034..d428f39 100644
@@ -25,5 +25,6 @@
 #define IGT_VC4_H
 
 uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval);
+void *igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot);
 
 #endif /* IGT_VC4_H */
Signature · 6 lines
2.7.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

PATCH 7/9 igt: Add a helper function for creating VC4 BOs.

In reply to Eric Anholt
---
 lib/igt_vc4.c       | 21 +++++++++++++++------
 lib/igt_vc4.h       |  1 +
 tests/vc4_wait_bo.c | 10 ++--------
 3 files changed, 18 insertions(+), 14 deletions(-)
lib/igt_vc4.c +15 -6
index 15804e9..0233f2b 100644
@@ -68,9 +68,7 @@ uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval)
 	/* A single row will be a page. */
 	uint32_t width = 1024;
 	uint32_t height = size / (width * 4);
-	struct drm_vc4_create_bo create = {
-		.size = size,
-	};
+	uint32_t handle = igt_vc4_create_bo(fd, size);
 	struct drm_vc4_submit_cl submit = {
 		.color_write = {
 			.hindex = 0,
@@ -84,7 +82,7 @@ uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval)
 		.msaa_color_write = { .hindex = ~0 },
 		.msaa_zs_write = { .hindex = ~0 },
 
-		.bo_handles = (uint64_t)(uintptr_t)&create.handle,
+		.bo_handles = (uint64_t)(uintptr_t)&handle,
 		.bo_handle_count = 1,
 		.width = width,
 		.height = height,
@@ -97,10 +95,21 @@ uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval)
 
 	igt_assert(width * height * 4 == size);
 
-	ret = ioctl(fd, DRM_IOCTL_VC4_CREATE_BO, &create);
+	ret = ioctl(fd, DRM_IOCTL_VC4_SUBMIT_CL, &submit);
 	igt_assert(ret == 0);
 
-	ret = ioctl(fd, DRM_IOCTL_VC4_SUBMIT_CL, &submit);
+	return handle;
+}
+
+int
+igt_vc4_create_bo(int fd, size_t size)
+{
+	struct drm_vc4_create_bo create = {
+		.size = size,
+	};
+	int ret;
+
+	ret = ioctl(fd, DRM_IOCTL_VC4_CREATE_BO, &create);
 	igt_assert(ret == 0);
 
 	return create.handle;
lib/igt_vc4.h +1 -0
index d428f39..e925246 100644
@@ -25,6 +25,7 @@
 #define IGT_VC4_H
 
 uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval);
+int igt_vc4_create_bo(int fd, size_t size);
 void *igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot);
 
 #endif /* IGT_VC4_H */
tests/vc4_wait_bo.c +2 -8
index 081ee09..642b941 100644
@@ -22,6 +22,7 @@
  */
 
 #include "igt.h"
+#include "igt_vc4.h"
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -40,15 +41,8 @@ igt_main
 	int bo_handle;
 
 	igt_fixture {
-		struct drm_vc4_create_bo create = {
-			.size = 4096,
-		};
-
 		fd = drm_open_driver(DRIVER_VC4);
-
-		ret = ioctl(fd, DRM_IOCTL_VC4_CREATE_BO, &create);
-		igt_assert(ret == 0);
-		bo_handle = create.handle;
+		bo_handle = igt_vc4_create_bo(fd, 4096);
 	}
 
 	igt_subtest("bad-bo") {
Signature · 6 lines
2.7.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

PATCH 8/9 igt/vc4_create_bo: Test various paths in BO creation.

In reply to Eric Anholt

create-bo-0 fails on the current kernel, and it's something I want to fix.

---
 tests/Makefile.am      |  2 ++
 tests/Makefile.sources |  1 +
 tests/vc4_create_bo.c  | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 94 insertions(+)
 create mode 100644 tests/vc4_create_bo.c
tests/Makefile.am +2 -0
index 791564d..f72f7c0 100644
@@ -101,6 +101,8 @@ prime_nv_api_CFLAGS = $(AM_CFLAGS) $(DRM_NOUVEAU_CFLAGS)
 prime_nv_api_LDADD = $(LDADD) $(DRM_NOUVEAU_LIBS)
 prime_nv_pcopy_CFLAGS = $(AM_CFLAGS) $(DRM_NOUVEAU_CFLAGS)
 prime_nv_pcopy_LDADD = $(LDADD) $(DRM_NOUVEAU_LIBS)
+vc4_create_bo_CFLAGS = $(AM_CFLAGS) $(DRM_VC4_CFLAGS)
+vc4_create_bo_LDADD = $(LDADD) $(DRM_VC4_LIBS)
 vc4_wait_bo_CFLAGS = $(AM_CFLAGS) $(DRM_VC4_CFLAGS)
 vc4_wait_bo_LDADD = $(LDADD) $(DRM_VC4_LIBS)
 vc4_wait_seqno_CFLAGS = $(AM_CFLAGS) $(DRM_VC4_CFLAGS)
tests/Makefile.sources +1 -0
index 49dd61e..df92586 100644
@@ -5,6 +5,7 @@ NOUVEAU_TESTS_M = \
 	$(NULL)
 
 VC4_TESTS_M = \
+	vc4_create_bo \
 	vc4_wait_bo \
 	vc4_wait_seqno \
 	$(NULL)
tests/vc4_create_bo.c new file +91 -0

91 lines not on this page · raw message

Signature · 6 lines
2.7.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw

PATCH 9/9 igt/vc4_wait_bo: Add tests with rendering performed.

In reply to Eric Anholt

These caught an unexpected bug with clear colors (we'd get the last executed clear's color in our new BO), while failing to catch the bug I'd been hoping to find all along.

---
 tests/vc4_wait_bo.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
tests/vc4_wait_bo.c +41 -0
index 642b941..511c03a 100644
@@ -34,6 +34,38 @@
 #include <sys/ioctl.h>
 #include "vc4_drm.h"
 
+static void
+test_used_bo(int fd, uint64_t timeout)
+{
+	size_t size = 4096;
+	uint32_t clearval = 0xaabbccdd + timeout;
+	int handle = igt_vc4_get_cleared_bo(fd, size, clearval);
+	struct drm_vc4_wait_bo wait = {
+		.timeout_ns = timeout,
+		.handle = handle,
+	};
+	int ret, i;
+
+	ret = ioctl(fd, DRM_IOCTL_VC4_WAIT_BO, &wait);
+	if (timeout == ~0ull) {
+		igt_assert(ret == 0);
+	} else {
+		if (ret == -1 && errno == ETIME)
+			igt_debug("Timeout triggered\n");
+		igt_assert(ret == 0 || (ret == -1 && errno == ETIME));
+	}
+
+	if (ret == 0) {
+		uint32_t *map = igt_vc4_mmap_bo(fd, handle, size, PROT_READ);
+		for (i = 0; i < size / 4; i++) {
+			igt_assert_eq_u32(map[i], clearval);
+		}
+		munmap((void *)map, size);
+	}
+
+	gem_close(fd, handle);
+}
+
 igt_main
 {
 	int ret;
@@ -82,6 +114,15 @@ igt_main
 		igt_assert(ret == 0);
 	}
 
+	igt_subtest("used-bo-0ns")
+		test_used_bo(fd, 0);
+
+	igt_subtest("used-bo-1ns")
+		test_used_bo(fd, 1);
+
+	igt_subtest("used-bo")
+		test_used_bo(fd, ~0ull);
+
 	igt_fixture
 		close(fd);
 }
Signature · 6 lines
2.7.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx