From patchwork Tue Dec 23 12:35:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 5533101 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1C017BEEBA for ; Tue, 23 Dec 2014 12:36:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4F807201BC for ; Tue, 23 Dec 2014 12:36:44 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 504AB20165 for ; Tue, 23 Dec 2014 12:36:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BC59D6E458; Tue, 23 Dec 2014 04:36:42 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by gabe.freedesktop.org (Postfix) with ESMTP id C7BE66E445 for ; Tue, 23 Dec 2014 04:36:40 -0800 (PST) Received: by mail-vc0-f170.google.com with SMTP id hy4so2293377vcb.29 for ; Tue, 23 Dec 2014 04:36:40 -0800 (PST) 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=/jCiv4ET4SQypCaUxNB+eGeUUWf0597USHbdYU4S7wA=; b=FsEfQrJyvqZXi44ppStfFw6dZt/CnarqmF0mG2EOPB7vdGL/t/sX6Vh7e6Frj/Fqs/ IM0VR1QTOI6zxbFX3oi6kjbBn/N/I2IDybk4b/1ZpDQbrcpqmhlDi528tobngYRaNe4M rZFgsKWwygpBDpP7rTuqaTocTGpUdsvnqPyR6ZdgnoTIPWX4OOi4fFl2Ct0cZIgPGF6g 8N98e6JsbXSJYOEBRpXdUFl0g1FGUrLOV7Yrc9tL+/HZa+gSnUg5RIODudEsIBitDw1Z +icAp9DCLyDYDryB7AuCh6iWWzy5Tq9k4ujABPe05wBC4FYSDF0L+cerTj/LD5jPHDZO ra4Q== X-Received: by 10.220.238.12 with SMTP id kq12mr10075319vcb.62.1419338200340; Tue, 23 Dec 2014 04:36:40 -0800 (PST) Received: from localhost.localdomain ([177.92.19.202]) by mx.google.com with ESMTPSA id at12sm4915045vdc.15.2014.12.23.04.36.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Dec 2014 04:36:39 -0800 (PST) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Tue, 23 Dec 2014 10:35:40 -0200 Message-Id: <1419338145-1912-5-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1419338145-1912-1-git-send-email-przanoni@gmail.com> References: <1419338145-1912-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 4/9] drm/i915: don't free the CFB while FBC is enabled 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.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 Because that is probably not very a good idea: if we used the stolen memory for more things, there could be a risk that someone would "allocate" the memory that the HW is still using as the CFB while FBC was still enabled. Signed-off-by: Paulo Zanoni --- drivers/gpu/drm/i915/i915_gem_stolen.c | 3 +++ drivers/gpu/drm/i915/intel_fbc.c | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c index d02c102..f84c5f3 100644 --- a/drivers/gpu/drm/i915/i915_gem_stolen.c +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c @@ -198,6 +198,8 @@ static int i915_setup_compression(struct drm_device *dev, int size, int fb_cpp) struct drm_mm_node *uninitialized_var(compressed_llb); int ret; + WARN_ON(dev_priv->fbc.enabled); + ret = find_compression_threshold(dev, &dev_priv->fbc.compressed_fb, size, fb_cpp); if (!ret) @@ -268,6 +270,7 @@ void i915_gem_stolen_cleanup_compression(struct drm_device *dev) if (dev_priv->fbc.compressed_fb.allocated == 0) return; + WARN_ON(dev_priv->fbc.enabled); drm_mm_remove_node(&dev_priv->fbc.compressed_fb); if (dev_priv->fbc.compressed_llb) { diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c index 1b10b06..83d3c8a 100644 --- a/drivers/gpu/drm/i915/intel_fbc.c +++ b/drivers/gpu/drm/i915/intel_fbc.c @@ -593,13 +593,6 @@ void intel_fbc_update(struct drm_device *dev) if (in_dbg_master()) goto out_disable; - if (i915_gem_stolen_setup_compression(dev, obj->base.size, - drm_format_plane_cpp(fb->pixel_format, 0))) { - if (set_no_fbc_reason(dev_priv, FBC_STOLEN_TOO_SMALL)) - DRM_DEBUG_KMS("framebuffer too large, disabling compression\n"); - goto out_disable; - } - /* If the scanout has not changed, don't modify the FBC settings. * Note that we make the fundamental assumption that the fb->obj * cannot be unpinned (and have its GTT offset and fence revoked) @@ -638,6 +631,13 @@ void intel_fbc_update(struct drm_device *dev) intel_fbc_disable(dev); } + if (i915_gem_stolen_setup_compression(dev, obj->base.size, + drm_format_plane_cpp(fb->pixel_format, 0))) { + if (set_no_fbc_reason(dev_priv, FBC_STOLEN_TOO_SMALL)) + DRM_DEBUG_KMS("framebuffer too large, disabling compression\n"); + return; + } + intel_fbc_enable(crtc); dev_priv->fbc.no_fbc_reason = FBC_OK; return;