Received: by 10.223.148.5 with SMTP id 5csp6076769wrq; Wed, 17 Jan 2018 09:03:29 -0800 (PST) X-Google-Smtp-Source: ACJfBouHo4j6yGr/z0v3XDO2WUPD6kh+4wOOQ1CiXr7ltaPVjXj18HA4zuz+5ctMbCL7uOsAWIZa X-Received: by 10.101.101.68 with SMTP id a4mr9362586pgw.368.1516208609562; Wed, 17 Jan 2018 09:03:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516208609; cv=none; d=google.com; s=arc-20160816; b=VknA605sPtjNra3krCNjbaTsvfKKahJ/R8/pLr2GEEC1Id+TXmSJFHHtysq8eoaPiL +Y8Pq+P8a1rkCxgsNa2paAcd9M88Q7rLU8H66jqNyE1SHoQ5vOkf/Nr/APjeSO9F1vAU ppFuZcYqSkHc/wij5lS2WlNhouvCZB90B3lwBLK4B3VlLiSC1/AUncJtzqEHqnW5kBEO iMVcEKpvuQdSEsZmOZ5bSh+0tzaMfBVw4rYLHjxk26G3Eyr9uAglzlHmSwSsZtyTDKqa IOeqhfwBHfC0t7Ztst+pFLIUGuYbpY08AxuqNzhp+YhEZbSdryrZkixuUFnG++I6AR60 +ilw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=WO3kXF91UYj9UmzJ1/sp6n9m9eYekmX9isxtUvy7+I4=; b=tr+G7lbQYJAUilWVe/4hbSk76zFkMhWj17A7Yjm722Ruhfky95fDEg3aHM0x7XbQDt eUpRZAMVRZvjDopuzHfmS0ekY4dxZQTrCkx5gTqUDGSZ3YtrwweupEubwMzXagsHwqEp DaI7CPdf47IioBYhpyss155EBAaunRn/MummhRiIu2C0xfwbBaXFcOpkNLssXjDi81sQ 8TftbXDU81kJdVMYwTKnzJuz4ssv4ZLoi6Srr3trspUC2sz+YfXYFnMGCfPhxRF6bA/o OTb1AlnuKlyYwzZD4xb/GZqSifAA9BXYd3u4XS0rwL28ffLgmu8KoZrKncxJlSoc4Guv RlMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t6si4882529plz.522.2018.01.17.09.02.52; Wed, 17 Jan 2018 09:03:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754578AbeAQRCI (ORCPT + 99 others); Wed, 17 Jan 2018 12:02:08 -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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linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.9.0