From patchwork Wed Oct 11 15:20:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 115567 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp879182qgn; Wed, 11 Oct 2017 08:22:16 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAXPSkijM0uUNHjdc4ybFKsVoO+wiW7y9SjRlk4ceC++0Zb2/N3vNPpF+cCjcZelF0oqfP9 X-Received: by 10.98.111.67 with SMTP id k64mr17335456pfc.304.1507735336520; Wed, 11 Oct 2017 08:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507735336; cv=none; d=google.com; s=arc-20160816; b=tmuSO3SPz3cFHv6EakvnGpe4Uo79ev9GIJrZ9bCOS4VYjKnRtaNqk+jfcmwXqT7fDo j2Y74+i1YPYuBNY9MiLR7JPeuEmW42nMslgurbtIj43rfe3T3olA9JHPZds2XGUsI0cl xU14Fq1AQp56A91DdX4eIyhxbt7TVEeaIc9kF8Xh5b49jGlB77YaQdRytlQzh8QaODjf ZqfFYgS7daseW0xNgvQ3G2LfrNibO1SoEoE/CNKaUE/6hp+8k+ZGBK5my3rUV/IGi4og YcUBkxlP8I9ejuH8tXOpbF79AW+GHzE3HYh6DKMwKlSkEU45y3jM5Rm2CDNQZxFxFy3t BiSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=JABxywf0wZjENuxph7+lts6MQeXbpiOB2CE+18f3CvM=; b=DTG4GAqo5No3NnRd/y6qCX8YDJqZfxKYtvHtdi/ZiTvfSAm6IGrGSQ12+sC7bhhtXE YOOmx9ije0dBZscE9A6ydhwQ186QODh/OCCKaekJ7YclZfSgm8zne5AKDP6WUckE18S8 +TxgXtU+Vl/qxP+BFaWEHb5O/DIoLQefysLGSEk5VSU/pJxYpKjEWRISktijouGInNKw iPmolAkj5gjud7O1sb/T7jjfU89Jmtt6GPjZgx5/sZgP9kjHQeM74qEYxFJkXQbBD5lC Iw7MYkb1XCITj9U0hB/jc1CXe2tJ8qKb8abU/ISPvkcRAs6fBsXFBDv8Xaoleb/5ofiM YnRQ== 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 e62si6206504pfa.483.2017.10.11.08.22.15; Wed, 11 Oct 2017 08:22:16 -0700 (PDT) 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 S1752267AbdJKPWO (ORCPT + 27 others); Wed, 11 Oct 2017 11:22:14 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:56890 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751350AbdJKPWM (ORCPT ); Wed, 11 Oct 2017 11:22:12 -0400 Received: from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.129]) with ESMTPA (Nemesis) id 0LgL5M-1dWUFz3LYy-00nhZz; Wed, 11 Oct 2017 17:21:55 +0200 From: Arnd Bergmann To: Daniel Vetter , Daniel Vetter , Jani Nikula , Sean Paul , David Airlie Cc: Arnd Bergmann , Dave Airlie , Chris Wilson , Alex Deucher , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] drm: vblank: remove drm_timestamp_monotonic parameter Date: Wed, 11 Oct 2017 17:20:13 +0200 Message-Id: <20171011152059.2394516-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171011152059.2394516-1-arnd@arndb.de> References: <20171011152059.2394516-1-arnd@arndb.de> X-Provags-ID: V03:K0:+iSiwYr4yjMALO97MSehAUeg6O03hD8h74QYvWT18Nzqap+aA0c 59gcvenpIjoZtupQDFdBhmxyP00yfYB5VfBEP5RiSC6VTCkAAKE6X8DXT+7ZUWD4CwMyiPl Togp+3vhX5GU7tvBmWpx1IUPz2rcrUf4t9A8vDHbeQiEtKp7dxPRh8H5O/o9TLHiTbJQ7tz WhKvSqkWfvaxRciQKxVMA== X-UI-Out-Filterresults: notjunk:1; V01:K0:lCqpw6QlOQg=:XPZrUDPwI0SIVC5RIEwV6n rxM3jikc/1JiR0i7sdvVM9v1NU397xEiS2XGzYMlHhelMlyAT5PIOamwIKf0CbpmO3QJSdqyd QQU+Ln4S3L2/dLfoVJjrA6kndWIPeDG5Bo2+Ck0CsQMNaCGMOFipjomERKDaWcGicSg4LG/nv cIKak+Iz+R4CofaCnwfTn9+UQfy6WlplQba/9xu6daX7+P3btkzMudM72lGn3QMjFLEW6SXH0 FQ+GmUKM5kdyt9r8pRngvI4eTTFJHQt4ahRb2TYojN0wiNlbtNODRvyOdUnl3SoHgJj7DVa8i imHKJQZA/Py5a6vL9fYqmc7gQ1yG6WJ9Rzqp0tvWyXYHHM0zbSEv8KxG+ghI/CtKWkqz/yWAH dsyUZYRFy0EplicMnwrZVFeIyYaqb4aZ00yTd5g2F25Le7pOomePvHuVyEJKRgK7OSICDzA5p FomU/miquHiHp5IARgyIEzUA0dXqnUl0vNLi4kvOw6WA/WGg94cndVRHU+gUl64g+SPeW4g3Z xenmzIlI2kVjd/dtEdYt4UfUOzeZ5a/L0VYBT7AcsEQL1rnabz17w/3YdhwJv6GlpKJHjWgcu MBhjkSa4HfwOfGf1rGFkvL1C7JszK2AG945W5ART0y9OGGJ/KJt9zl5wi05SV5xgtafV9ddnv 8elqr2suQyxxmiU+U6yjqcmEp3KAhWwW796aZlnFe6RrOiE5p4+5Ps9UAsbf1hKtGMAUw2TRX WBcvd7qolRi8kmKDjYAEhhMMoSHk/68mz4MM5w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a risk of overflowing vblank timestamps in 2038 or 2106 if someone sets the drm_timestamp_monotonic module parameter to zero. I found no indication of anyone ever setting the parameter, or complaining about the default being wrong, after it was introduced as a way to handle backwards-compatibility with linux prior to c61eef726a78 ("drm: add support for monotonic vblank timestamps"), so it's probably safer to just remove the parameter completely and only allowing the default behavior. Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/drm_internal.h | 1 - drivers/gpu/drm/drm_ioctl.c | 2 +- drivers/gpu/drm/drm_vblank.c | 29 ++++++----------------------- 3 files changed, 7 insertions(+), 25 deletions(-) -- 2.9.0 diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index fbc3f308fa19..edd921adcf33 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -55,7 +55,6 @@ int drm_clients_info(struct seq_file *m, void* data); int drm_gem_name_info(struct seq_file *m, void *data); /* drm_vblank.c */ -extern unsigned int drm_timestamp_monotonic; void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe); void drm_vblank_cleanup(struct drm_device *dev); diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index a9ae6dd2d593..a78f03155466 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -235,7 +235,7 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_ /* Only some caps make sense with UMS/render-only drivers. */ switch (req->capability) { case DRM_CAP_TIMESTAMP_MONOTONIC: - req->value = drm_timestamp_monotonic; + req->value = 1; return 0; case DRM_CAP_PRIME: req->value |= dev->driver->prime_fd_to_handle ? DRM_PRIME_CAP_IMPORT : 0; diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index c605c3ad6b6e..810a93fc558b 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -82,20 +82,12 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe, static unsigned int drm_timestamp_precision = 20; /* Default to 20 usecs. */ -/* - * Default to use monotonic timestamps for wait-for-vblank and page-flip - * complete events. - */ -unsigned int drm_timestamp_monotonic = 1; - static int drm_vblank_offdelay = 5000; /* Default to 5000 msecs. */ module_param_named(vblankoffdelay, drm_vblank_offdelay, int, 0600); module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 0600); -module_param_named(timestamp_monotonic, drm_timestamp_monotonic, int, 0600); MODULE_PARM_DESC(vblankoffdelay, "Delay until vblank irq auto-disable [msecs] (0: never disable, <0: disable immediately)"); MODULE_PARM_DESC(timestamp_precision_usec, "Max. error on timestamps [usecs]"); -MODULE_PARM_DESC(timestamp_monotonic, "Use monotonic timestamps"); static void store_vblank(struct drm_device *dev, unsigned int pipe, u32 vblank_count_inc, @@ -672,9 +664,6 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, delta_ns = div_s64(1000000LL * (vpos * mode->crtc_htotal + hpos), mode->crtc_clock); - if (!drm_timestamp_monotonic) - etime = ktime_mono_to_real(etime); - /* save this only for debugging purposes */ ts_etime = ktime_to_timespec64(etime); ts_vblank_time = ktime_to_timespec64(*vblank_time); @@ -694,11 +683,6 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, } EXPORT_SYMBOL(drm_calc_vbltimestamp_from_scanoutpos); -static ktime_t get_drm_timestamp(void) -{ - return drm_timestamp_monotonic ? ktime_get() : ktime_get_real(); -} - /** * drm_get_last_vbltimestamp - retrieve raw timestamp for the most recent * vblank interval @@ -738,7 +722,7 @@ drm_get_last_vbltimestamp(struct drm_device *dev, unsigned int pipe, * Return current monotonic/gettimeofday timestamp as best estimate. */ if (!ret) - *tvblank = get_drm_timestamp(); + *tvblank = ktime_get(); return ret; } @@ -811,8 +795,8 @@ static void send_vblank_event(struct drm_device *dev, e->event.sequence = seq; /* * e->event is a user space structure, with hardcoded unsigned - * 32-bit seconds/microseconds. This will overflow in 2106 for - * drm_timestamp_monotonic==0, but not with drm_timestamp_monotonic==1 + * 32-bit seconds/microseconds. This is safe as we always use + * monotonic timestamps since linux-4.15 */ e->event.tv_sec = tv.tv_sec; e->event.tv_usec = tv.tv_nsec / 1000; @@ -899,7 +883,7 @@ void drm_crtc_send_vblank_event(struct drm_crtc *crtc, } else { seq = 0; - now = get_drm_timestamp(); + now = ktime_get(); } e->pipe = pipe; e->event.crtc_id = crtc->base.id; @@ -1408,9 +1392,8 @@ static void drm_wait_vblank_reply(struct drm_device *dev, unsigned int pipe, /* * drm_wait_vblank_reply is a UAPI structure that uses 'long' - * to store the seconds. This will overflow in y2038 on 32-bit - * architectures with drm_timestamp_monotonic==0, but not with - * drm_timestamp_monotonic==1 (the default). + * to store the seconds. This is safe as we always use monotonic + * timestamps since linux-4.15. */ reply->sequence = drm_vblank_count_and_time(dev, pipe, &now); ts = ktime_to_timespec64(now);