All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: [PATCH 3/3] drm/atomic: Try to preserve the crtc enabled state in drm_atomic_remove_fb.
Date: Tue, 21 Feb 2017 14:51:42 +0100	[thread overview]
Message-ID: <1487685102-31991-4-git-send-email-maarten.lankhorst@linux.intel.com> (raw)
In-Reply-To: <1487685102-31991-1-git-send-email-maarten.lankhorst@linux.intel.com>

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 <maarten.lankhorst@linux.intel.com>
---
 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);
 
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-02-21 13:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-21 13:51 [PATCH 0/3] drm/atomic: Make drm_framebuffer_remove atomic, again Maarten Lankhorst
     [not found] ` <1487685102-31991-1-git-send-email-maarten.lankhorst-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-02-21 13:51   ` [PATCH 1/3] drm/atomic: Make disable_all helper fully disable the crtc Maarten Lankhorst
2017-02-23 15:03     ` Sean Paul
2017-02-23 20:10       ` Maarten Lankhorst
2017-02-21 13:51 ` [PATCH 2/3] drm: Convert drm_framebuffer_remove to atomic, v4 Maarten Lankhorst
2017-02-23 15:09   ` Sean Paul
2017-02-28 12:03     ` Daniel Vetter
2017-02-21 13:51 ` Maarten Lankhorst [this message]
2017-02-23 15:24   ` [PATCH 3/3] drm/atomic: Try to preserve the crtc enabled state in drm_atomic_remove_fb Sean Paul
2017-02-27 12:01     ` Maarten Lankhorst
2017-02-21 15:23 ` ✗ Fi.CI.BAT: failure for drm/atomic: Make drm_framebuffer_remove atomic, again Patchwork
2017-02-22 11:48   ` Maarten Lankhorst

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1487685102-31991-4-git-send-email-maarten.lankhorst@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.