From: Zhikai Zhai <zhikai.z...@amd.com>

[WHY]
In some cases the remain de-tile buffer segments will be greater
than zero if we don't add the non-top pipe to calculate, at
this time the override de-tile buffer size will be valid and used.
But it makes the de-tile buffer segments used finally for all of pipes
exceed the maximum.

[HOW]
Add the non-top pipe to calculate the remain de-tile buffer segments.
Don't set override size to use the average according to pipe count
if the value exceed the maximum.

Reviewed-by: Charlene Liu <charlene....@amd.com>
Signed-off-by: Zhikai Zhai <zhikai.z...@amd.com>
Signed-off-by: Tom Chung <chiahsuan.ch...@amd.com>
---
 .../dc/resource/dcn315/dcn315_resource.c      | 42 +++++++++----------
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c 
b/drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c
index 14acef036b5a..6c2bb3f63be1 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c
@@ -1698,7 +1698,7 @@ static int dcn315_populate_dml_pipes_from_context(
                pipes[pipe_cnt].dout.dsc_input_bpc = 0;
                DC_FP_START();
                dcn31_zero_pipe_dcc_fraction(pipes, pipe_cnt);
-               if (pixel_rate_crb && !pipe->top_pipe && !pipe->prev_odm_pipe) {
+               if (pixel_rate_crb) {
                        int bpp = 
source_format_to_bpp(pipes[pipe_cnt].pipe.src.source_format);
                        /* Ceil to crb segment size */
                        int approx_det_segs_required_for_pstate = 
dcn_get_approx_det_segs_required_for_pstate(
@@ -1755,28 +1755,26 @@ static int dcn315_populate_dml_pipes_from_context(
                                continue;
                        }
 
-                       if (!pipe->top_pipe && !pipe->prev_odm_pipe) {
-                               bool split_required = 
pipe->stream->timing.pix_clk_100hz >= 
dcn_get_max_non_odm_pix_rate_100hz(&dc->dml.soc)
-                                               || (pipe->plane_state && 
pipe->plane_state->src_rect.width > 5120);
-
-                               if (remaining_det_segs > MIN_RESERVED_DET_SEGS 
&& crb_pipes != 0)
-                                       
pipes[pipe_cnt].pipe.src.det_size_override += (remaining_det_segs - 
MIN_RESERVED_DET_SEGS) / crb_pipes +
-                                                       (crb_idx < 
(remaining_det_segs - MIN_RESERVED_DET_SEGS) % crb_pipes ? 1 : 0);
-                               if (pipes[pipe_cnt].pipe.src.det_size_override 
> 2 * DCN3_15_MAX_DET_SEGS) {
-                                       /* Clamp to 2 pipe split max det 
segments */
-                                       remaining_det_segs += 
pipes[pipe_cnt].pipe.src.det_size_override - 2 * (DCN3_15_MAX_DET_SEGS);
-                                       
pipes[pipe_cnt].pipe.src.det_size_override = 2 * DCN3_15_MAX_DET_SEGS;
-                               }
-                               if (pipes[pipe_cnt].pipe.src.det_size_override 
> DCN3_15_MAX_DET_SEGS || split_required) {
-                                       /* If we are splitting we must have an 
even number of segments */
-                                       remaining_det_segs += 
pipes[pipe_cnt].pipe.src.det_size_override % 2;
-                                       
pipes[pipe_cnt].pipe.src.det_size_override -= 
pipes[pipe_cnt].pipe.src.det_size_override % 2;
-                               }
-                               /* Convert segments into size for DML use */
-                               pipes[pipe_cnt].pipe.src.det_size_override *= 
DCN3_15_CRB_SEGMENT_SIZE_KB;
-
-                               crb_idx++;
+                       bool split_required = 
pipe->stream->timing.pix_clk_100hz >= 
dcn_get_max_non_odm_pix_rate_100hz(&dc->dml.soc)
+                                       || (pipe->plane_state && 
pipe->plane_state->src_rect.width > 5120);
+
+                       if (remaining_det_segs > MIN_RESERVED_DET_SEGS && 
crb_pipes != 0)
+                               pipes[pipe_cnt].pipe.src.det_size_override += 
(remaining_det_segs - MIN_RESERVED_DET_SEGS) / crb_pipes +
+                                               (crb_idx < (remaining_det_segs 
- MIN_RESERVED_DET_SEGS) % crb_pipes ? 1 : 0);
+                       if (pipes[pipe_cnt].pipe.src.det_size_override > 2 * 
DCN3_15_MAX_DET_SEGS) {
+                               /* Clamp to 2 pipe split max det segments */
+                               remaining_det_segs += 
pipes[pipe_cnt].pipe.src.det_size_override - 2 * (DCN3_15_MAX_DET_SEGS);
+                               pipes[pipe_cnt].pipe.src.det_size_override = 2 
* DCN3_15_MAX_DET_SEGS;
+                       }
+                       if (pipes[pipe_cnt].pipe.src.det_size_override > 
DCN3_15_MAX_DET_SEGS || split_required) {
+                               /* If we are splitting we must have an even 
number of segments */
+                               remaining_det_segs += 
pipes[pipe_cnt].pipe.src.det_size_override % 2;
+                               pipes[pipe_cnt].pipe.src.det_size_override -= 
pipes[pipe_cnt].pipe.src.det_size_override % 2;
                        }
+                       /* Convert segments into size for DML use */
+                       pipes[pipe_cnt].pipe.src.det_size_override *= 
DCN3_15_CRB_SEGMENT_SIZE_KB;
+
+                       crb_idx++;
                        pipe_cnt++;
                }
        }
-- 
2.34.1

Reply via email to