diff options
author | Jammy Zhou <Jammy.Zhou@amd.com> | 2015-11-17 17:14:35 +0800 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-11-20 19:21:48 -0500 |
commit | 9c15b4aacdd9265339aba6febd36a7e2c41b6968 (patch) | |
tree | 580834e83ec1b42042161e54aa17cee2fe47eefe /amdgpu | |
parent | 8913cd95b2f815687f356574fde35179d292cbd1 (diff) | |
download | libdrm-9c15b4aacdd9265339aba6febd36a7e2c41b6968.tar.gz libdrm-9c15b4aacdd9265339aba6febd36a7e2c41b6968.tar.bz2 libdrm-9c15b4aacdd9265339aba6febd36a7e2c41b6968.zip |
amdgpu: fix overflow for timeout calculation
Set the timeout to AMDGPU_TIMEOUT_INFINITE when overflow happens
Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Diffstat (limited to 'amdgpu')
-rw-r--r-- | amdgpu/amdgpu_cs.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c index 4da98214..aa594c44 100644 --- a/amdgpu/amdgpu_cs.c +++ b/amdgpu/amdgpu_cs.c @@ -289,12 +289,16 @@ drm_private uint64_t amdgpu_cs_calculate_timeout(uint64_t timeout) if (timeout != AMDGPU_TIMEOUT_INFINITE) { struct timespec current; + uint64_t current_ns; r = clock_gettime(CLOCK_MONOTONIC, ¤t); if (r) return r; - timeout += ((uint64_t)current.tv_sec) * 1000000000ull; - timeout += current.tv_nsec; + current_ns = ((uint64_t)current.tv_sec) * 1000000000ull; + current_ns += current.tv_nsec; + timeout += current_ns; + if (timeout < current_ns) + timeout = AMDGPU_TIMEOUT_INFINITE; } return timeout; } |