[PATCH 4/5] drm/amd/display: Move lock_and_validation_needed to dm_*_states

sunpeng.li at amd.com sunpeng.li at amd.com
Tue Dec 18 15:26:15 UTC 2018


From: Leo Li <sunpeng.li at amd.com>

In preparation for moving the dm_update dance to the crtc atomic helper,
the lock_and_validation_needed flag need to be de-localized.

Move it to dm_*_states, and update it in the corresponding dm_update*
functions. Add a function to determine if DC global locking is needed by
iterating over all the dm_*_states.

Signed-off-by: Leo Li <sunpeng.li at amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 64 +++++++++++++++++------
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  6 +++
 2 files changed, 53 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 3745472..a629544 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3472,8 +3472,7 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm,
 				 struct drm_crtc *crtc,
 				 struct drm_crtc_state *old_crtc_state,
 				 struct drm_crtc_state *new_crtc_state,
-				 bool enable,
-				 bool *lock_and_validation_needed)
+				 bool enable)
 {
 	struct dm_atomic_state *dm_state = NULL;
 	struct dm_crtc_state *dm_old_crtc_state, *dm_new_crtc_state;
@@ -3592,7 +3591,7 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm,
 
 		reset_freesync_config_for_crtc(dm_new_crtc_state);
 
-		*lock_and_validation_needed = true;
+		dm_new_crtc_state->lock_and_validation_needed = true;
 
 	} else {/* Add stream for any updated/enabled CRTC */
 		/*
@@ -3630,7 +3629,7 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm,
 				goto fail;
 			}
 
-			*lock_and_validation_needed = true;
+			dm_new_crtc_state->lock_and_validation_needed = true;
 		}
 	}
 
@@ -3690,8 +3689,7 @@ static int dm_update_planes_state(struct dc *dc,
 				  struct drm_plane *plane,
 				  struct drm_plane_state *old_plane_state,
 				  struct drm_plane_state *new_plane_state,
-				  bool enable,
-				  bool *lock_and_validation_needed)
+				  bool enable)
 {
 
 	struct dm_atomic_state *dm_state = NULL;
@@ -3750,7 +3748,7 @@ static int dm_update_planes_state(struct dc *dc,
 		dc_plane_state_release(dm_old_plane_state->dc_state);
 		dm_new_plane_state->dc_state = NULL;
 
-		*lock_and_validation_needed = true;
+		dm_new_plane_state->lock_and_validation_needed = true;
 
 	} else { /* Add new planes */
 		struct dc_plane_state *dc_new_plane_state;
@@ -3819,13 +3817,47 @@ static int dm_update_planes_state(struct dc *dc,
 		 */
 		dm_new_plane_state->dc_state->update_flags.bits.full_update = 1;
 
-		*lock_and_validation_needed = true;
+		dm_new_plane_state->lock_and_validation_needed = true;
 	}
 
 
 	return ret;
 }
 
+static bool dm_lock_and_validation_needed(struct drm_atomic_state *state)
+{
+	struct drm_plane *plane;
+	struct drm_plane_state *new_plane_state;
+	struct dm_plane_state *dm_new_plane_state;
+	struct drm_crtc *crtc;
+	struct drm_crtc_state *new_crtc_state;
+	struct dm_crtc_state *dm_new_crtc_state;
+	struct drm_connector *connector;
+	struct drm_connector_state *new_con_state;
+	struct dm_connector_state *dm_new_con_state;
+	int i = 0;
+
+	for_each_new_plane_in_state(state, plane, new_plane_state, i) {
+		dm_new_plane_state = to_dm_plane_state(new_plane_state);
+		if (dm_new_plane_state->lock_and_validation_needed)
+			return true;
+	}
+
+	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
+		dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
+		if (dm_new_crtc_state->lock_and_validation_needed)
+			return true;
+	}
+
+	for_each_new_connector_in_state(state, connector, new_con_state, i) {
+		dm_new_con_state = to_dm_connector_state(new_con_state);
+		if (dm_new_con_state->lock_and_validation_needed)
+			return true;
+	}
+
+	return false;
+}
+
 static int dm_crtc_helper_atomic_check(struct drm_crtc *crtc,
 				       struct drm_crtc_state *state)
 {
@@ -5921,8 +5953,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 		ret = dm_update_planes_state(dc, state, plane,
 					     old_plane_state,
 					     new_plane_state,
-					     false,
-					     &lock_and_validation_needed);
+					     false);
 		if (ret)
 			goto fail;
 	}
@@ -5932,8 +5963,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 		ret = dm_update_crtcs_state(&adev->dm, state, crtc,
 					    old_crtc_state,
 					    new_crtc_state,
-					    false,
-					    &lock_and_validation_needed);
+					    false);
 		if (ret)
 			goto fail;
 	}
@@ -5943,8 +5973,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 		ret = dm_update_crtcs_state(&adev->dm, state, crtc,
 					    old_crtc_state,
 					    new_crtc_state,
-					    true,
-					    &lock_and_validation_needed);
+					    true);
 		if (ret)
 			goto fail;
 	}
@@ -5954,8 +5983,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 		ret = dm_update_planes_state(dc, state, plane,
 					     old_plane_state,
 					     new_plane_state,
-					     true,
-					     &lock_and_validation_needed);
+					     true);
 		if (ret)
 			goto fail;
 	}
@@ -5985,13 +6013,15 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 			continue;
 
 		overall_update_type = UPDATE_TYPE_FULL;
-		lock_and_validation_needed = true;
+		dm_new_con_state->lock_and_validation_needed = true;
 	}
 
 	ret = dm_determine_update_type_for_commit(dc, state, &update_type);
 	if (ret)
 		goto fail;
 
+	lock_and_validation_needed = dm_lock_and_validation_needed(state);
+
 	if (overall_update_type < update_type)
 		overall_update_type = update_type;
 
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
index fbd161d..0754b3c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
@@ -254,6 +254,8 @@ struct dc_plane_state;
 struct dm_plane_state {
 	struct drm_plane_state base;
 	struct dc_plane_state *dc_state;
+
+	bool lock_and_validation_needed;
 };
 
 struct dm_crtc_state {
@@ -272,6 +274,8 @@ struct dm_crtc_state {
 	struct dc_info_packet vrr_infopacket;
 
 	int abm_level;
+
+	bool lock_and_validation_needed;
 };
 
 #define to_dm_crtc_state(x) container_of(x, struct dm_crtc_state, base)
@@ -294,6 +298,8 @@ struct dm_connector_state {
 	bool underscan_enable;
 	bool freesync_capable;
 	uint8_t abm_level;
+
+	bool lock_and_validation_needed;
 };
 
 #define to_dm_connector_state(x)\
-- 
2.7.4



More information about the amd-gfx mailing list