[igt-dev] [PATCH v3 01/10] tests/panfrost: Make sure we open a DUMB capable node for prime tests

Boris Brezillon boris.brezillon at collabora.com
Fri Jun 25 14:01:09 UTC 2021


v3:
* Check capabilities separately

v2:
* Use __drm_open_driver_another()

Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
Acked-by: Petri Latvala <petri.latvala at intel.com>
---
 tests/panfrost_prime.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/tests/panfrost_prime.c b/tests/panfrost_prime.c
index 351d46f2f7e6..40ba036b2d47 100644
--- a/tests/panfrost_prime.c
+++ b/tests/panfrost_prime.c
@@ -35,13 +35,33 @@
 #include <sys/ioctl.h>
 #include "panfrost_drm.h"
 
+static bool igt_has_dumb(int fd)
+{
+	uint64_t value = 0;
+	int ret;
+
+	ret = drmGetCap(fd, DRM_CAP_DUMB_BUFFER, &value);
+	igt_assert(ret == 0 || errno == EINVAL || errno == EOPNOTSUPP);
+	return value == 1;
+}
+
+static bool igt_has_prime(int fd, uint64_t flags)
+{
+	uint64_t value = 0;
+	int ret;
+
+	ret = drmGetCap(fd, DRM_CAP_PRIME, &value);
+	igt_assert(ret == 0 || errno == EINVAL || errno == EOPNOTSUPP);
+	return (value & flags) == flags;
+}
+
 igt_main
 {
 	int fd, kms_fd;
 
 	igt_fixture {
-		kms_fd = drm_open_driver_master(DRIVER_ANY);
 		fd = drm_open_driver(DRIVER_PANFROST);
+		kms_fd = __drm_open_driver_another(1, DRIVER_ANY);
 	}
 
 	igt_subtest("gem-prime-import") {
@@ -50,6 +70,9 @@ igt_main
 	        struct drm_panfrost_get_bo_offset get_bo_offset = {0,};
 		int dmabuf_fd;
 
+		igt_skip_on(!igt_has_dumb(kms_fd));
+		igt_skip_on(!igt_has_prime(kms_fd, DRM_PRIME_CAP_EXPORT));
+
 		/* Just to be sure that when we import the dumb buffer it has
 		 * a non-NULL address.
 		 */
-- 
2.31.1



More information about the igt-dev mailing list