[PATCH 16/28] drm/amd/display: Cleanup code that enables freesync

Harry Wentland harry.wentland at amd.com
Thu Oct 19 17:46:35 UTC 2017


From: "Leo (Sunpeng) Li" <sunpeng.li at amd.com>

This is a follow-up patch to:

Bhawanpreet Lakha    Atomic freesync ASSERT fix

Changes:
- Combine to use one iterator
- Use new DRM iterators.

Signed-off-by: Leo (Sunpeng) Li <sunpeng.li at amd.com>
Reviewed-by: Bhawanpreet Lakha <Bhawanpreet.Lakha at amd.com>
Acked-by: Harry Wentland <Harry.Wentland at amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 55 +++++++----------------
 1 file changed, 17 insertions(+), 38 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 a6424eb1c1a5..812a0016869f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4050,7 +4050,6 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct amdgpu_crtc *new_crtcs[MAX_STREAMS];
-	struct dc_stream_state *new_stream = NULL;
 	unsigned long flags;
 	bool wait_for_vblank = true;
 	struct drm_connector *connector;
@@ -4145,56 +4144,36 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	 * are removed from freesync module
 	 */
 	if (adev->dm.freesync_module) {
-		for (i = 0; i < new_crtcs_count; i++) {
+		for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
 			struct amdgpu_dm_connector *aconnector = NULL;
+			struct dm_connector_state *dm_new_con_state = NULL;
+			struct amdgpu_crtc *acrtc = NULL;
 
-			new_crtc_state = drm_atomic_get_new_crtc_state(
-					state, &new_crtcs[i]->base);
 			dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
+			acrtc = to_amdgpu_crtc(crtc);
 
-			new_stream = dm_new_crtc_state->stream;
 			aconnector =
 				amdgpu_dm_find_first_crtc_matching_connector(
-					state,
-					&new_crtcs[i]->base);
+					state, crtc);
 			if (!aconnector) {
 				DRM_DEBUG_DRIVER("Atomic commit: Failed to find connector for acrtc id:%d "
 					 "skipping freesync init\n",
-					 new_crtcs[i]->crtc_id);
+					 acrtc->crtc_id);
 				continue;
 			}
 
 			mod_freesync_add_stream(adev->dm.freesync_module,
-						new_stream, &aconnector->caps);
-		}
-
-		list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-
-			struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
-			struct amdgpu_dm_connector *aconnector = NULL;
-			struct dm_connector_state *dm_new_con_state = NULL;
-			struct dm_crtc_state *acrtc_state = NULL;
-
-			new_crtc_state = drm_atomic_get_new_crtc_state(
-					state, &acrtc->base);
-			acrtc_state = to_dm_crtc_state(new_crtc_state);
-
-
-			aconnector =
-				amdgpu_dm_find_first_crtc_matching_connector(
-					state,
-					crtc);
-			if (aconnector) {
-				new_con_state = drm_atomic_get_new_connector_state(
-						state, &aconnector->base);
-				dm_new_con_state = to_dm_connector_state(new_con_state);
-
-				if (new_stream) {
-					mod_freesync_set_user_enable(adev->dm.freesync_module,
-								     &acrtc_state->stream,
-								     1,
-								     &dm_new_con_state->user_enable);
-				}
+						dm_new_crtc_state->stream,
+						&aconnector->caps);
+			new_con_state = drm_atomic_get_new_connector_state(
+					state, &aconnector->base);
+			dm_new_con_state = to_dm_connector_state(new_con_state);
+
+			if (dm_new_crtc_state->stream) {
+				mod_freesync_set_user_enable(adev->dm.freesync_module,
+							     &dm_new_crtc_state->stream,
+							     1,
+							     &dm_new_con_state->user_enable);
 			}
 		}
 	}
-- 
2.14.1



More information about the amd-gfx mailing list