From 5d2ce55a38ef9f426323bef7980a2db794f14935 Mon Sep 17 00:00:00 2001 From: Clarence Ip Date: Fri, 9 Sep 2016 16:41:00 -0400 Subject: drm/msm/sde: don't convert ktime to ns when waiting for fences The driver should utilize the ktime_ series of functions to directly manipulate the time structures rather than converting everything to nanoseconds. This avoids possible trunction/rounding errors that may be introduced by the conversion process. Change-Id: Iac3dd40c679ffc9517881f41650aa5848dab884b Signed-off-by: Clarence Ip --- drivers/gpu/drm/msm/sde/sde_crtc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/msm/sde/sde_crtc.c b/drivers/gpu/drm/msm/sde/sde_crtc.c index 46375e025598..a8ed1daa3706 100644 --- a/drivers/gpu/drm/msm/sde/sde_crtc.c +++ b/drivers/gpu/drm/msm/sde/sde_crtc.c @@ -402,8 +402,7 @@ static void _sde_crtc_wait_for_fences(struct drm_crtc *crtc) { struct drm_plane *plane = NULL; uint32_t wait_ms = 1; - u64 ktime_end; - s64 ktime_wait; /* need signed 64-bit type */ + ktime_t kt_end, kt_wait; DBG(""); @@ -413,8 +412,8 @@ static void _sde_crtc_wait_for_fences(struct drm_crtc *crtc) } /* use monotonic timer to limit total fence wait time */ - ktime_end = ktime_get_ns() + - to_sde_crtc_state(crtc->state)->input_fence_timeout_ns; + kt_end = ktime_add_ns(ktime_get(), + to_sde_crtc_state(crtc->state)->input_fence_timeout_ns); /* * Wait for fences sequentially, as all of them need to be signalled @@ -428,9 +427,9 @@ static void _sde_crtc_wait_for_fences(struct drm_crtc *crtc) drm_atomic_crtc_for_each_plane(plane, crtc) { if (wait_ms) { /* determine updated wait time */ - ktime_wait = ktime_end - ktime_get_ns(); - if (ktime_wait >= 0) - wait_ms = ktime_wait / NSEC_PER_MSEC; + kt_wait = ktime_sub(kt_end, ktime_get()); + if (ktime_compare(kt_wait, ktime_set(0, 0)) >= 0) + wait_ms = ktime_to_ms(kt_wait); else wait_ms = 0; } -- cgit v1.2.3