drm/amd/display: Fix dc_stream_remove_writeback dropping wrong writeback entries.

[why]
The matching entry was disabled but still copied during compaction, so a
removed pipe could survive and overwrite a valid entry, leaving num_wb_info
wrong.

[how]
Skip every entry matching dwb_pipe_inst and compact only survivors. Covered
by test_dc_stream_writeback_drc_and_remove.And added new test cases for coverage.

Reviewed-by: Ilya Bakoulin <ilya.bakoulin@amd.com>
Signed-off-by: Bhuvanachandra Pinninti <BhuvanaChandra.Pinninti@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Bhuvanachandra Pinninti
2026-07-14 19:12:35 -04:00
committed by Alex Deucher
parent d52de56938
commit 5a22cc7c72
@@ -720,20 +720,17 @@ bool dc_stream_remove_writeback(struct dc *dc,
return false;
}
/* remove writeback info for disabled writeback pipes from stream */
/* remove writeback info for the requested writeback pipe from stream */
for (i = 0, j = 0; i < stream->num_wb_info; i++) {
if (stream->writeback_info[i].wb_enabled) {
/* drop every entry that targets the pipe being removed */
if (stream->writeback_info[i].dwb_pipe_inst == dwb_pipe_inst)
continue;
if (stream->writeback_info[i].dwb_pipe_inst == dwb_pipe_inst)
stream->writeback_info[i].wb_enabled = false;
/* trim the array */
if (j < i) {
memcpy(&stream->writeback_info[j], &stream->writeback_info[i],
sizeof(struct dc_writeback_info));
j++;
}
}
/* keep this entry, compacting it down when earlier entries were removed */
if (j != i)
memcpy(&stream->writeback_info[j], &stream->writeback_info[i],
sizeof(struct dc_writeback_info));
j++;
}
stream->num_wb_info = j;