drm/amd/display: fix flickering caused by S/G mode
authorjsg <jsg@openbsd.org>
Tue, 13 Jun 2023 03:07:52 +0000 (03:07 +0000)
committerjsg <jsg@openbsd.org>
Tue, 13 Jun 2023 03:07:52 +0000 (03:07 +0000)
From Hamza Mahfooz
f2e43c98042c607376479484ea8f98d3452868f5 in linux-6.1.y/6.1.29
08da182175db4c7f80850354849d95f2670e8cd9 in mainline linux

sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index dbe4311..1127fb2 100644 (file)
@@ -7597,6 +7597,13 @@ static void amdgpu_dm_commit_cursors(struct drm_atomic_state *state)
                        handle_cursor_update(plane, old_plane_state);
 }
 
+static inline uint32_t get_mem_type(struct drm_framebuffer *fb)
+{
+       struct amdgpu_bo *abo = gem_to_amdgpu_bo(fb->obj[0]);
+
+       return abo->tbo.resource ? abo->tbo.resource->mem_type : 0;
+}
+
 static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
                                    struct dc_state *dc_state,
                                    struct drm_device *dev,
@@ -7714,11 +7721,13 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 
                /*
                 * Only allow immediate flips for fast updates that don't
-                * change FB pitch, DCC state, rotation or mirroing.
+                * change memory domain, FB pitch, DCC state, rotation or
+                * mirroring.
                 */
                bundle->flip_addrs[planes_count].flip_immediate =
                        crtc->state->async_flip &&
-                       acrtc_state->update_type == UPDATE_TYPE_FAST;
+                       acrtc_state->update_type == UPDATE_TYPE_FAST &&
+                       get_mem_type(old_plane_state->fb) == get_mem_type(fb);
 
                timestamp_ns = ktime_get_ns();
                bundle->flip_addrs[planes_count].flip_timestamp_in_us = div_u64(timestamp_ns, 1000);