From patchwork Fri Mar 24 17:30:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9643427 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 C7A8060327 for ; Fri, 24 Mar 2017 17:31:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA3D226E51 for ; Fri, 24 Mar 2017 17:31:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF03026E69; Fri, 24 Mar 2017 17:31:06 +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=unavailable 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 6E96026E51 for ; Fri, 24 Mar 2017 17:31:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A55B76EC4C; Fri, 24 Mar 2017 17:31:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8D7EC6EC46; Fri, 24 Mar 2017 17:31:02 +0000 (UTC) Received: by mail-wr0-x242.google.com with SMTP id u108so1387522wrb.2; Fri, 24 Mar 2017 10:31:02 -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=6hZQrNK6hAoUMq6mMVevgKQoXlvAzWt8iI0dyN1Vl/M=; b=dcO32UcVr9mjVusKucfVjlW2vzD2diTxheF+/NYFiaRw3OsWvTWCdOod2jm7ZoBG4j YMM5tD0IQEFQcgBUCuFt6/usZj0hNfr4ahAaYnhHyDweooPrc2rJNthhA85kDLSeL39B nNymbN8Geuz/HMbzjJLVgXyTnGQTse52TcIcbHebF/cD521YKNQrQVQeohBsmQvJKDLa bKx/3bvZkVuHFJGrlXyVdkUNatGd3ES2YAUE+N7hiyxkuqdW9OmrOh67hx3UWUylPg3I 4e1jOYEqFVv51UOJfuqELKrfaa7vxVvJcz6czljxbw86Iar7W+ATK3TTnMd7HJM5Ul0+ 2hfw== 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=6hZQrNK6hAoUMq6mMVevgKQoXlvAzWt8iI0dyN1Vl/M=; b=Z7wj6nx60toNAFbU/wMMn4H23SVH+u7qwqNzdunLmDMLJb5ibj/LEVOC+L+/H16Uuc MRYTxBvC+3/kD3r143v9vFX9mrufd5/yOp7trXNCH+QtC02b0HjmWeCgbReI3pdUkKgu RbukaCBrk0lJk45X9lhBOJWJEadK4ojkK4RmWzabebxUPfQVY7udDueR2pP4b78TkLry FIg2splNEkxAOcZkxyWjvlZXcVIE8PyqtgF25zIJCS1u1yzWmMoVREY+S0IYyx/H6Nbx Zpz6pgSZzba+3DglIkneNoZeKZtHPQSHzetYXGxxRDn8r29zUwwGHq1dTsu1u6ITxNQb E4Gw== X-Gm-Message-State: AFeK/H2GhrzQn7HZuo4nKMLIIEk8wOjWyy4RArKljzDR6r+E4k1fuaGn/E/SOQf8mRHtYw== X-Received: by 10.223.153.228 with SMTP id y91mr8651544wrb.81.1490376661159; Fri, 24 Mar 2017 10:31:01 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id x133sm3220800wme.22.2017.03.24.10.30.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Mar 2017 10:31:00 -0700 (PDT) From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm: Make the decision to keep vblank irq enabled earlier Date: Fri, 24 Mar 2017 17:30:58 +0000 Message-Id: <20170324173058.23051-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <4098543f-16e1-ca44-cdf2-157bdb66b188@gmail.com> References: <4098543f-16e1-ca44-cdf2-157bdb66b188@gmail.com> MIME-Version: 1.0 Cc: =?UTF-8?q?Michel=20D=C3=A4nzer?= , Laurent Pinchart , Dave Airlie , 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 We want to provide the vblank irq shadow for pageflip events as well as vblank queries. Such events are completed within the vblank interrupt handler, and so the current check for disabling the irq will disable it from with the same interrupt as the last pageflip event. If we move the decision on whether to disable the irq (based on there no being no remaining vblank events, i.e. vblank->refcount == 0) to before we signal the events, we will only disable the irq on the interrupt after the last event was signaled. In the normal course of events, this will keep the vblank irq enabled for the entire flip sequence whereas before it would flip-flop around every interrupt. v2: Move the disable_fn() call outside of the vblank_event_lock. Signed-off-by: Chris Wilson Cc: Ville Syrjälä Cc: Daniel Vetter Cc: Michel Dänzer Cc: Laurent Pinchart Cc: Dave Airlie , Cc: Mario Kleiner Reviewed-by: Ville Syrjälä #v1 Reviewed-by: Mario Kleiner #v1 --- drivers/gpu/drm/drm_irq.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 5b77057e91ca..a511597580d8 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -1741,6 +1741,7 @@ bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe) { struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; unsigned long irqflags; + bool disable_irq; if (WARN_ON_ONCE(!dev->num_crtcs)) return false; @@ -1768,20 +1769,23 @@ bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe) spin_unlock(&dev->vblank_time_lock); wake_up(&vblank->queue); - drm_handle_vblank_events(dev, pipe); /* With instant-off, we defer disabling the interrupt until after - * we finish processing the following vblank. The disable has to - * be last (after drm_handle_vblank_events) so that the timestamp - * is always accurate. + * we finish processing the following vblank after all events have + * been signaled. The disable has to be last (after + * drm_handle_vblank_events) so that the timestamp is always accurate. */ - if (dev->vblank_disable_immediate && - drm_vblank_offdelay > 0 && - !atomic_read(&vblank->refcount)) - vblank_disable_fn((unsigned long)vblank); + disable_irq = (dev->vblank_disable_immediate && + drm_vblank_offdelay > 0 && + !atomic_read(&vblank->refcount)); + + drm_handle_vblank_events(dev, pipe); spin_unlock_irqrestore(&dev->event_lock, irqflags); + if (disable_irq) + vblank_disable_fn((unsigned long)vblank); + return true; } EXPORT_SYMBOL(drm_handle_vblank);