From patchwork Wed Jan 17 17:01:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10170205 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 83A59603ED for ; Wed, 17 Jan 2018 17:02:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 709AB285BE for ; Wed, 17 Jan 2018 17:02:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 652A0285D9; Wed, 17 Jan 2018 17:02:09 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C78F285BE for ; Wed, 17 Jan 2018 17:02:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754124AbeAQRCH (ORCPT ); Wed, 17 Jan 2018 12:02:07 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:51119 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753916AbeAQRCE (ORCPT ); Wed, 17 Jan 2018 12:02:04 -0500 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0Lnopk-1f4LHr1gzo-00g4Jg; Wed, 17 Jan 2018 18:01:35 +0100 From: Arnd Bergmann To: Inki Dae , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , David Airlie , Kukjin Kim , Krzysztof Kozlowski Cc: Marek Szyprowski , Arnd Bergmann , Tobias Jakobi , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] drm/exynos: g2d: use monotonic timestamps Date: Wed, 17 Jan 2018 18:01:21 +0100 Message-Id: <20180117170131.2677586-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:0vzQd3zs3f/+98QS16NCIg3Kw3FUzadEkl2Ro5NwjGNzJhgjJOH HoKC4pbyL/lzeZ22y3ot9z2RaHWHPRCWb7QMoZhSonKv7287WYTkNG2+toBinCd5pQg/1JA 4cpJ+QNNBZ+/Wx6uVlbwcAm88pRx1PhxCG96LvUvsDCoWOi1BcTjg+4bxURTnml3nMaMI1P JAkAmLc/Qo691F2kjMraA== X-UI-Out-Filterresults: notjunk:1; V01:K0:lsXyPkCSjFs=:cz8FXUwLmP/hqBhU/djfUC kjIZq03cDulRGIu/vgLkhTOAcTVqUDNizA8mxU8ismVG2eQZ/BG4e9j1SEHZEgWHQOw9qlnUB 20dGZLXyBAKJHWlAF+BVfJVRx76KDeqjNHoG/RC4Poy/UuJeJ29P/BARCjD4tNaPW788LG+Fi XreCo6eoA+RBF2yAOIGo9AV/2PqfSN2EUbcGkRk60nXaMFNe7OEoY1Wc/axLMLmB7Ly0sAWtS c04uYfpt32JNd/4SgEdYybb0XH+8sLA/F18u9WGt8A62v/LAxMsiz6Jm1OFZUP18JHy5Ng9ve VDaar3laRuwHFVt2kVCHb5MmTW77R1gQxOPEP8Fsl0MYLCIap5DmqeyvjDi1piC0wxMfcu6F4 RLm6suuRosDkFs1lIk57sB8CIEtAmQBGu746HJJ3sIvSYB8ew/C1YMJWRBhVx9PhglYh3Bs/A 52D/pcJ989MO+RVxFwfBV1Y0xbVo+tciMGnyMlr8vELUSjXmHrhm0AXam6KFYmIAxQYNr9Fs0 v4a+P2B/+ShnibHzhE2jB1iwSRdKETQBq1t2OfL8fhpvtxLPNnmAyW5n40Gy3ZkTSU5CYIttP iwq/If8DSss8l8My38Vyw+8Oo/PT01Dw3PJuQtPu7pueF8ptDtYVoCqfWNxjAHizYrPCh/L45 tELlH3sA0GN35Vt5d0Yy+vusF/R0ftBpk8iR5My7dOC+cYZrIuS6lN2VkGdsC3YnJnj2Up9+J 961lk6UNU1u2k5A0tHHAc/2mNVVAoWqtrM5PRQ== Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The exynos DRM driver uses real-time 'struct timeval' values for exporting its timestamps to user space. This has multiple problems: 1. signed seconds overflow in y2038 2. the 'struct timeval' definition is deprecated in the kernel 3. time may jump or go backwards after a 'settimeofday()' syscall 4. other DRM timestamps are in CLOCK_MONOTONIC domain, so they can't be compared 5. exporting microseconds requires a division by 1000, which may be slow on some architectures. The code existed in two places before, but the IPP portion was removed in 8ded59413ccc ("drm/exynos: ipp: Remove Exynos DRM IPP subsystem"), so we no longer need to worry about it. Ideally timestamps should just use 64-bit nanoseconds instead, but of course we can't change that now. Instead, this tries to address the first four points above by using monotonic 'timespec' values. According to Tobias Jakobi, user space doesn't care about the timestamp at the moment, so we can change the format. Even if there is something looking at them, it will work just fine with monotonic times as long as the application only looks at the relative values between two events. Link: https://patchwork.kernel.org/patch/10038593/ Cc: Tobias Jakobi Signed-off-by: Arnd Bergmann Reviewed-by: Tobias Jakobi --- v2: rebased to what will be in 4.15, now that ipp is gone, updated changelog text based on input from Tobias. --- drivers/gpu/drm/exynos/exynos_drm_g2d.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c index 2b8bf2dd6387..9effe40f5fa5 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c @@ -926,7 +926,7 @@ static void g2d_finish_event(struct g2d_data *g2d, u32 cmdlist_no) struct drm_device *drm_dev = g2d->subdrv.drm_dev; struct g2d_runqueue_node *runqueue_node = g2d->runqueue_node; struct drm_exynos_pending_g2d_event *e; - struct timeval now; + struct timespec64 now; if (list_empty(&runqueue_node->event_list)) return; @@ -934,9 +934,9 @@ static void g2d_finish_event(struct g2d_data *g2d, u32 cmdlist_no) e = list_first_entry(&runqueue_node->event_list, struct drm_exynos_pending_g2d_event, base.link); - do_gettimeofday(&now); + ktime_get_ts64(&now); e->event.tv_sec = now.tv_sec; - e->event.tv_usec = now.tv_usec; + e->event.tv_usec = now.tv_nsec / NSEC_PER_USEC; e->event.cmdlist_no = cmdlist_no; drm_send_event(drm_dev, &e->base);