summaryrefslogtreecommitdiff
path: root/lib/sw_sync.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-12-17 12:27:14 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2016-12-17 15:03:41 +0000
commit20fffe7e4209220c63ec45e9b459224833831989 (patch)
tree1693532e9b819057d03a6f606130b41d7feb857e /lib/sw_sync.c
parent471ce7663d57ba7d2135ad9eb9e68f571c698626 (diff)
lib/sw_sync: Bring sync_wait() API into line
igt likes to return kernel-esque negative errno where we can, and indicate that we expect to operate on a sync_fence, otherwise it is merely a grandiose poll(). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/sw_sync.c')
-rw-r--r--lib/sw_sync.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/sw_sync.c b/lib/sw_sync.c
index 116f9357..8d8e11b1 100644
--- a/lib/sw_sync.c
+++ b/lib/sw_sync.c
@@ -166,26 +166,27 @@ int sync_merge(int fd1, int fd2)
return data.fence;
}
-int sync_wait(int fd, int timeout)
+int sync_fence_wait(int fd, int timeout)
{
struct pollfd fds = { fd, POLLIN };
int ret;
do {
- ret = poll(&fds, 1, timeout);
- if (ret > 0) {
- if (fds.revents & (POLLERR | POLLNVAL)) {
- errno = EINVAL;
- return -1;
- }
- return 0;
- } else if (ret == 0) {
- errno = ETIME;
- return -1;
- }
- } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
-
- return ret;
+ ret = poll(&fds, 1, timeout);
+ if (ret > 0) {
+ if (fds.revents & (POLLERR | POLLNVAL))
+ return -EINVAL;
+
+ return 0;
+ } else if (ret == 0) {
+ return -ETIME;
+ } else {
+ ret = -errno;
+ if (ret == -EINTR || ret == -EAGAIN)
+ continue;
+ return ret;
+ }
+ } while (1);
}
int sync_fence_count(int fd)