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: 10170199 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 38FBA603ED for ; Wed, 17 Jan 2018 17:01:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2721E2859F for ; Wed, 17 Jan 2018 17:01:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B670285B7; Wed, 17 Jan 2018 17:01:47 +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 AF2962859F for ; Wed, 17 Jan 2018 17:01:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A5AE86E4DE; Wed, 17 Jan 2018 17:01:45 +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.126.187]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5EBF56E4DE for ; Wed, 17 Jan 2018 17:01:42 +0000 (UTC) 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 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== Cc: linux-samsung-soc@vger.kernel.org, Arnd Bergmann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Tobias Jakobi , linux-arm-kernel@lists.infradead.org, Marek Szyprowski 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 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);