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: 10167733 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 11432601E7 for ; Tue, 16 Jan 2018 17:24:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAEB52465D for ; Tue, 16 Jan 2018 17:24:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF55426AE3; Tue, 16 Jan 2018 17:24:40 +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 68BFA2465D for ; Tue, 16 Jan 2018 17:24:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2D8D1899D4; Tue, 16 Jan 2018 17:24:38 +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 [212.227.17.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0BE1D893D5 for ; Tue, 16 Jan 2018 17:24:36 +0000 (UTC) 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 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:SYPQrzJNyZY=:ylEYt4et9d88ZGl7KbSoY/ 2t1GpD731zyHi7fuY59v8wmC/T/yD4jVy1Wg850vFUHomyprDuPmpOp8xG6WgWVws/1dTeHS5 SYCVkpv7vNMNE6bwT1bgdPy4AVki84VSS31d9SPaeiGHtZukvvCvim5yd3F4Q4NeeeLI8q4nw nOBhhBR7TWra/1R3ZcnNQaIKFB8ph7GyLKokSShYYKuFMfqa1XHwNTd5cRanMatidCST1hYPw KsLihIQws1G2DurrRsL4IYJLPPrB5d0KK2XkY7uJ6Z5yr/ItMFwzOhUsT1Mj54hKwhCMEWCQ0 gz4q5IE8bTcLj6/k4dYOc3eSI0fyJgL9bPCyjYh24ou9e/PqyEWPb9Xx4LhCNuFv8wVtBT2UY e9VnqasVF5hrnIs9VZuSRNJV/6wEaQm1tftchbIy/NxMUkhRqy/PF7XQczz3phUtE56MR3UNh RpUTRDje4rdUbY1YmqEqnhCUSlMbVj16k6tWUAtaU/jjn/bufXNQbL5ofsmd8Gtxe9bIdCY08 BCXGILdSJq4lljNerIKE0mZ512P3qRNy3wXliB5+K8G7u8XzpBTwV8I6uMwW5pBfJzq7SxzlD 3XQCT+qcGFYRldbf+uXsI9UQAXqzVp+3vcircQEXDT5c5NZxrKPGqKfd3Zmp2JSHEJwcHlWDw yM20yZ2+Erllm5eym3YVANzsqW3dRXzyasSltD/YcZuBQ8EAJDrSMhr7skI+//uwmTGGJcXdB PnoYq+xC4RBIilJcxNqiPMzOS5arJXiqOFyb9A== Cc: Arnd Bergmann , y2038@lists.linaro.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Alex Deucher , Arvind Yadav , 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(). 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(-) 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);