Skip to content

Commit 4d28524

Browse files
George Shenalexdeucher
authored andcommitted
drm/amd/display: Fix calculation for cursor CAB allocation
[Why] The cursor size (in memory) is currently incorrectly calculated, resulting not enough CAB being allocated for static screen cursor in MALL refresh. This results in cursor image corruption. [How] Use cursor pitch instead of cursor width when calculating cursor size. Update num cache lines calculation to use the result of the cursor size calculation instead of manually recalculating again. Reviewed-by: Alvin Lee <Alvin.Lee2@amd.com> Acked-by: Tom Chung <chiahsuan.chung@amd.com> Signed-off-by: George Shen <george.shen@amd.com> Tested-by: Daniel Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org # 6.0.x
1 parent 7e952a1 commit 4d28524

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,7 @@ static uint32_t dcn32_calculate_cab_allocation(struct dc *dc, struct dc_state *c
283283
using the max for calculation */
284284

285285
if (hubp->curs_attr.width > 0) {
286-
// Round cursor width to next multiple of 64
287-
cursor_size = (((hubp->curs_attr.width + 63) / 64) * 64) * hubp->curs_attr.height;
286+
cursor_size = hubp->curs_attr.pitch * hubp->curs_attr.height;
288287

289288
switch (pipe->stream->cursor_attributes.color_format) {
290289
case CURSOR_MODE_MONO:
@@ -309,9 +308,9 @@ static uint32_t dcn32_calculate_cab_allocation(struct dc *dc, struct dc_state *c
309308
cursor_size > 16384) {
310309
/* cursor_num_mblk = CEILING(num_cursors*cursor_width*cursor_width*cursor_Bpe/mblk_bytes, 1)
311310
*/
312-
cache_lines_used += (((hubp->curs_attr.width * hubp->curs_attr.height * cursor_bpp +
313-
DCN3_2_MALL_MBLK_SIZE_BYTES - 1) / DCN3_2_MALL_MBLK_SIZE_BYTES) *
314-
DCN3_2_MALL_MBLK_SIZE_BYTES) / dc->caps.cache_line_size + 2;
311+
cache_lines_used += (((cursor_size + DCN3_2_MALL_MBLK_SIZE_BYTES - 1) /
312+
DCN3_2_MALL_MBLK_SIZE_BYTES) * DCN3_2_MALL_MBLK_SIZE_BYTES) /
313+
dc->caps.cache_line_size + 2;
315314
}
316315
break;
317316
}
@@ -727,10 +726,7 @@ void dcn32_update_mall_sel(struct dc *dc, struct dc_state *context)
727726
struct hubp *hubp = pipe->plane_res.hubp;
728727

729728
if (pipe->stream && pipe->plane_state && hubp && hubp->funcs->hubp_update_mall_sel) {
730-
//Round cursor width up to next multiple of 64
731-
int cursor_width = ((hubp->curs_attr.width + 63) / 64) * 64;
732-
int cursor_height = hubp->curs_attr.height;
733-
int cursor_size = cursor_width * cursor_height;
729+
int cursor_size = hubp->curs_attr.pitch * hubp->curs_attr.height;
734730

735731
switch (hubp->curs_attr.color_format) {
736732
case CURSOR_MODE_MONO:

0 commit comments

Comments
 (0)