summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/os/os_time.h
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2015-06-27 00:05:26 +0200
committerMarek Olšák <[email protected]>2015-07-05 15:08:59 +0200
commit7316cc92f3810c9e53a22c35343190d8fb7980be (patch)
tree10eadbf00458d05015db1e4614ca11ccb53a36e0 /src/gallium/auxiliary/os/os_time.h
parent3836857a777a248dd212ce7a1d7307d2984fda7d (diff)
gallium/os: add conversion and wait functions for absolute timeouts
Absolute timeouts are used with the amdgpu kernel driver. It also makes waiting for several variables and fences at the same time easier (the timeout doesn't have to be recalculated after every wait call). Reviewed-by: Alex Deucher <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/os/os_time.h')
-rw-r--r--src/gallium/auxiliary/os/os_time.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/os/os_time.h b/src/gallium/auxiliary/os/os_time.h
index 2989af10fe2..21979a72ac5 100644
--- a/src/gallium/auxiliary/os/os_time.h
+++ b/src/gallium/auxiliary/os/os_time.h
@@ -95,6 +95,17 @@ os_time_timeout(int64_t start,
/**
+ * Convert a relative timeout in nanoseconds into an absolute timeout,
+ * in other words, it returns current time + timeout.
+ * os_time_get_nano() must be monotonic.
+ * PIPE_TIMEOUT_INFINITE is passed through unchanged. If the calculation
+ * overflows, PIPE_TIMEOUT_INFINITE is returned.
+ */
+int64_t
+os_time_get_absolute_timeout(uint64_t timeout);
+
+
+/**
* Wait until the variable at the given memory location is zero.
*
* \param var variable
@@ -105,6 +116,21 @@ os_time_timeout(int64_t start,
bool
os_wait_until_zero(volatile int *var, uint64_t timeout);
+
+/**
+ * Wait until the variable at the given memory location is zero.
+ * The timeout is the absolute time when the waiting should stop. If it is
+ * less than or equal to the current time, it only returns the status and
+ * doesn't wait. PIPE_TIME_INFINITE waits forever. This requires that
+ * os_time_get_nano is monotonic.
+ *
+ * \param var variable
+ * \param timeout the time in ns when the waiting should stop
+ * \return true if the variable is zero
+ */
+bool
+os_wait_until_zero_abs_timeout(volatile int *var, int64_t timeout);
+
#ifdef __cplusplus
}
#endif