All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] amdgpu: fix overflow for timeout calculation
@ 2015-11-21  0:24 Alex Deucher
  2015-11-21  0:24 ` [PATCH 2/2] amdgpu: Make amdgpu_cs_calculate_timeout() return something sensible on error Alex Deucher
  2015-11-21 10:48 ` [PATCH 1/2] amdgpu: fix overflow for timeout calculation Ernst Sjöstrand
  0 siblings, 2 replies; 5+ messages in thread
From: Alex Deucher @ 2015-11-21  0:24 UTC (permalink / raw)
  To: dri-devel

From: Jammy Zhou <Jammy.Zhou@amd.com>

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>
---
 amdgpu/amdgpu_cs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
index 4da9821..aa594c4 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, &current);
 		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;
 }
-- 
1.8.3.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-11-21 11:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-21  0:24 [PATCH 1/2] amdgpu: fix overflow for timeout calculation Alex Deucher
2015-11-21  0:24 ` [PATCH 2/2] amdgpu: Make amdgpu_cs_calculate_timeout() return something sensible on error Alex Deucher
2015-11-21 10:48 ` [PATCH 1/2] amdgpu: fix overflow for timeout calculation Ernst Sjöstrand
2015-11-21 11:07   ` Christian König
2015-11-21 11:25     ` Ernst Sjöstrand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.