freedreno/drm: Don't miscalculate timeout
authorGuido Günther <agx@sigxcpu.org>
Wed, 22 Jan 2020 10:43:11 +0000 (11:43 +0100)
committerMarge Bot <eric+marge@anholt.net>
Thu, 23 Jan 2020 18:07:13 +0000 (18:07 +0000)
The current code overflows (s * 1000000000) for s >= 5 but that is
e.g. used in msm_bo_cpu_prep.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3514>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3514>

src/freedreno/drm/msm_priv.h

index 172e9870fe5973e497229ff39e03e3b229ca4635..37adb13624ca793af6eb117ac8a6be221ff4c60a 100644 (file)
@@ -108,10 +108,9 @@ msm_dump_submit(struct drm_msm_gem_submit *req)
 static inline void get_abs_timeout(struct drm_msm_timespec *tv, uint64_t ns)
 {
        struct timespec t;
-       uint32_t s = ns / 1000000000;
        clock_gettime(CLOCK_MONOTONIC, &t);
-       tv->tv_sec = t.tv_sec + s;
-       tv->tv_nsec = t.tv_nsec + ns - (s * 1000000000);
+       tv->tv_sec = t.tv_sec + ns / 1000000000;
+       tv->tv_nsec = t.tv_nsec + ns % 1000000000;
 }
 
 /*