All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: jfalempe@redhat.com, daniel@ffwll.ch, airlied@gmail.com,
	ville.syrjala@linux.intel.com, daniel@fooishbar.org,
	javierm@redhat.com, mripard@kernel.org,
	maarten.lankhorst@linux.intel.com
Cc: David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org,
	Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH] drm/atomic-helper: Don't allocated plane state in CRTC check
Date: Thu, 29 Sep 2022 16:07:14 +0200	[thread overview]
Message-ID: <20220929140714.14794-1-tzimmermann@suse.de> (raw)

In drm_atomic_helper_check_crtc_state(), do not add a new plane state
to the global state if it does not exist already. Adding a new plane
state will results in overhead for the plane during the atomic-commit
step.

For the test in drm_atomic_helper_check_crtc_state() to succeed, it is
important that the CRTC has an enabled primary plane after the commit.
This can be a newly enabled plane or an already enabled plane. So if a
plane is not part of the commit, use the plane's existing state. The new
helper drm_atomic_get_next_plane_state() returns the correct instance.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: d6b9af1097fe ("drm/atomic-helper: Add helper drm_atomic_helper_check_crtc_state()")
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Jocelyn Falempe <jfalempe@redhat.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
---
 drivers/gpu/drm/drm_atomic_helper.c |  4 +---
 include/drm/drm_atomic.h            | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 98cc3137c062..463d4f3fa443 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -960,9 +960,7 @@ int drm_atomic_helper_check_crtc_state(struct drm_crtc_state *crtc_state,
 
 			if (plane->type != DRM_PLANE_TYPE_PRIMARY)
 				continue;
-			plane_state = drm_atomic_get_plane_state(state, plane);
-			if (IS_ERR(plane_state))
-				return PTR_ERR(plane_state);
+			plane_state = drm_atomic_get_next_plane_state(state, plane);
 			if (plane_state->fb && plane_state->crtc) {
 				has_primary_plane = true;
 				break;
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 10b1990bc1f6..4006f2d459e3 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -623,6 +623,26 @@ drm_atomic_get_new_plane_state(struct drm_atomic_state *state,
 	return state->planes[drm_plane_index(plane)].new_state;
 }
 
+/**
+ * drm_atomic_get_next_plane_state - get plane state after atomic commit
+ * @state: global atomic state object
+ * @plane: plane to grab
+ *
+ * This function returns the plane state that the given plane will have
+ * after the atomic commit. This will be the new plane state if the plane
+ * is part of the global atomic state, or the current state otherwise.
+ */
+static inline struct drm_plane_state *
+drm_atomic_get_next_plane_state(struct drm_atomic_state *state,
+				struct drm_plane *plane)
+{
+	struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
+
+	if (plane_state)
+		return plane_state;
+	return plane->state;
+}
+
 /**
  * drm_atomic_get_existing_connector_state - get connector state, if it exists
  * @state: global atomic state object
-- 
2.37.3


             reply	other threads:[~2022-09-29 14:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-29 14:07 Thomas Zimmermann [this message]
2022-09-29 19:03 ` [PATCH] drm/atomic-helper: Don't allocated plane state in CRTC check Ville Syrjälä
2022-09-30  9:01   ` Thomas Zimmermann
2022-09-30  9:12     ` Ville Syrjälä
2022-09-30 10:26       ` Ville Syrjälä
2022-09-30 10:36         ` Thomas Zimmermann
2022-09-30 10:41           ` Ville Syrjälä
2022-09-30 10:27       ` Thomas Zimmermann

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=20220929140714.14794-1-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=daniel@fooishbar.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=jfalempe@redhat.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=ville.syrjala@linux.intel.com \
    /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.