From patchwork Thu Jul 18 16:15:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Ravnborg X-Patchwork-Id: 11049329 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 B74CD912 for ; Thu, 18 Jul 2019 16:18:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A49212874B for ; Thu, 18 Jul 2019 16:18:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 987C528802; Thu, 18 Jul 2019 16:18:05 +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,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 329832874B for ; Thu, 18 Jul 2019 16:18:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=m0yraZTezmG2dM5QoJAgqwtWbtIGZxqV2CS82pqQPPQ=; b=ZbUY0tc7qfzWv0 uJTsZQXPyrynr2PdxEbO8dP+xpwFYDRg5KTSmaWfWTGNS73AiwiCEuCpdXC2MJjUYG87Eqz80mqET LmaRBozeU1okH5q9sc0ZY3ykmWIRqwRAA3I+KaUOPO7vAIvjXvpu8ljMUQ+/4ZTrq6qPThSTtVOf7 PWpXpjjqPU82XssSbguM2IgSmFPPc4je4z+0haZ5uUbkHgtmPg4NJz8k3Wh5vhRZEzxDICnPTS8/u 2TEi3SXdzVu13wlJ57O1JyNf0F4FP/kNqcp6eV5ecF92cdy1fyeQdoBRgnqeB8npOTSGRw3wRmtiH Ig+qXwwXCHPaoWlVOmEA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1ho96a-0002MK-Jw; Thu, 18 Jul 2019 16:18:04 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1ho949-0007sY-Ut; Thu, 18 Jul 2019 16:15:35 +0000 Received: by mail-lj1-x243.google.com with SMTP id v18so27900877ljh.6; Thu, 18 Jul 2019 09:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vfJth78zrsCE8EvAkb2q7xxIdGu3poPk3dyoAqmz7bA=; b=BbtCb9g2DsNiEp4NQaoJ4QYlf9TOBMn5FNfXAILkgRxVvjMv4oYQ2QWQur2QpY1oDs tY+hq6tQpdn6sv4GaAaRN3zqoKMtOJxKTS+CE/FeurecYR2py7DmD+wOYqDqFPliavRD kUvnCwNnxdpmg77SNaygFlJnpzjhLEFeu3r3pjJqPBA1qYv13+DJUC4oqyBIegVvlLUf yV55m8LLBBHpOjCBjccG83p4/fiVAPoDBnjNwfJNh1ay525CqTZIoid4MD9BRXItWgVc N7jdcGxdFSDusx5NEMh0a+wZcDux71kNRXlqKP3VfMBmJJZlGukoBFODa+OKNFpsR1xe 1F0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=vfJth78zrsCE8EvAkb2q7xxIdGu3poPk3dyoAqmz7bA=; b=LqbK/+jZVxnm50TMxZKpqmoBc06FIUJekbIkibPN24RYwGYGQSRp36XhEvV7CFkHXo yBvkoU+PG1eH2NzcQ1wTZPFuqDvfDM+qgDjHoF6LJYIl4s2d6yqcSgEUvrZwH2uOkNOL b32MPYEpzrp+YZLfc/Mt2W0sXrzK/5SJrT9RWAahQGRsTP8lDj5jOf5prgHNRsIWwIRl +d7mR2OeHc+Czs3Sg/y4qHEBdIHZB2vyFkhWdZok/LIA+6ffNvOUVC6k7piiJw3YWkqn B6CL0H22Whf2wmbJlw/K1eaXMVakqTBw8zV7UqcRDJ9WThZ0RQA0uJ1QlQEheItwzBJj 0DCw== X-Gm-Message-State: APjAAAUe+p/ZN9d/MQiSFFKowg4XgTfSIW6hF6CSHeJZ5zdrRV9SIXeL MzRwTjEc4Dpccdu+1pH1fYA= X-Google-Smtp-Source: APXvYqz+lvIEFfsf44rKsdxmLLQVJPn5lk9Rv8gUung+m8ggZXDMg+iNeOqEP6Hx4DqN5fgQu97mtQ== X-Received: by 2002:a2e:3013:: with SMTP id w19mr24846595ljw.73.1563466532065; Thu, 18 Jul 2019 09:15:32 -0700 (PDT) Received: from saturn.lan (18.158-248-194.customer.lyse.net. [158.248.194.18]) by smtp.gmail.com with ESMTPSA id d21sm4057995lfc.73.2019.07.18.09.15.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 18 Jul 2019 09:15:31 -0700 (PDT) From: Sam Ravnborg To: dri-devel@lists.freedesktop.org, Intel Graphics Development Subject: [PATCH v1 05/11] drm/vblank: drop use of DRM_WAIT_ON() Date: Thu, 18 Jul 2019 18:15:01 +0200 Message-Id: <20190718161507.2047-6-sam@ravnborg.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190718161507.2047-1-sam@ravnborg.org> References: <20190718161507.2047-1-sam@ravnborg.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190718_091534_009385_AF96F885 X-CRM114-Status: GOOD ( 13.09 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , Liviu Dudau , Lionel Landwerlin , Chris Wilson , Eric Anholt , Sam Ravnborg , Rob Herring , Maxime Ripard , CK Hu , Thierry Reding , Daniel Vetter , Chunming Zhou , Jani Nikula , Maarten Lankhorst , linux-mediatek@lists.infradead.org, Stefan Agner , Matthias Brugger , Sean Paul , linux-arm-kernel@lists.infradead.org, Boris Brezillon , Thomas Zimmermann , Rob Clark , =?utf-8?q?Noralf_Tr=C3=B8nnes?= , Philipp Zabel , =?utf-8?q?Christian_K=C3=B6nig?= Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Reviewed-by: Sean Paul --- drivers/gpu/drm/drm_vblank.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index 603ab105125d..8e9ac187500e 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" @@ -1672,19 +1671,31 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data, 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)); + ret = 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 (ret) { + 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: