]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/amd/display: Only add stream to freesync when modeset required
authorLeo (Sunpeng) Li <sunpeng.li@amd.com>
Wed, 18 Oct 2017 18:22:23 +0000 (14:22 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 4 Dec 2017 21:41:29 +0000 (16:41 -0500)
This is a follow-up patch to:

Leo (Sunpeng) Li    Cleanup code that enables freesync

We should only add a stream to freesync if a modeset was requested, so
we don't fill the core freesync map with pointless streams.

Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com>
Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index 816aa426ddd36ea85ec53c9464d8f266e5298aaf..f4bebdc603519d530dad0398f2a3c2f78ab24738 100644 (file)
@@ -4132,12 +4132,28 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
         * are removed from freesync module
         */
        if (adev->dm.freesync_module) {
-               for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
+               for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
                        struct amdgpu_dm_connector *aconnector = NULL;
                        struct dm_connector_state *dm_new_con_state = NULL;
                        struct amdgpu_crtc *acrtc = NULL;
+                       bool modeset_needed;
 
                        dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
+                       dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
+                       modeset_needed = modeset_required(
+                                       new_crtc_state,
+                                       dm_new_crtc_state->stream,
+                                       dm_old_crtc_state->stream);
+                       /* We add stream to freesync if:
+                        * 1. Said stream is not null, and
+                        * 2. A modeset is requested. This means that the
+                        *    stream was removed previously, and needs to be
+                        *    replaced.
+                        */
+                       if (dm_new_crtc_state->stream == NULL ||
+                                       !modeset_needed)
+                               continue;
+
                        acrtc = to_amdgpu_crtc(crtc);
 
                        aconnector =
@@ -4157,12 +4173,10 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *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);
-                       }
+                       mod_freesync_set_user_enable(adev->dm.freesync_module,
+                                                    &dm_new_crtc_state->stream,
+                                                    1,
+                                                    &dm_new_con_state->user_enable);
                }
        }