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. Update
AMD KUnit color tests accordingly.
Fixes: 9ba25915efba ("drm/amd/display: Add support for sRGB EOTF in DEGAM
block")
Reviewed-by: Harry Wentland <[email protected]>
Signed-off-by: Melissa Wen <[email protected]>
---
.../drm/amd/display/amdgpu_dm/amdgpu_dm_color.c | 8 ++++----
.../amdgpu_dm/tests/amdgpu_dm_color_test.c | 17 +++++++++--------
2 files changed, 13 insertions(+), 12 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 7332c8874397..3bc4cbe820c6 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
@@ -2009,10 +2009,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;
- /* Fixed Matrix (YUV to RGB) */
- if (!colorop)
+ if (drm_WARN_ON(dev, !colorop))
return -EINVAL;
+ /* Fixed Matrix (YUV to RGB) */
ret = __set_dm_plane_colorop_fixed_matrix(plane_state, dc_plane_state,
colorop);
if (ret)
return ret;
@@ -2194,8 +2194,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);
}
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_color_test.c
b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_color_test.c
index 8e00da61a04b..61543a3026e9 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_color_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_color_test.c
@@ -2539,7 +2539,7 @@ static void
dm_test_update_plane_color_mgmt_colorop_bypass_pipeline(struct kunit
}
/**
- * dm_test_update_plane_color_mgmt_colorop_missing_multiplier - missing
multiplier op falls back
+ * dm_test_update_plane_color_mgmt_colorop_missing_multiplier - missing
multiplier op is rejected
* @test: KUnit test context
*/
static void dm_test_update_plane_color_mgmt_colorop_missing_multiplier(struct
kunit *test)
@@ -2560,13 +2560,13 @@ static void
dm_test_update_plane_color_mgmt_colorop_missing_multiplier(struct ku
KUNIT_EXPECT_EQ(test,
amdgpu_dm_update_plane_color_mgmt(f.crtc_state,
&f.dm_plane_state->base, f.dc_plane_state),
- 0);
+ -EINVAL);
KUNIT_EXPECT_FALSE(test, f.dc_plane_state->cm.flags.bits.shaper_enable);
KUNIT_EXPECT_FALSE(test, f.dc_plane_state->cm.flags.bits.blend_enable);
}
/**
- * dm_test_update_plane_color_mgmt_colorop_missing_3x4 - missing 3x4 op falls
back
+ * dm_test_update_plane_color_mgmt_colorop_missing_3x4 - missing 3x4 op is
rejected
* @test: KUnit test context
*/
static void dm_test_update_plane_color_mgmt_colorop_missing_3x4(struct kunit
*test)
@@ -2589,13 +2589,13 @@ static void
dm_test_update_plane_color_mgmt_colorop_missing_3x4(struct kunit *te
KUNIT_EXPECT_EQ(test,
amdgpu_dm_update_plane_color_mgmt(f.crtc_state,
&f.dm_plane_state->base, f.dc_plane_state),
- 0);
+ -EINVAL);
KUNIT_EXPECT_FALSE(test, f.dc_plane_state->cm.flags.bits.shaper_enable);
KUNIT_EXPECT_FALSE(test, f.dc_plane_state->cm.flags.bits.blend_enable);
}
/**
- * dm_test_update_plane_color_mgmt_colorop_truncated - truncated pipelines
fall back
+ * dm_test_update_plane_color_mgmt_colorop_truncated - truncated pipelines are
rejected
* @test: KUnit test context
*
* Covers each pipeline exit after the 3x4 matrix while all present colorops
@@ -2640,7 +2640,8 @@ static void
dm_test_update_plane_color_mgmt_colorop_truncated(struct kunit *test
memset(f.dc_plane_state, 0, sizeof(*f.dc_plane_state));
ret = amdgpu_dm_update_plane_color_mgmt(crtc_state,
plane_state, dc_plane_state);
- KUNIT_EXPECT_EQ_MSG(test, ret, 0, "pipeline length %d should
fall back", count);
+ KUNIT_EXPECT_EQ_MSG(test, ret, -EINVAL,
+ "pipeline length %d should be rejected",
count);
KUNIT_EXPECT_FALSE(test,
f.dc_plane_state->cm.flags.bits.shaper_enable);
KUNIT_EXPECT_FALSE(test,
f.dc_plane_state->cm.flags.bits.lut3d_enable);
KUNIT_EXPECT_FALSE(test,
f.dc_plane_state->cm.flags.bits.blend_enable);
@@ -2810,7 +2811,7 @@ static void
dm_test_update_plane_color_mgmt_colorop_3dlut(struct kunit *test)
}
/**
- * dm_test_update_plane_color_mgmt_colorop_3dlut_no_data - empty 3D LUT falls
back
+ * dm_test_update_plane_color_mgmt_colorop_3dlut_no_data - active 3D LUT
without data is rejected
* @test: KUnit test context
*/
static void dm_test_update_plane_color_mgmt_colorop_3dlut_no_data(struct kunit
*test)
@@ -2851,7 +2852,7 @@ static void
dm_test_update_plane_color_mgmt_colorop_3dlut_no_data(struct kunit *
ret = amdgpu_dm_update_plane_color_mgmt(f.crtc_state, plane_state,
f.dc_plane_state);
- KUNIT_EXPECT_EQ(test, ret, 0);
+ KUNIT_EXPECT_EQ(test, ret, -EINVAL);
KUNIT_EXPECT_FALSE(test, f.dc_plane_state->cm.flags.bits.lut3d_enable);
}
--
2.53.0