From patchwork Mon Nov 27 11:17:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10076601 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 EBD5E6028E for ; Mon, 27 Nov 2017 11:17:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF5AD2895D for ; Mon, 27 Nov 2017 11:17:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C35EF28B7A; Mon, 27 Nov 2017 11:17:33 +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 616A62895D for ; Mon, 27 Nov 2017 11:17:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A77AD89A83; Mon, 27 Nov 2017 11:17:32 +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 11D5889A4A for ; Mon, 27 Nov 2017 11:17:30 +0000 (UTC) Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0MDpnS-1eLz7P00kQ-00H93p; Mon, 27 Nov 2017 12:17:29 +0100 From: Arnd Bergmann To: David Airlie , Arnd Bergmann Subject: [PATCH] drm/via: use monotonic time for VIA_WAIT_IRQ Date: Mon, 27 Nov 2017 12:17:03 +0100 Message-Id: <20171127111728.1710742-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:rziACJxj3vV12TQvsY/N8QzxxEg5S5VGJMGocbfpgut26MrMIWo uORxHSBQPk7weeUvELCSjpioBTB8KyzGEGvBpPvzZ6fZhb6ThZi7ojpfNQwKVZMM+LOfM8u V9+K54eFwxDrYOjo8mWK/99aHVsxv/Yo9X0Inx06bO7/WDcyAhMlaZBXD87laKeqfgw5DLf b7ese+6C8yfXJfQ/LFUeg== X-UI-Out-Filterresults: notjunk:1; V01:K0:QKiK3v0D+C4=:LmEfJp1oLgc55p/TWZmze6 JM+Sc0cyW0xhOlWDQsJOAKY8KNd0wao+W+D0Vfe4eMipWbvI5xwzEsR7losCZjUlTiIPMhdqX skzHqiZ51ZtqmvaP4vllM/omCX8G0HAH+RUvkCUWTlle22jtvWVsjRAJsExDLuMkgmPUw1cDl UO2U39fW7Ttfz6KbFCLRh6xAPFPMTj8Az/NoWZCrkRjxgLgaju5QTJvL/BxHYvqQJRatSxvmE gi66dUzmwJMeo4GBRtDKJvecqffn2BplbyZoTowMLuZmYu5WR2VXND01NGlRbIGnRGKye0Dqw iKiv9mz1lFey9lkZknYushCAqDeJODWPQUNCsBcWVz1nXojW/O5MwmrRU9DRHoEEs18i0/8WV 39aQe+Eq3lLmCIUyqnjYVWcMp+wDiqaR3rZFjDRJ4nX/gs2aRch5gqCSywgJ8677I9aMuE/EU 7d9zdHvP7rwhPnr3gzMNAvaWC4k0+kMz9h9jOUrKOsoaq025VGP2HdG8A3YU4JSO+yX1IiE4A xKCz4z5+FLGQWj7RX1+gYgw7Rfup2GPpGRZvXxI4eKpstIv41mAKq3B3JRgNvC3dyUaVxqaAZ UJ3BPCfjG+d2Lnr5E23jHy7M8jt1USzoAyDkIaXL2jvgQ77s8lWafB0amSgDCFaSAMh+oWL+b Snri+HMxQo8SXtYV87I9lh1ZYHz8gwYAtVzC7sA205uzhzAVRy9lvzBLrXdzP30nfIRlJyA+d oLmtlC7lAFNnm3UhreNeSThIk0bN0eQ1aq8yoQ== Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org 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 normal DRM vblank interrupt events started using monotonic times in commit c61eef726a78 ("drm: add support for monotonic vblank timestamps"), which is useful for a number of reasons, including the possible y2038 overflow. The VIA_WAIT_IRQ ioctl uses the same drm_wait_vblank_reply as DRM_IOCTL_WAIT_VBLANK, but still uses wall-clock time. This converts it to using monotonic time as well, which is more consistent, and avoids problems with the y2038 overflow as well as synchronization issues when the real time skips. I could not find the matching user space that calls the VIA_WAIT_IRQ ioctl to verify that this is safe, but it very likely is. Please either test or review the user space side before applying this. Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/via/via_irq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c index 24e71578af4d..c96830ccc0ec 100644 --- a/drivers/gpu/drm/via/via_irq.c +++ b/drivers/gpu/drm/via/via_irq.c @@ -343,7 +343,7 @@ void via_driver_irq_uninstall(struct drm_device *dev) int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_via_irqwait_t *irqwait = data; - struct timeval now; + struct timespec64 now; int ret = 0; drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; drm_via_irq_t *cur_irq = dev_priv->via_irqs; @@ -377,9 +377,9 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv) ret = via_driver_irq_wait(dev, irqwait->request.irq, force_sequence, &irqwait->request.sequence); - do_gettimeofday(&now); + ktime_get_ts64(&now); irqwait->reply.tval_sec = now.tv_sec; - irqwait->reply.tval_usec = now.tv_usec; + irqwait->reply.tval_usec = now.tv_nsec / NSEC_PER_USEC; return ret; }