From patchwork Tue Feb 21 13:51:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 9584641 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 A3145602A7 for ; Tue, 21 Feb 2017 13:51:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DCE4288B4 for ; Tue, 21 Feb 2017 13:51:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82DAA288C3; Tue, 21 Feb 2017 13:51:57 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 4F49C288B4 for ; Tue, 21 Feb 2017 13:51:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1635A893CD; Tue, 21 Feb 2017 13:51:48 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mblankhorst.nl (mblankhorst.nl [141.105.120.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id B9433893C0; Tue, 21 Feb 2017 13:51:46 +0000 (UTC) From: Maarten Lankhorst To: dri-devel@lists.freedesktop.org Date: Tue, 21 Feb 2017 14:51:42 +0100 Message-Id: <1487685102-31991-4-git-send-email-maarten.lankhorst@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487685102-31991-1-git-send-email-maarten.lankhorst@linux.intel.com> References: <1487685102-31991-1-git-send-email-maarten.lankhorst@linux.intel.com> Cc: intel-gfx@lists.freedesktop.org Subject: [Intel-gfx] [PATCH 3/3] drm/atomic: Try to preserve the crtc enabled state in drm_atomic_remove_fb. 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-Virus-Scanned: ClamAV using ClamSMTP This introduces a slight behavioral change to rmfb. Instead of disabling a crtc when the primary plane is disabled, we try to preserve it. Apart from old versions of the vmwgfx xorg driver, there is nothing depending on rmfb disabling a crtc. Since vmwgfx is a legacy driver we can safely only disable the plane with atomic. In the conversion to atomic the driver will reject the config without primary plane. If this commit is rejected by the driver then we will still fall back to the old behavior and turn off the crtc. Signed-off-by: Maarten Lankhorst --- drivers/gpu/drm/drm_atomic.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 285e1c23e8c9..0d5b0065208e 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -2070,7 +2070,7 @@ int drm_atomic_remove_fb(struct drm_framebuffer *fb) struct drm_connector *conn; struct drm_connector_state *conn_state; int i, ret = 0; - unsigned plane_mask; + unsigned plane_mask, disable_crtcs = false; state = drm_atomic_state_alloc(dev); if (!state) @@ -2097,7 +2097,13 @@ int drm_atomic_remove_fb(struct drm_framebuffer *fb) goto unlock; } - if (plane_state->crtc->primary == plane) { + /* + * Some drivers do not support keeping crtc active with the + * primary plane disabled. If we fail to commit with -EINVAL + * then we will try to perform the same commit but with all + * crtc's disabled for primary planes as well. + */ + if (disable_crtcs && plane_state->crtc->primary == plane) { struct drm_crtc_state *crtc_state; crtc_state = drm_atomic_get_existing_crtc_state(state, plane_state->crtc); @@ -2122,6 +2128,7 @@ int drm_atomic_remove_fb(struct drm_framebuffer *fb) plane->old_fb = plane->fb; } + /* This list is only not empty when disable_crtcs is set. */ for_each_connector_in_state(state, conn, conn_state, i) { ret = drm_atomic_set_crtc_for_connector(conn_state, NULL); @@ -2143,6 +2150,17 @@ int drm_atomic_remove_fb(struct drm_framebuffer *fb) drm_atomic_state_put(state); + if (ret == -EINVAL && !disable_crtcs) { + disable_crtcs = true; + + state = drm_atomic_state_alloc(dev); + if (state) { + state->acquire_ctx = &ctx; + goto retry; + } + ret = -ENOMEM; + } + drm_modeset_drop_locks(&ctx); drm_modeset_acquire_fini(&ctx);