From patchwork Fri Mar 17 20:20:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9631547 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 D845D60245 for ; Fri, 17 Mar 2017 20:20:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC8CC285A1 for ; Fri, 17 Mar 2017 20:20:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1772285D4; Fri, 17 Mar 2017 20:20:40 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 73765285A1 for ; Fri, 17 Mar 2017 20:20:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 089296EDAC; Fri, 17 Mar 2017 20:20:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id B6B9E6EDA9; Fri, 17 Mar 2017 20:20:36 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id z133so4967481wmb.2; Fri, 17 Mar 2017 13:20:36 -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=mjtYepVbBMuFdhUg5EtJJ/3bAVtralikqDvDLv2NMsk=; b=CcIuw6vgyHfomBTiIi2CljB0kcy/GK4/xS3wvIpIWLnXXBsgUpiiNbpSyz4G8Brvax VZIyLaIM24GwEOR630LmVLV06ObkMq4upIUwwMT9ehjqeyr9VREVzpI1TJ6kdwDcDpax MRFU+LLDixFApHXvHsLPsG/+x8w+Bdfim0P1PRsk6l/XlfsyLjIm97gmNDw+8P5gBQ2U u04mih4+AP2q9ZhGdhw8Nybkn1suyKZ/4WzE+eKivtZaX9is2IVQtOBQdD0nokOySOgS syA8EPqI9c/6hNFCzlbfAbXKOvo1aPtE6NKrEFXpaju8WAfAAi1O1ys4DgfTCxwWSoPZ MJBQ== 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=mjtYepVbBMuFdhUg5EtJJ/3bAVtralikqDvDLv2NMsk=; b=ndejD1GJo/ZUCC85DCkjCImBdFtsJb645wLCl4VpWESSFhnPP8VSxFtykaeget2Wbb ZA+UMt1F5BLljPnec357rM7OY09wFi09DE8FZBqSGcnb6ZaEitkkH+eHlU2jkpuKWSxX 9H4tzT7JSzZK2rJPglv1t+B4Bx/EoNgHIgEqR0bauKb3qVGbrzpqcWudkTbi9vyFaNjs VD0bjoaX0Dy+o8JHQ5wYeCGz0DNGjWaiTTI9HO/5H2pj3hRpVqrFGUUn62dxF8l0rmpe dnZnXBk8CXsvukDsIAOlZtq9xk9MGNeAHtVbuyq0Y+AGk3ZAnnIqd0LBuSF0xz+Bw9Jx 8JVQ== X-Gm-Message-State: AFeK/H34u8r/G07X+llR6+t6ZBEcfOtXL0RvwaMQho0pCyUm1LtUrkpFVVpTF46fYuhJUw== X-Received: by 10.28.21.15 with SMTP id 15mr68207wmv.11.1489782035152; Fri, 17 Mar 2017 13:20:35 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id k139sm3829222wmg.11.2017.03.17.13.20.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Mar 2017 13:20:34 -0700 (PDT) From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 3/4] drm: Refactor vblank sequence number comparison Date: Fri, 17 Mar 2017 20:20:29 +0000 Message-Id: <20170317202030.24410-3-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170317202030.24410-1-chris@chris-wilson.co.uk> References: <20170317202030.24410-1-chris@chris-wilson.co.uk> MIME-Version: 1.0 Cc: Daniel Vetter , intel-gfx@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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Move the repeated (a - b) <= (1 << 23) to its own function. Signed-off-by: Chris Wilson Cc: Ville Syrjälä Cc: Daniel Vetter --- drivers/gpu/drm/drm_irq.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index a164cf51d093..253505da57bd 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -1492,6 +1492,11 @@ int drm_legacy_modeset_ctl(struct drm_device *dev, void *data, return 0; } +static inline bool vblank_passed(u32 seq, u32 ref) +{ + return (seq - ref) <= (1 << 23); +} + static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe, union drm_wait_vblank *vblwait, struct drm_file *file_priv) @@ -1542,7 +1547,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe, vblwait->request.sequence); e->event.sequence = vblwait->request.sequence; - if ((seq - vblwait->request.sequence) <= (1 << 23)) { + if (vblank_passed(seq, vblwait->request.sequence)) { drm_vblank_put(dev, pipe); send_vblank_event(dev, e, seq, &now); vblwait->reply.sequence = seq; @@ -1632,9 +1637,8 @@ int drm_wait_vblank(struct drm_device *dev, void *data, } if ((flags & _DRM_VBLANK_NEXTONMISS) && - (seq - vblwait->request.sequence) <= (1 << 23)) { + vblank_passed(seq, vblwait->request.sequence)) vblwait->request.sequence = seq + 1; - } if (flags & _DRM_VBLANK_EVENT) { /* must hold on to the vblank ref until the event fires @@ -1647,8 +1651,8 @@ int drm_wait_vblank(struct drm_device *dev, void *data, DRM_DEBUG("waiting on vblank count %u, crtc %u\n", vblwait->request.sequence, pipe); DRM_WAIT_ON(ret, vblank->queue, 3 * HZ, - (drm_vblank_count(dev, pipe) - - vblwait->request.sequence) <= (1 << 23) || + vblank_passed(drm_vblank_count(dev, pipe), + vblwait->request.sequence) || !READ_ONCE(vblank->enabled)); }