Skip to content
Snippets Groups Projects
Commit 5b213b75 authored by Rob Clark's avatar Rob Clark :speech_balloon:
Browse files

lib: Add helper to wait and close fence fd


Get rid of some copy/pasta and open coding of a common pattern, waiting
for GPU commands to complete.

Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
parent ecbc2bb5
No related branches found
No related tags found
No related merge requests found
......@@ -1919,3 +1919,14 @@ void *igt_memdup(const void *ptr, size_t len)
return dup;
}
/**
* igt_wait_and_close: helper to wait on a fence-fd and then close it
*
* @fence_fd: the fence-fd to wait on and close
*/
void igt_wait_and_close(int fence_fd)
{
poll(&(struct pollfd){fence_fd, POLLIN}, 1, -1);
close(fence_fd);
}
......@@ -337,4 +337,6 @@ uint64_t vfs_file_max(void);
void *igt_memdup(const void *ptr, size_t len);
void igt_wait_and_close(int fence_fd);
#endif /* IGT_AUX_H */
......@@ -25,7 +25,6 @@
#include <fcntl.h>
#include <glob.h>
#include <string.h>
#include <sys/poll.h>
#include <sys/stat.h>
#include "igt.h"
......@@ -197,8 +196,7 @@ do_mapping_test(struct msm_pipe *pipe, const char *buffername, bool write)
fence_fd = igt_msm_cmd_submit(cmd);
/* Wait for submit to complete: */
poll(&(struct pollfd){fence_fd, POLLIN}, 1, -1);
close(fence_fd);
igt_wait_and_close(fence_fd);
igt_msm_bo_free(scratch_bo);
......
......@@ -22,7 +22,6 @@
*/
#include <fcntl.h>
#include <sys/poll.h>
#include "igt.h"
#include "igt_msm.h"
......@@ -52,16 +51,6 @@ mem_write(struct msm_cmd *cmd, uint32_t offset_dwords, uint32_t val)
msm_cmd_emit(cmd, val); /* VAL */
}
/*
* Helper to wait on a fence-fd:
*/
static void
wait_and_close(int fence_fd)
{
poll(&(struct pollfd){fence_fd, POLLIN}, 1, -1);
close(fence_fd);
}
/*
* Helper for hang tests. Emits multiple submits, with one in the middle
* that triggers a fault, and confirms that the submits before and after
......@@ -107,7 +96,7 @@ do_hang_test(struct msm_pipe *pipe)
scratch[0] = 1;
for (unsigned i = 0; i < ARRAY_SIZE(cmds); i++) {
wait_and_close(fence_fds[i]);
igt_wait_and_close(fence_fds[i]);
igt_msm_cmd_free(cmds[i]);
if (i == 10)
continue;
......@@ -163,7 +152,7 @@ igt_main
msm_cmd_emit(cmd, 0x1); /* ADDR_HI */
msm_cmd_emit(cmd, 0x123); /* VAL */
wait_and_close(igt_msm_cmd_submit(cmd));
igt_wait_and_close(igt_msm_cmd_submit(cmd));
}
igt_fixture {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment