diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-12-17 12:27:14 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-12-17 15:03:41 +0000 |
commit | 20fffe7e4209220c63ec45e9b459224833831989 (patch) | |
tree | 1693532e9b819057d03a6f606130b41d7feb857e /lib | |
parent | 471ce7663d57ba7d2135ad9eb9e68f571c698626 (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')
-rw-r--r-- | lib/sw_sync.c | 31 | ||||
-rw-r--r-- | lib/sw_sync.h | 2 |
2 files changed, 17 insertions, 16 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) diff --git a/lib/sw_sync.h b/lib/sw_sync.h index 82af3378..abcdc523 100644 --- a/lib/sw_sync.h +++ b/lib/sw_sync.h @@ -36,7 +36,7 @@ int __sw_sync_fence_create(int fd, uint32_t seqno); int sw_sync_fence_create(int fd, uint32_t seqno); void sw_sync_timeline_inc(int fd, uint32_t count); int sync_merge(int fd1, int fd2); -int sync_wait(int fence, int timeout); +int sync_fence_wait(int fence, int timeout); int sync_fence_count(int fd); int sync_fence_count_status(int fd, int status); void igt_require_sw_sync(void); |