Received: by 10.223.148.5 with SMTP id 5csp6184347wrq; Wed, 17 Jan 2018 10:26:16 -0800 (PST) X-Google-Smtp-Source: ACJfBovf8dX9fRCUhBJ2jnhZH7H+kwO9I9misOWWi9cg8GBS7VfApyVh5BvO7tb1tuK2AueGAZsO X-Received: by 10.84.242.1 with SMTP id ba1mr35170349plb.125.1516213575920; Wed, 17 Jan 2018 10:26:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516213575; cv=none; d=google.com; s=arc-20160816; b=XSH+dbPL4s/RynWHMdjlkbX44Dd+gNLCpaQ48DP5tiXvm75/U+WJ28P0vpBUQUDSka eWW8RZyLFusV+bXaIi4t4ducjU9X2YqqsG0pWMHkTfyWgRO3Cp+LsIsJg1NctTxUCaGt RnBAqDvZBa7a4xVNCs9bCZHdjrBqyQi6HvxiRsxyYvan52UVKoyVRIB7iocVIkhBzDTl 8vEGVu5e+RZ7kE2SXa3TuKxoLuJZOFVIYzau5qPvURq7iO7PNHgu7pgARV1CCCpqDX1L I2q8Pak4zLTdynCHRBvVMcsHtRANSOxQ7aD2GRPBiMUPF8QnbVrOuYrVkW4ORW46Q9Ak If6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject:arc-authentication-results; bh=ZxSRMjUtBeOuhJY2i7/LRdEj9xX9Jk1GjA1XZ8Xwz1M=; b=xYUrZi8/rBL0ok+xYBOueOtGZq7f7JHvgmmfgO58bLBfiwmFdXd6mEkyYHg0zZ6g3L 6omuKg1ViTLkJ7tiA/+q9Zbg0EGHO9ZJOtdjzJ8/Fen3peRmY9bEFMYvFLnhfEbsiC2S rvFkcgR4TTcFjKMxpWDZzg+TXkEK39t0bCLsUjHfflI04GQimfONeb0301J2u2UlTTMc CBuX7Lwx08yKx5871beRqtYhoqCgq4qotZ9QAc3HpjSsCgksS0A7K38d/yfBY/oL60nd gebehCqyPMXNWDaHq52ThEv7KYDpmygH/H2MlHjyza+ExIOixKzcXVqL+KKUegh9poZ+ bKfw== 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 h22si4849551pfa.14.2018.01.17.10.26.01; Wed, 17 Jan 2018 10:26:15 -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 S1754220AbeAQSXs (ORCPT + 99 others); Wed, 17 Jan 2018 13:23:48 -0500 Received: from smtp.math.uni-bielefeld.de ([129.70.45.10]:35045 "EHLO smtp.math.uni-bielefeld.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752579AbeAQSXq (ORCPT ); Wed, 17 Jan 2018 13:23:46 -0500 X-Greylist: delayed 444 seconds by postgrey-1.27 at vger.kernel.org; Wed, 17 Jan 2018 13:23:46 EST Received: from [192.168.0.179] (p4FECF57F.dip0.t-ipconnect.de [79.236.245.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by smtp.math.uni-bielefeld.de (Postfix) with ESMTPSA id 925255FEA5; Wed, 17 Jan 2018 19:16:18 +0100 (CET) Subject: Re: [PATCH] [v2] drm/exynos: g2d: use monotonic timestamps To: Arnd Bergmann , Inki Dae , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , David Airlie , Kukjin Kim , Krzysztof Kozlowski Cc: Marek Szyprowski , Tobias Jakobi , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180117170131.2677586-1-arnd@arndb.de> From: Tobias Jakobi Message-ID: <8b3c5b1a-c630-30d6-a261-2ee12d71fcc5@math.uni-bielefeld.de> Date: Wed, 17 Jan 2018 19:16:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.5.0 MIME-Version: 1.0 In-Reply-To: <20180117170131.2677586-1-arnd@arndb.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hey Arnd, looks good to me! Reviewed-by: Tobias Jakobi - Tobias Arnd Bergmann wrote: > 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); >