amdgpu_dm_plane_set_colorop_properties() returns -EINVAL both when the
plane has no color pipeline selected, where falling back to the legacy
color properties is correct, and when programming an active pipeline
fails, so the caller treats every failure as the former and silently
programs the plane from the legacy properties, leaving it in a mixed
state and userspace with no error. Check if plane_state->color_pipeline
is set instead, so the legacy path is only taken when no pipeline is set
and any other failure is propagated out of the atomic check.

Signed-off-by: Melissa Wen <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
index f6a2af5d2e96..f2731989499c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
@@ -1906,10 +1906,10 @@ amdgpu_dm_plane_set_colorop_properties(struct 
drm_plane_state *plane_state,
        bool has_3dlut = adev->dm.dc->caps.color.dpp.hw_3d_lut || 
adev->dm.dc->caps.color.mpc.preblend;
        int ret;
 
-       /* 1D Curve - DEGAM TF */
-       if (!colorop)
+       if (drm_WARN_ON(dev, !colorop))
                return -EINVAL;
 
+       /* 1D Curve - DEGAM TF */
        ret = __set_dm_plane_colorop_degamma(plane_state, dc_plane_state, 
colorop);
        if (ret)
                return ret;
@@ -2080,8 +2080,8 @@ int amdgpu_dm_update_plane_color_mgmt(struct 
dm_crtc_state *crtc,
                dc_plane_state->input_csc_color_matrix.enable_adjustment = 
false;
        }
 
-       if (!amdgpu_dm_plane_set_colorop_properties(plane_state, 
dc_plane_state))
-               return 0;
+       if (plane_state->color_pipeline)
+               return amdgpu_dm_plane_set_colorop_properties(plane_state, 
dc_plane_state);
 
        return amdgpu_dm_plane_set_color_properties(plane_state, 
dc_plane_state);
 }
-- 
2.53.0

Reply via email to