Mesa (master): etnaviv: drm: Normalize nano seconds

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun May 10 07:44:43 UTC 2020


Module: Mesa
Branch: master
Commit: 56f955e4850035d915a2a87e2ebea7fa66ab5e19
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=56f955e4850035d915a2a87e2ebea7fa66ab5e19

Author: Guido Günther <agx at sigxcpu.org>
Date:   Thu Jan 23 09:20:00 2020 +0100

etnaviv: drm: Normalize nano seconds

Make sure the nano second part is less than one second. This matches
what clock_settime expects and allows for more concise kernel
interfaces.

Signed-off-by: Guido Günther <guido.gunther at puri.sm>
Reviewed-by: Jonathan Marek <jonathan at marek.ca>
Reviewed-by: Christian Gmeiner <christian.gmeiner at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3534>

---

 src/etnaviv/drm/etnaviv_priv.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/etnaviv/drm/etnaviv_priv.h b/src/etnaviv/drm/etnaviv_priv.h
index 93bd2d90985..054e6cc730e 100644
--- a/src/etnaviv/drm/etnaviv_priv.h
+++ b/src/etnaviv/drm/etnaviv_priv.h
@@ -208,6 +208,10 @@ static inline void get_abs_timeout(struct drm_etnaviv_timespec *tv, uint64_t ns)
 	clock_gettime(CLOCK_MONOTONIC, &t);
 	tv->tv_sec = t.tv_sec + ns / NSEC_PER_SEC;
 	tv->tv_nsec = t.tv_nsec + ns % NSEC_PER_SEC;
+	if (tv->tv_nsec >= NSEC_PER_SEC) {
+		tv->tv_nsec -= NSEC_PER_SEC;
+		tv->tv_sec++;
+	}
 }
 
 #if HAVE_VALGRIND



More information about the mesa-commit mailing list