drm/amd/display: Fix incorrect logic in CRC source handling

[WHAT]
Fix three issues amdgpu_dm_crc.c:
- Use cur_crc_src instead of source when deciding whether to call
  drm_dp_stop_crc() in the disable path of set_crc_source(). When
  disabling CRC, source is always NONE so dm_is_crc_source_dprx(source)
  was always false, meaning drm_dp_stop_crc() was never called when
  stopping a DPRX CRC source. Use cur_crc_src to check what was
  previously active instead.
- Replace fragile 'source < 0' comparisons in verify_crc_source() and
  set_crc_source() with AMDGPU_DM_PIPE_CRC_SOURCE_INVALID.
  and avoiding signed/unsigned enum comparison concerns.
- Remove redundant NULL initializations for drm_dev and acrtc in
  handle_crc_irq(). Both variables are unconditionally assigned right
  after.

Assisted-by: Copilot:Claude-Sonnet-4.6
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Alex Hung
2026-05-28 11:48:11 -06:00
committed by Alex Deucher
parent 1c37d1b6c7
commit e561531f2f

View File

@@ -496,7 +496,7 @@ amdgpu_dm_crtc_verify_crc_source(struct drm_crtc *crtc, const char *src_name,
{
enum amdgpu_dm_pipe_crc_source source = dm_parse_crc_source(src_name);
if (source < 0) {
if (source == AMDGPU_DM_PIPE_CRC_SOURCE_INVALID) {
DRM_DEBUG_DRIVER("Unknown CRC source %s for CRTC%d\n",
src_name, crtc->index);
return -EINVAL;
@@ -595,7 +595,7 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name)
bool enabled = false;
int ret = 0;
if (source < 0) {
if (source == AMDGPU_DM_PIPE_CRC_SOURCE_INVALID) {
DRM_DEBUG_DRIVER("Unknown CRC source %s for CRTC%d\n",
src_name, crtc->index);
return -EINVAL;
@@ -724,7 +724,7 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name)
}
} else if (enabled && !enable) {
drm_crtc_vblank_put(crtc);
if (dm_is_crc_source_dprx(source)) {
if (dm_is_crc_source_dprx(cur_crc_src)) {
if (drm_dp_stop_crc(aux)) {
DRM_DEBUG_DRIVER("dp stop crc failed\n");
ret = -EINVAL;
@@ -767,9 +767,9 @@ void amdgpu_dm_crtc_handle_crc_irq(struct drm_crtc *crtc)
{
struct dm_crtc_state *crtc_state;
struct dc_stream_state *stream_state;
struct drm_device *drm_dev = NULL;
struct drm_device *drm_dev;
enum amdgpu_dm_pipe_crc_source cur_crc_src;
struct amdgpu_crtc *acrtc = NULL;
struct amdgpu_crtc *acrtc;
uint32_t crcs[3];
unsigned long flags;