[PATCH i-g-t 2/3] lib/igt_kms: Add kmstest_wait_for_pageflip_timeout()
Imre Deak
imre.deak at intel.com
Tue Oct 22 15:53:10 UTC 2024
Add a function to wait for a page flip completion providing the timeout
duration. This is required by the next patch, using an Intel HW specific
pageflip timeout.
Signed-off-by: Imre Deak <imre.deak at intel.com>
---
lib/igt_kms.c | 21 +++++++++++++++++----
lib/igt_kms.h | 1 +
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 99231d6e7..81a9930a2 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2377,15 +2377,16 @@ unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags)
}
/**
- * kmstest_wait_for_pageflip:
+ * kmstest_wait_for_pageflip_timeout:
* @fd: Opened drm file descriptor
+ * @timeout_us: timeout used for waiting
*
* Blocks until pageflip is completed
*/
-void kmstest_wait_for_pageflip(int fd)
+void kmstest_wait_for_pageflip_timeout(int fd, uint64_t timeout_us)
{
drmEventContext evctx = { .version = 2 };
- struct timeval timeout = { .tv_sec = 0, .tv_usec = 50000 };
+ struct timeval timeout = { .tv_sec = 0, .tv_usec = timeout_us };
fd_set fds;
int ret;
@@ -2398,7 +2399,8 @@ void kmstest_wait_for_pageflip(int fd)
} while (ret < 0 && errno == EINTR);
igt_fail_on_f(ret == 0,
- "Exceeded timeout (50ms) while waiting for a pageflip\n");
+ "Exceeded timeout (%" PRIu64 " us) while waiting for a pageflip\n",
+ timeout_us);
igt_assert_f(ret == 1,
"Waiting for pageflip failed with %d from select(drmfd)\n",
@@ -2407,6 +2409,17 @@ void kmstest_wait_for_pageflip(int fd)
igt_assert(drmHandleEvent(fd, &evctx) == 0);
}
+/**
+ * kmstest_wait_for_pageflip:
+ * @fd: Opened drm file descriptor
+ *
+ * Blocks until pageflip is completed using a 50 ms timeout.
+ */
+void kmstest_wait_for_pageflip(int fd)
+{
+ kmstest_wait_for_pageflip_timeout(fd, 50000);
+}
+
/**
* kms_has_vblank:
* @fd: DRM fd
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index fc7e4cda1..57e62d86c 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -310,6 +310,7 @@ void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
unsigned prot);
void kmstest_dumb_destroy(int fd, uint32_t handle);
void kmstest_wait_for_pageflip(int fd);
+void kmstest_wait_for_pageflip_timeout(int fd, uint64_t timeout_us);
unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
bool kms_has_vblank(int fd);
--
2.44.2
More information about the igt-dev
mailing list