public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tomeu Vizoso <tomeu.vizoso@collabora.com>
To: Development mailing list for IGT GPU Tools
	<igt-dev@lists.freedesktop.org>
Cc: Petri Latvala <petri.latvala@intel.com>,
	Tomeu Vizoso <tomeu.vizoso@collabora.com>
Subject: [igt-dev] [PATCH i-g-t 5/6] tests/panfrost: Add initial tests for panfrost
Date: Fri, 10 May 2019 16:44:57 +0200	[thread overview]
Message-ID: <20190510144458.20113-5-tomeu.vizoso@collabora.com> (raw)
In-Reply-To: <20190510144458.20113-1-tomeu.vizoso@collabora.com>

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Acked-by: Petri Latvala <petri.latvala@intel.com>
---
 tests/meson.build          |   4 +
 tests/panfrost_gem_new.c   |  90 ++++++++++++++++++++
 tests/panfrost_get_param.c |  73 +++++++++++++++++
 tests/panfrost_prime.c     |  79 ++++++++++++++++++
 tests/panfrost_submit.c    | 163 +++++++++++++++++++++++++++++++++++++
 5 files changed, 409 insertions(+)
 create mode 100644 tests/panfrost_gem_new.c
 create mode 100644 tests/panfrost_get_param.c
 create mode 100644 tests/panfrost_prime.c
 create mode 100644 tests/panfrost_submit.c

diff --git a/tests/meson.build b/tests/meson.build
index 711979b4a1c2..351594fa72f0 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -63,6 +63,10 @@ test_progs = [
 	'kms_vblank',
 	'kms_vrr',
 	'meta_test',
+	'panfrost_get_param',
+	'panfrost_gem_new',
+	'panfrost_prime',
+	'panfrost_submit',
 	'perf',
 	'prime_busy',
 	'prime_mmap',
diff --git a/tests/panfrost_gem_new.c b/tests/panfrost_gem_new.c
new file mode 100644
index 000000000000..940525ff1b34
--- /dev/null
+++ b/tests/panfrost_gem_new.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright © 2016 Broadcom
+ * Copyright © 2019 Collabora, Ltd.
+ *
+ * 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.
+ */
+
+#include "igt.h"
+#include "igt_panfrost.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include "panfrost_drm.h"
+
+igt_main
+{
+	int fd;
+
+	igt_fixture {
+		fd = drm_open_driver(DRIVER_PANFROST);
+	}
+
+	igt_subtest("gem-new-4096") {
+		struct panfrost_bo *bo = igt_panfrost_gem_new(fd, 4096);
+		igt_panfrost_free_bo(fd, bo);
+	}
+
+	igt_subtest("gem-new-0") {
+		struct drm_panfrost_create_bo arg = {
+			.size = 0,
+		};
+		do_ioctl_err(fd, DRM_IOCTL_PANFROST_CREATE_BO, &arg, EINVAL);
+	}
+
+	igt_subtest("gem-new-zeroed") {
+		int fd2 = drm_open_driver(DRIVER_PANFROST);
+		struct panfrost_bo *bo;
+		uint32_t *map;
+		/* A size different from any used in our other tests, to try
+		 * to convince it to land as the only one of its size in the
+		 * kernel BO cache
+		 */
+		size_t size = 3 * 4096, i;
+
+		/* Make a BO and free it on our main fd. */
+		bo = igt_panfrost_gem_new(fd, size);
+		map = igt_panfrost_mmap_bo(fd, bo->handle, size, PROT_READ | PROT_WRITE);
+		memset(map, 0xd0, size);
+		munmap(map, size);
+		igt_panfrost_free_bo(fd, bo);
+
+		/* Now, allocate a BO on the other fd and make sure it doesn't
+		 * have the old contents.
+		 */
+		bo = igt_panfrost_gem_new(fd2, size);
+		map = igt_panfrost_mmap_bo(fd2, bo->handle, size, PROT_READ | PROT_WRITE);
+		for (i = 0; i < size / 4; i++)
+			igt_assert_eq_u32(map[i], 0x0);
+		munmap(map, size);
+		igt_panfrost_free_bo(fd2, bo);
+
+		close(fd2);
+	}
+
+	igt_fixture
+		close(fd);
+}
diff --git a/tests/panfrost_get_param.c b/tests/panfrost_get_param.c
new file mode 100644
index 000000000000..11c2632b8f3b
--- /dev/null
+++ b/tests/panfrost_get_param.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright © 2017 Broadcom
+ * Copyright © 2019 Collabora, Ltd.
+ *
+ * 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.
+ */
+
+#include "igt.h"
+#include "igt_panfrost.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <poll.h>
+#include "panfrost_drm.h"
+
+igt_main
+{
+	int fd;
+
+	igt_fixture
+		fd = drm_open_driver(DRIVER_PANFROST);
+
+	igt_subtest("base-params") {
+		int last_base_param = DRM_PANFROST_PARAM_GPU_PROD_ID;
+		uint32_t results[last_base_param + 1];
+
+		for (int i = 0; i < ARRAY_SIZE(results); i++)
+			results[i] = igt_panfrost_get_param(fd, i);
+
+		igt_assert(results[DRM_PANFROST_PARAM_GPU_PROD_ID]);
+	}
+
+	igt_subtest("get-bad-param") {
+		struct drm_panfrost_get_param get = {
+			.param = 0xd0d0d0d0,
+		};
+		do_ioctl_err(fd, DRM_IOCTL_PANFROST_GET_PARAM, &get, EINVAL);
+	}
+
+	igt_subtest("get-bad-padding") {
+		struct drm_panfrost_get_param get = {
+			.param = DRM_PANFROST_PARAM_GPU_PROD_ID,
+			.pad = 1,
+		};
+		do_ioctl_err(fd, DRM_IOCTL_PANFROST_GET_PARAM, &get, EINVAL);
+	}
+
+	igt_fixture
+		close(fd);
+}
diff --git a/tests/panfrost_prime.c b/tests/panfrost_prime.c
new file mode 100644
index 000000000000..351d46f2f7e6
--- /dev/null
+++ b/tests/panfrost_prime.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright © 2016 Broadcom
+ * Copyright © 2019 Collabora, Ltd.
+ *
+ * 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.
+ */
+
+#include "igt.h"
+#include "igt_panfrost.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include "panfrost_drm.h"
+
+igt_main
+{
+	int fd, kms_fd;
+
+	igt_fixture {
+		kms_fd = drm_open_driver_master(DRIVER_ANY);
+		fd = drm_open_driver(DRIVER_PANFROST);
+	}
+
+	igt_subtest("gem-prime-import") {
+		struct panfrost_bo *bo;
+		uint32_t handle, dumb_handle;
+	        struct drm_panfrost_get_bo_offset get_bo_offset = {0,};
+		int dmabuf_fd;
+
+		/* Just to be sure that when we import the dumb buffer it has
+		 * a non-NULL address.
+		 */
+		bo = igt_panfrost_gem_new(fd, 1024);
+
+		dumb_handle = kmstest_dumb_create(kms_fd, 1024, 1024, 32, NULL, NULL);
+
+		dmabuf_fd = prime_handle_to_fd(kms_fd, dumb_handle);
+
+		handle = prime_fd_to_handle(fd, dmabuf_fd);
+
+		get_bo_offset.handle = handle;
+		do_ioctl(fd, DRM_IOCTL_PANFROST_GET_BO_OFFSET, &get_bo_offset);
+		igt_assert(get_bo_offset.offset);
+
+		gem_close(fd, handle);
+
+		kmstest_dumb_destroy(kms_fd, dumb_handle);
+
+		igt_panfrost_free_bo(fd, bo);
+	}
+
+	igt_fixture {
+		close(fd);
+		close(kms_fd);
+	}
+}
diff --git a/tests/panfrost_submit.c b/tests/panfrost_submit.c
new file mode 100644
index 000000000000..5770dc24a42b
--- /dev/null
+++ b/tests/panfrost_submit.c
@@ -0,0 +1,163 @@
+/*
+ * Copyright © 2016 Broadcom
+ * Copyright © 2019 Collabora, Ltd.
+ *
+ * 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.
+ */
+
+#include "igt.h"
+#include "igt_panfrost.h"
+#include "igt_syncobj.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include "panfrost_drm.h"
+
+#define WIDTH          1366
+#define HEIGHT         768
+#define CLEAR_COLOR    0xff7f7f7f
+
+/* One tenth of a second */
+#define SHORT_TIME_NSEC 100000000ull
+
+/* Add the time that the bad job takes to timeout (sched->timeout) and the time that a reset can take */
+#define BAD_JOB_TIME_NSEC (SHORT_TIME_NSEC + 500000000ull + 100000000ull)
+
+#define NSECS_PER_SEC 1000000000ull
+
+static uint64_t
+abs_timeout(uint64_t duration)
+{
+        struct timespec current;
+        clock_gettime(CLOCK_MONOTONIC, &current);
+        return (uint64_t)current.tv_sec * NSECS_PER_SEC + current.tv_nsec + duration;
+}
+
+static void check_fb(int fd, struct panfrost_bo *bo)
+{
+        __uint32_t *fbo;
+        int i;
+
+        fbo = bo->map;
+        for (i = 0; i < ALIGN(WIDTH, 16) * HEIGHT; i++)
+                igt_assert_eq_u32(fbo[i], CLEAR_COLOR);
+}
+
+igt_main
+{
+        int fd;
+
+        igt_fixture {
+                fd = drm_open_driver(DRIVER_PANFROST);
+        }
+
+        igt_subtest("pan-submit") {
+                struct panfrost_submit *submit;
+
+                submit = igt_panfrost_trivial_job(fd, false, WIDTH, HEIGHT,
+                                                  CLEAR_COLOR);
+
+                igt_panfrost_bo_mmap(fd, submit->fbo);
+                do_ioctl(fd, DRM_IOCTL_PANFROST_SUBMIT, submit->args);
+                igt_assert(syncobj_wait(fd, &submit->args->out_sync, 1,
+                                        abs_timeout(SHORT_TIME_NSEC), 0, NULL));
+                check_fb(fd, submit->fbo);
+                igt_panfrost_free_job(fd, submit);
+        }
+
+        igt_subtest("pan-submit-error-no-jc") {
+                struct drm_panfrost_submit submit = {.jc = 0,};
+                do_ioctl_err(fd, DRM_IOCTL_PANFROST_SUBMIT, &submit, EINVAL);
+        }
+
+        igt_subtest("pan-submit-error-bad-in-syncs") {
+                struct panfrost_submit *submit;
+
+                submit = igt_panfrost_trivial_job(fd, false, WIDTH, HEIGHT,
+                                                  CLEAR_COLOR);
+                submit->args->in_syncs = 0ULL;
+                submit->args->in_sync_count = 1;
+
+                do_ioctl_err(fd, DRM_IOCTL_PANFROST_SUBMIT, submit->args, EFAULT);
+        }
+
+        igt_subtest("pan-submit-error-bad-bo-handles") {
+                struct panfrost_submit *submit;
+
+                submit = igt_panfrost_trivial_job(fd, false, WIDTH, HEIGHT,
+                                                  CLEAR_COLOR);
+                submit->args->bo_handles = 0ULL;
+                submit->args->bo_handle_count = 1;
+
+                do_ioctl_err(fd, DRM_IOCTL_PANFROST_SUBMIT, submit->args, EFAULT);
+        }
+
+        igt_subtest("pan-submit-error-bad-requirements") {
+                struct panfrost_submit *submit;
+
+                submit = igt_panfrost_trivial_job(fd, false, WIDTH, HEIGHT,
+                                                  CLEAR_COLOR);
+                submit->args->requirements = 2;
+
+                do_ioctl_err(fd, DRM_IOCTL_PANFROST_SUBMIT, submit->args, EINVAL);
+        }
+
+        igt_subtest("pan-submit-error-bad-out-sync") {
+                struct panfrost_submit *submit;
+
+                submit = igt_panfrost_trivial_job(fd, false, WIDTH, HEIGHT,
+                                                  CLEAR_COLOR);
+                submit->args->out_sync = -1;
+
+                do_ioctl_err(fd, DRM_IOCTL_PANFROST_SUBMIT, submit->args, ENODEV);
+        }
+
+        igt_subtest("pan-reset") {
+                struct panfrost_submit *submit;
+
+                submit = igt_panfrost_trivial_job(fd, true, WIDTH, HEIGHT,
+                                                  CLEAR_COLOR);
+                do_ioctl(fd, DRM_IOCTL_PANFROST_SUBMIT, submit->args);
+                /* Expect for this job to timeout */
+                igt_assert(!syncobj_wait(fd, &submit->args->out_sync, 1,
+                                         abs_timeout(SHORT_TIME_NSEC), 0, NULL));
+                igt_panfrost_free_job(fd, submit);
+
+                submit = igt_panfrost_trivial_job(fd, false, WIDTH, HEIGHT,
+                                                  CLEAR_COLOR);
+                igt_panfrost_bo_mmap(fd, submit->fbo);
+                do_ioctl(fd, DRM_IOCTL_PANFROST_SUBMIT, submit->args);
+                /* This one should work */
+                igt_assert(syncobj_wait(fd, &submit->args->out_sync, 1,
+                                        abs_timeout(BAD_JOB_TIME_NSEC), 0, NULL));
+                check_fb(fd, submit->fbo);
+                igt_panfrost_free_job(fd, submit);
+        }
+
+        igt_fixture {
+                close(fd);
+        }
+}
-- 
2.20.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2019-05-10 14:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-10 14:44 [igt-dev] [PATCH i-g-t 1/6] lib: Check for -ETIME, not ETIME Tomeu Vizoso
2019-05-10 14:44 ` [igt-dev] [PATCH i-g-t 2/6] drm-uapi: Add panfrost header Tomeu Vizoso
2019-05-10 14:44 ` [igt-dev] [PATCH i-g-t 3/6] lib/panfrost: Add panfrost helpers Tomeu Vizoso
2019-05-10 14:44 ` [igt-dev] [PATCH i-g-t 4/6] lib: Add support for opening panfrost devices Tomeu Vizoso
2019-05-10 14:44 ` Tomeu Vizoso [this message]
2019-05-10 14:44 ` [igt-dev] [PATCH i-g-t 6/6] panfrost: Don't check for automake support Tomeu Vizoso
2019-05-10 15:21 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/6] lib: Check for -ETIME, not ETIME Patchwork
2019-05-10 18:21 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190510144458.20113-5-tomeu.vizoso@collabora.com \
    --to=tomeu.vizoso@collabora.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox