From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751451AbdK0LQy (ORCPT ); Mon, 27 Nov 2017 06:16:54 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:64640 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751292AbdK0LQx (ORCPT ); Mon, 27 Nov 2017 06:16:53 -0500 From: Arnd Bergmann To: VMware Graphics , Sinclair Yeh , Thomas Hellstrom , David Airlie Cc: Arnd Bergmann , Deepak Singh Rawat , Tomi Valkeinen , Arvind Yadav , Ravikant B Sharma , Joe Perches , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] vmwgfx: use monotonic event timestamps Date: Mon, 27 Nov 2017 12:16:19 +0100 Message-Id: <20171127111629.1682286-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:WAy7Tdd7wETt5o/wYwam81KnqjBD4Fe77JrocPK7KX8rcKy71F1 iplHMk24PBBQSKjk7wKbyPPQSOLHkmGKS6H9AMk3tA3M3mKddpSGnb7UGWJzk8/ziXrR7H+ 7/GYbMQSK2+/tOEHraL1rurW7HCZYujRgaNz/iiIcZkxVzCLJ4o/7jUKw2SX1kUqIECAHa4 QXXaV7bST4OO6mzXuoa+Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:R0zewldZXLg=:HqqcPMZixoZ7hACfWr5QjK F6nUyY8EQNyBkumBnd1Il6lLoH7s08yAfsBjc9nQqZVq2jxqQHlIOQBujT3Kj086vPh4HN+JO BgURaB1uOWzVtWoLJGOmuyhnGF3yv5FPuuErieXaHQb8I6wdNKJ5Se6MvS4My7/y1qgm0uRRW LixzL9iRczIITubBB+ybW959W3xmw7NJIGVytvxiGf+yKIRz5bifg0uJDHOMzaLtehzmJGCQk stWfb43fKY+UwvG95QezqpF9izNb4kN6FTlXLSVbg43FyHmYZ5dJCjbaSmVAE5PuYkxD4vC12 fX9AOADmncSBZXA4aliivovypt9SHAL+CPHc1CDBWgI6+kOQn7p8XarYHX/0/bQ+ra/de63N4 fWHGA+vL9QlGspw32JjXVP0i615Qhq0TeqwwOux4GafLYgcYmbz1WumlDFZK5EnED2vNFHBro NNFOrZrOC/QNCDTCPBcHle6S/Ei5fWgouMhSTosHCQgmbOahfBchv1j2f7q42E5uaAOoN4NSq IpFE06CKZ01rgMuwHfiM7fBmg7upxC3mNYH4/nHr4nFkRKA/mYyikW7tFbpPANvzjysyHlEA2 T6PHF1wynuHGiDTujPWV4sIYwt9US2mn4DC9OwurOwxOo40oJZaKfta9Zi5aZl13s/NX4qS+Q 3BWmM8xx6MP37egfNH2nNipQhOUA5uT7F2b4Ia+bReWIpbM1RsQv4Chg1viLmCz/JXSBWK+ly Fl6mWMtd0faWfI1W0kCJ/Z+iMibGCj2YsQPnuQ== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org DRM_VMW_EVENT_FENCE_SIGNALED (struct drm_vmw_event_fence) and DRM_EVENT_VBLANK (struct drm_event_vblank) pass timestamps in 32-bit seconds/microseconds format. As of commit c61eef726a78 ("drm: add support for monotonic vblank timestamps"), other DRM drivers use monotonic times for drm_event_vblank, but vmwgfx still uses CLOCK_REALTIME for both events, which suffers from the y2038/y2106 overflow as well as time jumps. For consistency, this changes vmwgfx to use ktime_get_ts64 as well, which solves those problems and avoids the deprecated do_gettimeofday() function. This should be transparent to to user space, as long as it doesn't compare the time against the result of gettimeofday(). Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c index d6b1c509ae01..55214d0da66e 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c @@ -897,11 +897,12 @@ static void vmw_event_fence_action_seq_passed(struct vmw_fence_action *action) spin_lock_irq(&dev->event_lock); if (likely(eaction->tv_sec != NULL)) { - struct timeval tv; + struct timespec64 ts; - do_gettimeofday(&tv); - *eaction->tv_sec = tv.tv_sec; - *eaction->tv_usec = tv.tv_usec; + ktime_get_ts64(&ts); + /* monotonic time, so no y2038 overflow */ + *eaction->tv_sec = ts.tv_sec; + *eaction->tv_usec = ts.tv_nsec / NSEC_PER_USEC; } drm_send_event_locked(dev, eaction->event); -- 2.9.0