From patchwork Tue Jun 30 13:53:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 6696161 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7F9CAC05AD for ; Tue, 30 Jun 2015 13:54:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7AEAC20457 for ; Tue, 30 Jun 2015 13:54:12 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 57FBC20617 for ; Tue, 30 Jun 2015 13:54:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A0D76E715; Tue, 30 Jun 2015 06:54:10 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qg0-f45.google.com (mail-qg0-f45.google.com [209.85.192.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id B261C6E6FD for ; Tue, 30 Jun 2015 06:54:09 -0700 (PDT) Received: by qgem68 with SMTP id m68so4059342qge.0 for ; Tue, 30 Jun 2015 06:54:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8vAlsJOyXxeYdgrx4iUPYgGspdUB7QQkpxGI7O+6uRc=; b=GO4VnjXun6Vza1hMmLrLJvjoRD9kb07m97Mqs89z8xurhkV14tNrg737nD77nLvHQl yrAvwr7MRwwlkPOZIHYL35kkICuVFfkMzNIOa1YBtt5IKapaFKTOkOFg9nHDE3JWzMSH 1v2VguH33Lf6A9KBas4R9zn5g0G0rqFK+qLzbf8AUzU3XZEckLUt39qRT5+P+bjMoL7Z gGl++IptEneyqg8dB6OqrkyfTC0I2wtAEehW+wAvdNf6yJO8kj0WvccwTEtaAqYZiO83 v0C5K2Bqjb9MfcWDi/+kA7jWPd3YRrq3w8+CGvjjpSDrr1AN6yhlbYGJaiE1jUVBtLUY IxPg== X-Received: by 10.140.104.147 with SMTP id a19mr26878077qgf.71.1435672448891; Tue, 30 Jun 2015 06:54:08 -0700 (PDT) Received: from localhost.localdomain (r130-pw-tresbarras.ibys.com.br. [189.76.1.243]) by mx.google.com with ESMTPSA id e10sm4651585qka.40.2015.06.30.06.54.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jun 2015 06:54:08 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Tue, 30 Jun 2015 10:53:09 -0300 Message-Id: <1435672392-7329-6-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435672392-7329-1-git-send-email-przanoni@gmail.com> References: <1435672392-7329-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 5/8] drm/i915: simplify FBC start/stop at invalidate/flush X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Paulo Zanoni The problem with calling intel_fbc_update() at flush is that it fully rechecks and recomputes the FBC state, and that includes reallocating the CFB, which requires a struct_mutex lock that we don't always have. The lack of struct_mutex lock can be considered a regression from: commit dbef0f15b5c83231dacb214dbf9a6dba063ca21c Author: Paulo Zanoni Date: Fri Feb 13 17:23:46 2015 -0200 drm/i915: add frontbuffer tracking to FBC So introduce intel_fbc_stop() that doesn't unset fbc.crtc, then call stop/enable at invalidate/flush. Notice that invalidate/flush is only called by the frontbuffer tracking infrastrucutre, so it's safe to not do a full intel_fbc_update() here. Signed-off-by: Paulo Zanoni --- drivers/gpu/drm/i915/intel_fbc.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c index 316feb1..0a66814 100644 --- a/drivers/gpu/drm/i915/intel_fbc.c +++ b/drivers/gpu/drm/i915/intel_fbc.c @@ -422,7 +422,7 @@ static void intel_fbc_enable(struct drm_crtc *crtc) schedule_delayed_work(&work->work, msecs_to_jiffies(50)); } -static void __intel_fbc_disable(struct drm_device *dev) +static void intel_fbc_stop(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; @@ -434,6 +434,13 @@ static void __intel_fbc_disable(struct drm_device *dev) return; dev_priv->display.disable_fbc(dev); +} + +static void __intel_fbc_disable(struct drm_device *dev) +{ + struct drm_i915_private *dev_priv = dev->dev_private; + + intel_fbc_stop(dev); dev_priv->fbc.crtc = NULL; } @@ -753,7 +760,7 @@ void intel_fbc_invalidate(struct drm_i915_private *dev_priv, dev_priv->fbc.busy_bits |= (fbc_bits & frontbuffer_bits); if (dev_priv->fbc.busy_bits) - __intel_fbc_disable(dev); + intel_fbc_stop(dev); mutex_unlock(&dev_priv->fbc.lock); } @@ -770,8 +777,11 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv, dev_priv->fbc.busy_bits &= ~frontbuffer_bits; - if (!dev_priv->fbc.busy_bits) - __intel_fbc_update(dev); + if (!dev_priv->fbc.busy_bits && dev_priv->fbc.crtc) { + if (dev_priv->fbc.enabled) + intel_fbc_stop(dev); + intel_fbc_enable(&dev_priv->fbc.crtc->base); + } out: mutex_unlock(&dev_priv->fbc.lock);