Hi,

The function amdgpu_dm_crtc_mem_type_changed() in amdgpu/display/dm_helpers.c appears to have a logical issue:

new_plane_state = drm_atomic_get_plane_state(state, plane);
old_plane_state = drm_atomic_get_plane_state(state, plane);

Both new_plane_state and old_plane_state are obtained from drm_atomic_get_plane_state(state, plane), which means they will always point to the same plane state. As a result, the subsequent check:

if (old_plane_state->fb && new_plane_state->fb &&
    get_mem_type(old_plane_state->fb) != get_mem_type(new_plane_state->fb))
    return true;
        
such case it will never detect a change in memory type, because old_plane_state and new_plane_state are identical.

Proposed fix: use drm_atomic_get_old_plane_state() to retrieve the previous plane state:

---
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 8e1622bf7a42..74f4f7e7b119 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -11968,7 +11968,7 @@ static bool amdgpu_dm_crtc_mem_type_changed(struct drm_device *dev,

        drm_for_each_plane_mask(plane, dev, crtc_state->plane_mask) {
                new_plane_state = drm_atomic_get_plane_state(state, plane);
-               old_plane_state = drm_atomic_get_plane_state(state, plane);
+ old_plane_state = drm_atomic_get_old_plane_state(state, plane); //<<

                if (IS_ERR(new_plane_state) || IS_ERR(old_plane_state)) {
drm_err(dev, "Failed to get plane state for plane %s\n", plane->name);


Thanks,
Alok

Reply via email to