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: 119669 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1552152edl; Mon, 27 Nov 2017 03:16:57 -0800 (PST) X-Google-Smtp-Source: AGs4zMb5hv5p0YhKLB+A+rS+PLaU5EIiqYCYQYklxTyLFd6VXt1KV0Gr2QQVivrBFBy7rg8mDa/n X-Received: by 10.99.191.1 with SMTP id v1mr16008064pgf.93.1511781416888; Mon, 27 Nov 2017 03:16:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511781416; cv=none; d=google.com; s=arc-20160816; b=y/tYjW+MvdC6EspHRIzjY0teRkEfJwVUSAckq7R4cnIhWv3kAxm3buPsMoBwlkPPjA KKg2ZWLLg1KRG6pDiJhAoJsApI4CI29uqrx8Mcc8gp17Li40t1PvEMh2Lgl+sdhwWDtA ZgTzPtBrkwH/lsLTlUQxqJ4POvMiQbKlw/WER9IhN1T1K9tjJSCCOLSnu5o+cSF931RN 5e196QkgdQqcPZM4Kve+fLs6ymMtMnpC4af44LJm2s0TMxRH587VmLX1CDoeWdSO5/1V 1Q7dIGUgU4PJSxVlSK+VD1Tjc7kcYjLMVJdY2SR7L35j/ecmbdzRdDm/vnuZVyftGVW8 WQEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Id+MIVn/DyuA7KxAzMFsCZEA1wR9QsVx7CkU3yutFOA=; b=ZkawzfXH3782+u2akaqgTkzZJWQzskk4kyHEmyzWkxY3l3qOUw2tBId8wY+zV8iHFm XrFpxjG4g8aDmoqTg0TIS16DYvJnriR5Is5CKvsIjz0ViA/8mPaePSweT4ubUEls9eGw 2UZkeSPy1LXRJ2wt4hB9yQVHeZo/KkCT/pNfEXVB7jU2iRDrpatSUgzWc2XL0PQZHQvQ eYMH6ATC4HZVX0f9tywV2gG3/FrH5DlfirXtmUW4Jl1HIeDF6YpyBZGdAGAaVHPOeTvL IwcufDZ0pDMEMTKPA+VoB5sEKLPdthRNYDU65vrAGkSbYSYxYXIyh9SFW34esiQrnwgN kpFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7si22696575pgs.719.2017.11.27.03.16.56; Mon, 27 Nov 2017 03:16:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751482AbdK0LQy (ORCPT + 28 others); 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 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 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 Precedence: bulk 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(-) -- 2.9.0 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);