Skip to content

Commit 58d97c9

Browse files
Alvin Leealexdeucher
authored andcommitted
drm/amd/display: Update MBLK calculation for SubVP
[Description] Update MBLK calculation according to hardware doc. For DCC case we were not allocation enough MALL due to an inaccurate MBLK calculation. Tested-by: Daniel Wheeler <[email protected]> Reviewed-by: Jun Lei <[email protected]> Acked-by: Pavle Kotarac <[email protected]> Signed-off-by: Alvin Lee <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 42ff33e commit 58d97c9

File tree

2 files changed

+54
-8
lines changed

2 files changed

+54
-8
lines changed

drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131
#define DCN3_2_DET_SEG_SIZE 64
3232
#define DCN3_2_MALL_MBLK_SIZE_BYTES 65536 // 64 * 1024
33+
#define DCN3_2_MBLK_WIDTH 128
34+
#define DCN3_2_MBLK_HEIGHT_4BPE 128
35+
#define DCN3_2_MBLK_HEIGHT_8BPE 64
3336

3437
#define TO_DCN32_RES_POOL(pool)\
3538
container_of(pool, struct dcn32_resource_pool, base)

drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource_helpers.c

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,71 @@
4646
uint32_t dcn32_helper_calculate_num_ways_for_subvp(struct dc *dc, struct dc_state *context)
4747
{
4848
uint32_t num_ways = 0;
49-
uint32_t mall_region_pixels = 0;
5049
uint32_t bytes_per_pixel = 0;
5150
uint32_t cache_lines_used = 0;
5251
uint32_t lines_per_way = 0;
5352
uint32_t total_cache_lines = 0;
5453
uint32_t bytes_in_mall = 0;
5554
uint32_t num_mblks = 0;
5655
uint32_t cache_lines_per_plane = 0;
57-
uint32_t i = 0;
56+
uint32_t i = 0, j = 0;
57+
uint32_t mblk_width = 0;
58+
uint32_t mblk_height = 0;
59+
uint32_t full_vp_width_blk_aligned = 0;
60+
uint32_t full_vp_height_blk_aligned = 0;
61+
uint32_t mall_alloc_width_blk_aligned = 0;
62+
uint32_t mall_alloc_height_blk_aligned = 0;
63+
uint32_t full_vp_height = 0;
5864

5965
for (i = 0; i < dc->res_pool->pipe_count; i++) {
6066
struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
6167

6268
// Find the phantom pipes
63-
if (pipe->stream && pipe->plane_state && !pipe->top_pipe &&
69+
if (pipe->stream && pipe->plane_state && !pipe->top_pipe && !pipe->prev_odm_pipe &&
6470
pipe->stream->mall_stream_config.type == SUBVP_PHANTOM) {
65-
bytes_per_pixel = pipe->plane_state->format >= SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616 ? 8 : 4;
66-
mall_region_pixels = pipe->plane_state->plane_size.surface_pitch * pipe->stream->timing.v_addressable;
71+
struct pipe_ctx *main_pipe = NULL;
72+
73+
/* Get full viewport height from main pipe (required for MBLK calculation) */
74+
for (j = 0; j < dc->res_pool->pipe_count; j++) {
75+
main_pipe = &context->res_ctx.pipe_ctx[j];
76+
if (main_pipe->stream == pipe->stream->mall_stream_config.paired_stream) {
77+
full_vp_height = main_pipe->plane_res.scl_data.viewport.height;
78+
break;
79+
}
80+
}
6781

68-
// For bytes required in MALL, calculate based on number of MBlks required
69-
num_mblks = (mall_region_pixels * bytes_per_pixel +
70-
DCN3_2_MALL_MBLK_SIZE_BYTES - 1) / DCN3_2_MALL_MBLK_SIZE_BYTES;
82+
bytes_per_pixel = pipe->plane_state->format >= SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616 ? 8 : 4;
83+
mblk_width = DCN3_2_MBLK_WIDTH;
84+
mblk_height = bytes_per_pixel == 4 ? DCN3_2_MBLK_HEIGHT_4BPE : DCN3_2_MBLK_HEIGHT_8BPE;
85+
86+
/* full_vp_width_blk_aligned = FLOOR(vp_x_start + full_vp_width + blk_width - 1, blk_width) -
87+
* FLOOR(vp_x_start, blk_width)
88+
*/
89+
full_vp_width_blk_aligned = ((pipe->plane_res.scl_data.viewport.x +
90+
pipe->plane_res.scl_data.viewport.width + mblk_width - 1) / mblk_width * mblk_width) +
91+
(pipe->plane_res.scl_data.viewport.x / mblk_width * mblk_width);
92+
93+
/* full_vp_height_blk_aligned = FLOOR(vp_y_start + full_vp_height + blk_height - 1, blk_height) -
94+
* FLOOR(vp_y_start, blk_height)
95+
*/
96+
full_vp_height_blk_aligned = ((pipe->plane_res.scl_data.viewport.y +
97+
full_vp_height + mblk_height - 1) / mblk_height * mblk_height) +
98+
(pipe->plane_res.scl_data.viewport.y / mblk_height * mblk_height);
99+
100+
/* mall_alloc_width_blk_aligned_l/c = full_vp_width_blk_aligned_l/c */
101+
mall_alloc_width_blk_aligned = full_vp_width_blk_aligned;
102+
103+
/* mall_alloc_height_blk_aligned_l/c = CEILING(sub_vp_height_l/c - 1, blk_height_l/c) + blk_height_l/c */
104+
mall_alloc_height_blk_aligned = (pipe->stream->timing.v_addressable - 1 + mblk_height - 1) /
105+
mblk_height * mblk_height + mblk_height;
106+
107+
/* full_mblk_width_ub_l/c = mall_alloc_width_blk_aligned_l/c;
108+
* full_mblk_height_ub_l/c = mall_alloc_height_blk_aligned_l/c;
109+
* num_mblk_l/c = (full_mblk_width_ub_l/c / mblk_width_l/c) * (full_mblk_height_ub_l/c / mblk_height_l/c);
110+
* (Should be divisible, but round up if not)
111+
*/
112+
num_mblks = ((mall_alloc_width_blk_aligned + mblk_width - 1) / mblk_width) *
113+
((mall_alloc_height_blk_aligned + mblk_height - 1) / mblk_height);
71114
bytes_in_mall = num_mblks * DCN3_2_MALL_MBLK_SIZE_BYTES;
72115
// cache lines used is total bytes / cache_line size. Add +2 for worst case alignment
73116
// (MALL is 64-byte aligned)

0 commit comments

Comments
 (0)