Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751378AbeAPRT1 (ORCPT + 1 other); 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 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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: 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); -- 2.9.0