From patchwork Thu Mar 23 07:51:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9640495 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 21653602CA for ; Thu, 23 Mar 2017 07:51:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BC3D28459 for ; Thu, 23 Mar 2017 07:51:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 006A9284DC; Thu, 23 Mar 2017 07:51:15 +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 B599F28459 for ; Thu, 23 Mar 2017 07:51:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5A2396E25E; Thu, 23 Mar 2017 07:51:12 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 220836E25E; Thu, 23 Mar 2017 07:51:11 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id 20so1863142wrx.0; Thu, 23 Mar 2017 00:51:11 -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=KSKBp9YtpJ7DNpeT9tO9jkPDj0B5oHpsDqtDv3t6fgE=; b=MBCiSFperWbKM5kAPU2uF+OWyrEgCTwJRB5pk45W9eIkqJyYgPl537ZWhiDrEk+yVB 8K568WlpElTXEf5rEn8sfqw2cIXq6ffEyFMTig8UkoDBcez1y3Gjr8K4EmkY1pQ+rRXA 5anb2lnMUY/Yf4PwuldL/3+Nf4q4lm4fOIh6TK0ZOCqX3LdtAKvsHZSSOjoPOf82M8z+ IVENlXCMmRY6VAySmWH/wppX6sI9RAYbYqjZZDCaHIjwQdFRIu13G21kDYqPjWvD6y5U J8lbUBmFInDSf0hkAxrCUsfPR/T4o+rCGLF3HdDFjFbIypS44MDU8RPqhK2Erki8Anj5 EoEQ== 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=KSKBp9YtpJ7DNpeT9tO9jkPDj0B5oHpsDqtDv3t6fgE=; b=IS/rz9il2hmZL80/zIbRg7t9irhnp5qGLg0RsMiSM84kL+s6fPj+UwuTZprObKeBpM 3j9ZhVC70SfaO4+hIQti4hJnEUwLV5yYkY2yjsH9tkxJkRBABczpSJ8/NwsEFLV1j62I RBYWKJisa9Xua3bhg5E8M9nSq02QWlDvv/LgpBeIUQkqrDqEnFQ7skbdGV80+EhnZUf0 AdS5qpAeRs9NSmktV1EzoGZjod3hUjIWLCrW7tdkvliJYMDXzZ72mxAFtrOdc4VBAQkB NRD33SP/T4zUtoX+cDX2XkChGVd5MKU5Lz4PGK/S9pOpC9v6b0yPER3CZ997sVl2JNZU I43Q== X-Gm-Message-State: AFeK/H0JN6ngMkw3vt3mWdcv4/b+SV1I1cUr20wIA90cPpcJwTeYa+T2G+uf1aZmiwR+7w== X-Received: by 10.223.146.164 with SMTP id 33mr1058690wrn.135.1490255469772; Thu, 23 Mar 2017 00:51:09 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id v14sm3259681wmv.24.2017.03.23.00.51.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Mar 2017 00:51:09 -0700 (PDT) From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm: Make the decision to keep vblank irq enabled earlier Date: Thu, 23 Mar 2017 07:51:06 +0000 Message-Id: <20170323075106.7494-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170322200200.GM31595@intel.com> References: <20170322200200.GM31595@intel.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. 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ä Reviewed-by: Mario Kleiner --- drivers/gpu/drm/drm_irq.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 5b77057e91ca..1d6bcee3708f 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,16 +1769,19 @@ 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)) + disable_irq = (dev->vblank_disable_immediate && + drm_vblank_offdelay > 0 && + !atomic_read(&vblank->refcount)); + + drm_handle_vblank_events(dev, pipe); + + if (disable_irq) vblank_disable_fn((unsigned long)vblank); spin_unlock_irqrestore(&dev->event_lock, irqflags);