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: 124884 Delivered-To: patch@linaro.org Received: by 10.46.62.1 with SMTP id l1csp114644lja; Wed, 17 Jan 2018 09:01:46 -0800 (PST) X-Google-Smtp-Source: ACJfBos5k9yhzZ55+mNPoPg6igQcQ1ahWTAviPII8Aym4yLk2Lue8mogzgWl97H4QZLaTk+6tGoY X-Received: by 10.98.160.25 with SMTP id r25mr23703389pfe.218.1516208506750; Wed, 17 Jan 2018 09:01:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516208506; cv=none; d=google.com; s=arc-20160816; b=UrblAbQWFfHkfkD7HwXg7n4oe4zKTXp4xrVVfP+HHvNw9ZDreO6xCp3rIjpgNgaYbv QnYBuBog1l18auXKwLt99rploSVMQoLDHFvwCUb4xXSpVhujbrORRBvcknoIPCpbSj0Y eT6EeubftfVFLKrGnxDJnUxqkvIKWcvV+YYgprVjUX/pENyrfcvU5bwslmljBIJxjgbR 26bubbv3tZZ1DU+KQQXjcicAzAe9ajKXW8XljoxmY6gkqTswgckWSVOcNu4FgjUFI2To IdwqexwEMJYbqtJj9pMDhsrq0DH0NAfAMZ9N1IrTARxKy3mj3OUnlG84wh6BHz4JVtQO AjkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=6ErYHzQfxFxeMK9o8iODk5MXmGDWdklQzDrvn+XQeHw=; b=S0Ej8pr1kB7DyLBIdxNkDisXfWQPFAm52XjLvBqUkSo5qZBRqfU224U3mphnYmZhI3 hP1+z1bbaeDVZwgJShOag+YfdmXuirgOQ/ueCFLxVJtbK6uHOt9eCui9SRZz+jgptmC7 bno9gtGL/gCYILf9AJ/rtd8O1EEnB+wh5hRDCRRx934eWMI221R10MGq76LjnNy7QTXg lmQdO6+5VhE3yCzvDHGAV4XKNo0R3siVR19eP500iUf1z+9OIFxbEkhC3ERjQ6bK3dW4 fG4IRtY1EmNoXBYiavkwg1WF9nj1RdxzSQIG4WhkLVzGqDEd7+OBA/KJ/s5IZxKwpBfK 4V1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id d65si4275355pga.399.2018.01.17.09.01.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jan 2018 09:01:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org 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" 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 --- 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);