From patchwork Mon Nov 27 11:16:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10076597 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 95E2E6028E for ; Mon, 27 Nov 2017 11:17:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 789372895D for ; Mon, 27 Nov 2017 11:17:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C10028AC5; Mon, 27 Nov 2017 11:17:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E2F882895D for ; Mon, 27 Nov 2017 11:16:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 408626E2A7; Mon, 27 Nov 2017 11:16:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id DFC2B6E2A7 for ; Mon, 27 Nov 2017 11:16:49 +0000 (UTC) Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0LopTv-1ekuVu3prH-00grP0; Mon, 27 Nov 2017 12:16:34 +0100 From: Arnd Bergmann To: VMware Graphics , Sinclair Yeh , Thomas Hellstrom , David Airlie 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== Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Tomi Valkeinen , Arvind Yadav , Joe Perches , Ravikant B Sharma , Deepak Singh Rawat X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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);