From patchwork Thu Jul 18 19:47:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Ravnborg X-Patchwork-Id: 11049535 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2411413AC for ; Thu, 18 Jul 2019 19:47:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10AD728179 for ; Thu, 18 Jul 2019 19:47:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 026D42883B; Thu, 18 Jul 2019 19:47:16 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 0B14028179 for ; Thu, 18 Jul 2019 19:47:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9135C6E462; Thu, 18 Jul 2019 19:47:14 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from asavdk3.altibox.net (asavdk3.altibox.net [109.247.116.14]) by gabe.freedesktop.org (Postfix) with ESMTPS id D7A8A6E462 for ; Thu, 18 Jul 2019 19:47:12 +0000 (UTC) Received: from ravnborg.org (unknown [158.248.194.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by asavdk3.altibox.net (Postfix) with ESMTPS id 4405220024 for ; Thu, 18 Jul 2019 21:47:11 +0200 (CEST) Date: Thu, 18 Jul 2019 21:47:09 +0200 From: Sam Ravnborg To: Intel Graphics Development Message-ID: <20190718194709.GA11103@ravnborg.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=dqr19Wo4 c=1 sm=1 tr=0 a=UWs3HLbX/2nnQ3s7vZ42gw==:117 a=UWs3HLbX/2nnQ3s7vZ42gw==:17 a=kj9zAlcOel0A:10 a=7gkXJVJtAAAA:8 a=QyXUC8HyAAAA:8 a=P-IC7800AAAA:8 a=YEINtQZRul9hlDdZYYIA:9 a=CjuIK1q_8ugA:10 a=E9Po1WZjFZOl8hwRPBS3:22 a=d3PnA9EDa4IxuAV0gXij:22 Subject: [Intel-gfx] [PATCH 1/1] drm/vblank: drop use of DRM_WAIT_ON() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From e6f70cb90e0c3c90d45017a8257353652b7e0dcc Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Thu, 30 May 2019 09:38:47 +0200 Subject: [PATCH] drm/vblank: drop use of DRM_WAIT_ON() DRM_WAIT_ON() is from the deprecated drm_os_linux header and the modern replacement is the wait_event_*. The return values differ, so a conversion is needed to keep the original interface towards userspace. Introduced a switch/case to make code obvious and to allow different debug prints depending on the result. Signed-off-by: Sam Ravnborg Reviewed-by: Sean Paul Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: David Airlie Cc: Daniel Vetter --- To verify if it works with the fix. (Added wat variable to handle the situation where we never wait) Sam drivers/gpu/drm/drm_vblank.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index 603ab105125d..4e83f1dfd446 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include "drm_internal.h" @@ -1576,7 +1575,7 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data, struct drm_crtc *crtc; struct drm_vblank_crtc *vblank; union drm_wait_vblank *vblwait = data; - int ret; + int ret, wait; u64 req_seq, seq; unsigned int pipe_index; unsigned int flags, pipe, high_pipe; @@ -1669,22 +1668,35 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data, return drm_queue_vblank_event(dev, pipe, req_seq, vblwait, file_priv); } + wait = 1; if (req_seq != seq) { DRM_DEBUG("waiting on vblank count %llu, crtc %u\n", req_seq, pipe); - DRM_WAIT_ON(ret, vblank->queue, 3 * HZ, - vblank_passed(drm_vblank_count(dev, pipe), - req_seq) || - !READ_ONCE(vblank->enabled)); + wait = wait_event_interruptible_timeout(vblank->queue, + vblank_passed(drm_vblank_count(dev, pipe), req_seq) || + !READ_ONCE(vblank->enabled), + msecs_to_jiffies(3000)); } - if (ret != -EINTR) { + switch (wait) { + case 0: + /* timeout */ + ret = -EBUSY; drm_wait_vblank_reply(dev, pipe, &vblwait->reply); - - DRM_DEBUG("crtc %d returning %u to client\n", + DRM_DEBUG("timeout waiting for vblank. crtc %d returning %u to client\n", pipe, vblwait->reply.sequence); - } else { + break; + case -ERESTARTSYS: + /* interrupted by signal */ + ret = -EINTR; DRM_DEBUG("crtc %d vblank wait interrupted by signal\n", pipe); + break; + default: + ret = 0; + drm_wait_vblank_reply(dev, pipe, &vblwait->reply); + DRM_DEBUG("crtc %d returning %u to client\n", + pipe, vblwait->reply.sequence); + break; } done: