From: Alex Hung <alex.h...@amd.com>

[ Upstream commit ab37b88ed9de9de8d582683f7ea17059f1251a7f ]

[WHY]
Counter j was not updated to present the num of writeback_info when
writeback pipes are removed.

[HOW]
update j (num of writeback info) under the correct condition.

Tested-by: Daniel Wheeler <daniel.whee...@amd.com>
Reviewed-by: Harry Wentland <harry.wentl...@amd.com>
Signed-off-by: Alex Hung <alex.h...@amd.com>
Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---
 drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
index 5055af147c20..37dc280e5566 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
@@ -497,11 +497,12 @@ bool dc_stream_remove_writeback(struct dc *dc,
                        if (stream->writeback_info[i].dwb_pipe_inst == 
dwb_pipe_inst)
                                stream->writeback_info[i].wb_enabled = false;
 
-                       if (j < i)
-                               /* trim the array */
+                       /* trim the array */
+                       if (j < i) {
                                memcpy(&stream->writeback_info[j], 
&stream->writeback_info[i],
                                                sizeof(struct 
dc_writeback_info));
-                       j++;
+                               j++;
+                       }
                }
        }
        stream->num_wb_info = j;
-- 
2.43.0

Reply via email to