drm/amd/display: Check all enabled planes in dm_check_crtc_cursor
authorMichel Dänzer <mdaenzer@redhat.com>
Tue, 12 Sep 2023 10:22:24 +0000 (12:22 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 28 Sep 2023 19:38:30 +0000 (15:38 -0400)
It was only checking planes which had any state changes in the same
commit. However, it also needs to check other enabled planes.

Not doing this meant that a commit might spuriously "succeed", resulting
in the cursor plane displaying with incorrect scaling. See
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3177#note_1824263
for an example.

Fixes: d1bfbe8a3202 ("amd/display: check cursor plane matches underlying plane")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index 4dfb1cb2efb1d8cf23d756cd1752c7a096e8c407..059d1a32fbbf587f37abfcbbab79bc9a8de61d48 100644 (file)
@@ -10019,14 +10019,24 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,
         * blending properties match the underlying planes'.
         */
 
-       new_cursor_state = drm_atomic_get_new_plane_state(state, cursor);
-       if (!new_cursor_state || !new_cursor_state->fb)
+       new_cursor_state = drm_atomic_get_plane_state(state, cursor);
+       if (IS_ERR(new_cursor_state))
+               return PTR_ERR(new_cursor_state);
+
+       if (!new_cursor_state->fb)
                return 0;
 
        dm_get_oriented_plane_size(new_cursor_state, &cursor_src_w, &cursor_src_h);
        cursor_scale_w = new_cursor_state->crtc_w * 1000 / cursor_src_w;
        cursor_scale_h = new_cursor_state->crtc_h * 1000 / cursor_src_h;
 
+       /* Need to check all enabled planes, even if this commit doesn't change
+        * their state
+        */
+       i = drm_atomic_add_affected_planes(state, crtc);
+       if (i)
+               return i;
+
        for_each_new_plane_in_state_reverse(state, underlying, new_underlying_state, i) {
                /* Narrow down to non-cursor planes on the same CRTC as the cursor */
                if (new_underlying_state->crtc != crtc || underlying == crtc->cursor)