From patchwork Tue Jan 16 17:18:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 124753 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1085771lje; Tue, 16 Jan 2018 09:19:29 -0800 (PST) X-Google-Smtp-Source: ACJfBos/AWDaayqbIPRtiQv/5vW/bLsyKRG6WSUUqrK9BeJS0JRrSX2kBiOJQzn3l6EoqTppckXw X-Received: by 10.98.31.72 with SMTP id f69mr30911637pff.196.1516123169425; Tue, 16 Jan 2018 09:19:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516123169; cv=none; d=google.com; s=arc-20160816; b=StX/D7jHv1yrndb7R2myb2egw0sKwKHCFEkiM3WW2VPPfSDFmgU6ULl1mEkYJ+ezhq pur/blwwQOTw9Fv3AFBzKEN1LFZe+hs0mRFlXleSCfJt07ZUq0Je1QolddKy4qw+zpn8 h3/b9S8oOFV59Z1r2laflgcnQ55kIqLqripOLYyRe4W5Fj4WRXiZyvXyRl4HxnU5aX6S x8fktF0SnV3lN4gOM6bz2N9n0mjUu1uBsYWr/Zlp8H7VYeEKVApp071SXaTcpMJ4dzHh P/E+zaFXT9kOuxkyTOW2hGNZV7pCskfoJ2yU+uaT7pb8xkNOUoqRakPVkcemUrF5ldxQ f7Pw== 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=0c6dj2TlI2MUwo8GojFU9YmuT+rb1FWBrL9ff7AsgmE=; b=ZD6xqnaUdSpReXBEjKcbLOrwWV+Lx0KyEJakvgKael26jC0GyJSxw39qnKgYZP6grl YqUUuxDWYeGCGBYlPMqonsdZFrZb0N4eEYxBJUgv3KMdK40RImXwaWEv0Vum199edeRL BowClp4diZS0jZ8Co+eEannPWnafjLNNEjvJ+w06hD12rSEGoLHq97G8RSrw1W4PvEEl ooazCi6Mgiu0wwcmNxlJ1F7rrhtMwxdJcHULJKxxt9jOdOvz/9bq194zQvSydcKCyrXd 2OgXylm3ichvU9I+Oake7fhD1FShQylDVgOSiDAvnAMfLbgPUrpcrc9l/s/nskhAvHQ0 YRZA== 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 l6si2425000pln.269.2018.01.16.09.19.29; Tue, 16 Jan 2018 09:19:29 -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 S1751378AbeAPRT1 (ORCPT + 28 others); Tue, 16 Jan 2018 12:19:27 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:56891 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750752AbeAPRTZ (ORCPT ); Tue, 16 Jan 2018 12:19:25 -0500 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.145]) with ESMTPA (Nemesis) id 0Lutsn-1f2LPl1Ba5-0103Xh; Tue, 16 Jan 2018 18:19:12 +0100 From: Arnd Bergmann To: VMware Graphics , Sinclair Yeh , Thomas Hellstrom , David Airlie Cc: y2038@lists.linaro.org, Arnd Bergmann , Deepak Singh Rawat , Patrik Jakobsson , Alex Deucher , Arvind Yadav , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] [RESEND] vmwgfx: use monotonic event timestamps Date: Tue, 16 Jan 2018 18:18:43 +0100 Message-Id: <20180116171910.3259056-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:VK3uvwL4XEmOZLE/kAjHAiDjLbhFV01uxXuQE2zptCpd6Js1Q9Y Sc9DcAqzS98SyWUIGCpmQ5VGSepXLPhGUeoa0Xbx2fnRiUMqksfFh8GbSyDjUppuWGVvKLD jeRyPKn6tpsTRpd1oH4kBKA1LZmDl6AKXKRcV/T4f2C7JBfLfF8ShF+Jr9LyaICygP65dt/ YLug6BisLBeDia74Cl4sg== X-UI-Out-Filterresults: notjunk:1; V01:K0:y+rLPUtzzHg=:1VaAtGhBmNqJK1b7NEzGXy +PEuDKb/xuLEfhQ2dCZu2dkW0uYg0Tx562+d1Vu3xo+mdIRjuwezdq5BC6MzHtxAri6HmknDS ZGrAR5Sm5tsIae/dbJX5wFPj1R/WarkBHZnSsiJ+Dig3ZvA5e5/0bDgT/aI5RrSeSjG6mmtXN 3W7Pz1LrL0FMvKWwit0aq7q8Hdg9NpyIzrDYTQSFDDNBz/IVX4ZQZDz8usj0V+1x6wbS3lw6c KV08m32smrwF72mWbXzBey+CIDeZgGMnFSnTYsSQO61lH4Vk4uM1/jW5V2FYi5MbQT6/xE/CK QIZitdkXVobH3kyfbHAAsLfC+JduZ5814aXnw3QcUoFIoHDIYEii6PtCjvd0s5Xte1dlTLUaR qXX68Z2SI1EHY20zgov0fVVuv0b2RHHDxkGgGsitzLaOjqByVEpYt7neuTfsv+c8s7hZkTHCH rnE2haCHy03nUjUA/D6BWv6woN3G12OiD80roVfzSKEMEarXx5Z90faBPDjR62rGc7tmIHhmb hcJ7vZN0NkXEU89vnENE7LKjsJjG1XnQCbHvIiao87n6Y2UsRkm3OSwlMjD1o6ibmz+7Oph8R IjyDoFV+Z48yXtDkGoJKuNBmEMUftAHgyWGXsJ4Kpn543KIUM95PGiojwuY3BflLHmFschSx8 kynirm2LE0ZlWETn9ZfsZIpTkyx7wUdt3MCSWabSv0Hm/giiWSGOSpRDAFLGoAHWOFBe0Kn6i kbtAFNF76cyL01UCRiJaNLnObCYkhj2A6wlmbg== 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(). Link: https://patchwork.kernel.org/patch/10076599/ Signed-off-by: Arnd Bergmann --- Originally sent on Nov 27. Sinclair Yeh said he'd pick it up for the next pull request, but it's not in linux-next yet. Resending the unchanged patch, please pick it up when you have time, or feel free to ignore this email in case it's already in some tree that just isn't part of linux-next but will be sent during the next merge window. --- 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 6c5c75cf5e6c..9ed544f8958f 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c @@ -901,11 +901,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);