From: "Maíra Canal" <mcanal@igalia.com>
To: "Melissa Wen" <mwen@igalia.com>,
"André Almeida" <andrealmeid@igalia.com>,
"Petri Latvala" <petri.latvala@intel.com>,
"Kamil Konieczny" <kamil.konieczny@linux.intel.com>,
"Emma Anholt" <emma@anholt.net>,
"Iago Toral Quiroga" <itoral@igalia.com>
Cc: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v4 5/6] tests/v3d_wait_bo: Create test for V3D's Wait BO IOCTL
Date: Mon, 30 Jan 2023 14:57:57 -0300 [thread overview]
Message-ID: <20230130175758.420535-6-mcanal@igalia.com> (raw)
In-Reply-To: <20230130175758.420535-1-mcanal@igalia.com>
Add nine igt_subtests for the DRM_IOCTL_V3D_WAIT_BO, which ensures
that improper parameters return an errno and tests timeouts for used
and unused BOs. In order to create used BOs, it submits a noop job and
evaluates V3D's job BOs.
Reviewed-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
lib/igt_v3d.c | 9 +++
lib/igt_v3d.h | 2 +
tests/v3d/meson.build | 1 +
tests/v3d/v3d_wait_bo.c | 127 ++++++++++++++++++++++++++++++++++++++
tests/v3d_ci/v3d.testlist | 9 +++
5 files changed, 148 insertions(+)
create mode 100644 tests/v3d/v3d_wait_bo.c
diff --git a/lib/igt_v3d.c b/lib/igt_v3d.c
index 0cadafe2..55eb3c0f 100644
--- a/lib/igt_v3d.c
+++ b/lib/igt_v3d.c
@@ -140,6 +140,15 @@ void igt_v3d_bo_mmap(int fd, struct v3d_bo *bo)
igt_assert(bo->map);
}
+void igt_v3d_wait_bo(int fd, struct v3d_bo *bo, uint64_t timeout_ns)
+{
+ struct drm_v3d_wait_bo arg = {
+ .handle = bo->handle,
+ .timeout_ns = timeout_ns
+ };
+ do_ioctl(fd, DRM_IOCTL_V3D_WAIT_BO, &arg);
+}
+
uint32_t igt_v3d_perfmon_create(int fd, uint32_t ncounters, uint8_t *counters)
{
struct drm_v3d_perfmon_create create = {
diff --git a/lib/igt_v3d.h b/lib/igt_v3d.h
index c3799096..af2c9c2f 100644
--- a/lib/igt_v3d.h
+++ b/lib/igt_v3d.h
@@ -56,6 +56,8 @@ void *igt_v3d_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot);
void igt_v3d_bo_mmap(int fd, struct v3d_bo *bo);
+void igt_v3d_wait_bo(int fd, struct v3d_bo *bo, uint64_t timeout_ns);
+
uint32_t igt_v3d_perfmon_create(int fd, uint32_t ncounters, uint8_t *counters);
void igt_v3d_perfmon_get_values(int fd, uint32_t id);
void igt_v3d_perfmon_destroy(int fd, uint32_t id);
diff --git a/tests/v3d/meson.build b/tests/v3d/meson.build
index 07badc49..7b4257f9 100644
--- a/tests/v3d/meson.build
+++ b/tests/v3d/meson.build
@@ -4,6 +4,7 @@ v3d_progs = [
'v3d_get_param',
'v3d_mmap',
'v3d_perfmon',
+ 'v3d_wait_bo',
]
foreach prog : v3d_progs
diff --git a/tests/v3d/v3d_wait_bo.c b/tests/v3d/v3d_wait_bo.c
new file mode 100644
index 00000000..9e51b6a0
--- /dev/null
+++ b/tests/v3d/v3d_wait_bo.c
@@ -0,0 +1,127 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2022 Igalia S.L.
+ */
+
+#include "igt.h"
+#include "igt_v3d.h"
+#include "v3d/v3d_cl.h"
+
+IGT_TEST_DESCRIPTION("Tests for the V3D's Wait BO IOCTL");
+
+static void test_used_bo(int fd, struct v3d_bo *bo, uint64_t timeout)
+{
+ struct drm_v3d_wait_bo arg = {
+ .timeout_ns = timeout,
+ .handle = bo->handle,
+ };
+ int ret;
+
+ ret = igt_ioctl(fd, DRM_IOCTL_V3D_WAIT_BO, &arg);
+
+ if (ret == -1 && errno == ETIME)
+ igt_debug("Timeout triggered\n");
+ igt_assert(ret == 0 || (ret == -1 && errno == ETIME));
+}
+
+igt_main
+{
+ int fd;
+ struct v3d_bo *bo;
+
+ igt_fixture {
+ fd = drm_open_driver(DRIVER_V3D);
+ bo = igt_v3d_create_bo(fd, PAGE_SIZE);
+ }
+
+ igt_describe("Make sure it cannot wait on an invalid BO.");
+ igt_subtest("bad-bo") {
+ struct drm_v3d_wait_bo arg = {
+ .handle = bo->handle + 1,
+ .timeout_ns = 0,
+ };
+ do_ioctl_err(fd, DRM_IOCTL_V3D_WAIT_BO, &arg, EINVAL);
+ }
+
+ igt_describe("Make sure the pad is zero.");
+ igt_subtest("bad-pad") {
+ struct drm_v3d_wait_bo arg = {
+ .pad = 1,
+ .handle = bo->handle,
+ .timeout_ns = 0,
+ };
+ do_ioctl_err(fd, DRM_IOCTL_V3D_WAIT_BO, &arg, EINVAL);
+ }
+
+ igt_describe("Wait on an unused BO for 0 ns.");
+ igt_subtest("unused-bo-0ns")
+ igt_v3d_wait_bo(fd, bo, 0);
+
+ igt_describe("Wait on an unused BO for 1 ns.");
+ igt_subtest("unused-bo-1ns")
+ igt_v3d_wait_bo(fd, bo, 1);
+
+ igt_describe("Wait on a newly mapped BO for 0 ns.");
+ igt_subtest("map-bo-0ns") {
+ igt_v3d_bo_mmap(fd, bo);
+ igt_v3d_wait_bo(fd, bo, 0);
+ munmap(bo->map, bo->size);
+ }
+
+ igt_describe("Wait on a newly mapped BO for 1 ns.");
+ igt_subtest("map-bo-1ns") {
+ igt_v3d_bo_mmap(fd, bo);
+ igt_v3d_wait_bo(fd, bo, 1);
+ munmap(bo->map, bo->size);
+ }
+
+ igt_describe("Wait for BOs used for a noop job for 0 ns.");
+ igt_subtest("used-bo-0ns") {
+ struct v3d_cl_job *job = igt_v3d_noop_job(fd);
+
+ do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CL, job->submit);
+
+ test_used_bo(fd, job->tile_alloc, 0);
+ test_used_bo(fd, job->tile_state, 0);
+ test_used_bo(fd, job->bcl->bo, 0);
+ test_used_bo(fd, job->rcl->bo, 0);
+ test_used_bo(fd, job->icl->bo, 0);
+
+ igt_v3d_free_cl_job(fd, job);
+ }
+
+ igt_describe("Wait for BOs used for a noop job for 1 ns.");
+ igt_subtest("used-bo-1ns") {
+ struct v3d_cl_job *job = igt_v3d_noop_job(fd);
+
+ do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CL, job->submit);
+
+ test_used_bo(fd, job->tile_alloc, 1);
+ test_used_bo(fd, job->tile_state, 1);
+ test_used_bo(fd, job->bcl->bo, 1);
+ test_used_bo(fd, job->rcl->bo, 1);
+ test_used_bo(fd, job->icl->bo, 1);
+
+ igt_v3d_free_cl_job(fd, job);
+ }
+
+ igt_describe("Wait for BOs used for a noop job for a long amount of time.");
+ igt_subtest("used-bo") {
+ struct v3d_cl_job *job = igt_v3d_noop_job(fd);
+
+ do_ioctl(fd, DRM_IOCTL_V3D_SUBMIT_CL, job->submit);
+
+ igt_v3d_wait_bo(fd, job->tile_alloc, INT64_MAX);
+ igt_v3d_wait_bo(fd, job->tile_state, INT64_MAX);
+ igt_v3d_wait_bo(fd, job->bcl->bo, INT64_MAX);
+ igt_v3d_wait_bo(fd, job->rcl->bo, INT64_MAX);
+ igt_v3d_wait_bo(fd, job->icl->bo, INT64_MAX);
+
+ igt_v3d_free_cl_job(fd, job);
+ }
+
+ igt_fixture {
+ igt_v3d_free_bo(fd, bo);
+ close(fd);
+ }
+}
diff --git a/tests/v3d_ci/v3d.testlist b/tests/v3d_ci/v3d.testlist
index ce8c4f6c..54d28ce5 100644
--- a/tests/v3d_ci/v3d.testlist
+++ b/tests/v3d_ci/v3d.testlist
@@ -21,3 +21,12 @@ igt@v3d/v3d_perfmon@get-values-invalid-pointer
igt@v3d/v3d_perfmon@get-values-valid-perfmon
igt@v3d/v3d_perfmon@destroy-invalid-perfmon
igt@v3d/v3d_perfmon@destroy-valid-perfmon
+igt@v3d/v3d_wait_bo@bad-bo
+igt@v3d/v3d_wait_bo@bad-pad
+igt@v3d/v3d_wait_bo@unused-bo-0ns
+igt@v3d/v3d_wait_bo@unused-bo-1ns
+igt@v3d/v3d_wait_bo@map-bo-0ns
+igt@v3d/v3d_wait_bo@map-bo-1ns
+igt@v3d/v3d_wait_bo@used-bo-0ns
+igt@v3d/v3d_wait_bo@used-bo-1ns
+igt@v3d/v3d_wait_bo@used-bo
--
2.39.1
next prev parent reply other threads:[~2023-01-30 17:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 17:57 [igt-dev] [PATCH i-g-t v4 0/6] V3D Job Submission Tests Maíra Canal
2023-01-30 17:57 ` [igt-dev] [PATCH i-g-t v4 1/6] lib/v3d: Add V3D packet helpers Maíra Canal
2023-01-30 17:57 ` [igt-dev] [PATCH i-g-t v4 2/6] lib/v3d: Add V3D packet description Maíra Canal
2023-01-30 17:57 ` [igt-dev] [PATCH i-g-t v4 3/6] lib/v3d: Introduce the struct v3d_cl_job Maíra Canal
2023-01-30 17:57 ` [igt-dev] [PATCH i-g-t v4 4/6] lib/v3d: Add a helper to create a noop job Maíra Canal
2023-01-30 17:57 ` Maíra Canal [this message]
2023-01-30 17:57 ` [igt-dev] [PATCH i-g-t v4 6/6] tests/v3d_submit_cl: Create test for V3D's Submit CL IOCTL Maíra Canal
2023-01-30 18:32 ` [igt-dev] ✓ Fi.CI.BAT: success for V3D Job Submission Tests (rev4) Patchwork
2023-01-31 0:32 ` [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=20230130175758.420535-6-mcanal@igalia.com \
--to=mcanal@igalia.com \
--cc=andrealmeid@igalia.com \
--cc=emma@anholt.net \
--cc=igt-dev@lists.freedesktop.org \
--cc=itoral@igalia.com \
--cc=kamil.konieczny@linux.intel.com \
--cc=mwen@igalia.com \
--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