Skip to contentSkip to conversation

drm/atomic-helper: Don't allocated plane state in CRTC check

PATCH Superseded Thomas Zimmermann 1 participant 1 message Sep 30, 2022

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

PATCH v2 1/1 drm/atomic-helper: Don't allocated plane state in CRTC check

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 result 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.

v2:
* remove unnecessary test for plane->crtc (Ville)
* inline drm_atomic_get_next_plane_state() (Ville)
* acquire plane lock before accessing plane->state (Ville)

Fixes d6b9af1097fe ("drm/atomic-helper: Add helper drm_atomic_helper_check_crtc_state()")
Cc Thomas Zimmermann <[email protected]>
Cc Jocelyn Falempe <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/drm_atomic_helper.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +12 -4
index 98cc3137c062..b7774a39712b 100644
@@ -960,10 +960,18 @@ 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);
-			if (plane_state->fb && plane_state->crtc) {
+
+			plane_state = drm_atomic_get_new_plane_state(state, plane);
+			if (!plane_state) {
+				/* plane isn't part of the update; look at existing state */
+				int ret = drm_modeset_lock(&plane->mutex, state->acquire_ctx);
+
+				if (ret)
+					return ret;
+				plane_state = plane->state;
+			}
+
+			if (plane_state->fb) {
 				has_primary_plane = true;
 				break;
 			}
Signature · 1 line
2.37.3