Skip to content

Commit 787e7be

Browse files
AMD-aricalexdeucher
authored andcommitted
drm/amd/display: Optimize cursor position updates
[why] Updating the cursor enablement register can be a slow operation and accumulates when high polling rate cursors cause frequent updates asynchronously to the cursor position. [how] Since the cursor enable bit is cached there is no need to update the enablement register if there is no change to it. This removes the read-modify-write from the cursor position programming path in HUBP and DPP, leaving only the register writes. Reviewed-by: Josip Pavic <[email protected]> Signed-off-by: Aric Cyr <[email protected]> Signed-off-by: Roman Li <[email protected]> Tested-by: Daniel Wheeler <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent de5d7a8 commit 787e7be

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

drivers/gpu/drm/amd/display/dc/dpp/dcn10/dcn10_dpp.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,11 @@ void dpp1_set_cursor_position(
480480
if (src_y_offset + cursor_height <= 0)
481481
cur_en = 0; /* not visible beyond top edge*/
482482

483-
REG_UPDATE(CURSOR0_CONTROL,
484-
CUR0_ENABLE, cur_en);
483+
if (dpp_base->pos.cur0_ctl.bits.cur0_enable != cur_en) {
484+
REG_UPDATE(CURSOR0_CONTROL, CUR0_ENABLE, cur_en);
485485

486-
dpp_base->pos.cur0_ctl.bits.cur0_enable = cur_en;
486+
dpp_base->pos.cur0_ctl.bits.cur0_enable = cur_en;
487+
}
487488
}
488489

489490
void dpp1_cnv_set_optional_cursor_attributes(

drivers/gpu/drm/amd/display/dc/dpp/dcn401/dcn401_dpp_cm.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,11 @@ void dpp401_set_cursor_position(
154154
struct dcn401_dpp *dpp = TO_DCN401_DPP(dpp_base);
155155
uint32_t cur_en = pos->enable ? 1 : 0;
156156

157-
REG_UPDATE(CURSOR0_CONTROL, CUR0_ENABLE, cur_en);
157+
if (dpp_base->pos.cur0_ctl.bits.cur0_enable != cur_en) {
158+
REG_UPDATE(CURSOR0_CONTROL, CUR0_ENABLE, cur_en);
158159

159-
dpp_base->pos.cur0_ctl.bits.cur0_enable = cur_en;
160+
dpp_base->pos.cur0_ctl.bits.cur0_enable = cur_en;
161+
}
160162
}
161163

162164
void dpp401_set_optional_cursor_attributes(

drivers/gpu/drm/amd/display/dc/hubp/dcn20/dcn20_hubp.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,11 +1058,13 @@ void hubp2_cursor_set_position(
10581058
if (src_y_offset + cursor_height <= 0)
10591059
cur_en = 0; /* not visible beyond top edge*/
10601060

1061-
if (cur_en && REG_READ(CURSOR_SURFACE_ADDRESS) == 0)
1062-
hubp->funcs->set_cursor_attributes(hubp, &hubp->curs_attr);
1061+
if (hubp->pos.cur_ctl.bits.cur_enable != cur_en) {
1062+
if (cur_en && REG_READ(CURSOR_SURFACE_ADDRESS) == 0)
1063+
hubp->funcs->set_cursor_attributes(hubp, &hubp->curs_attr);
10631064

1064-
REG_UPDATE(CURSOR_CONTROL,
1065+
REG_UPDATE(CURSOR_CONTROL,
10651066
CURSOR_ENABLE, cur_en);
1067+
}
10661068

10671069
REG_SET_2(CURSOR_POSITION, 0,
10681070
CURSOR_X_POSITION, pos->x,

drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,11 +730,13 @@ void hubp401_cursor_set_position(
730730
dc_fixpt_from_int(dst_x_offset),
731731
param->h_scale_ratio));
732732

733-
if (cur_en && REG_READ(CURSOR_SURFACE_ADDRESS) == 0)
734-
hubp->funcs->set_cursor_attributes(hubp, &hubp->curs_attr);
733+
if (hubp->pos.cur_ctl.bits.cur_enable != cur_en) {
734+
if (cur_en && REG_READ(CURSOR_SURFACE_ADDRESS) == 0)
735+
hubp->funcs->set_cursor_attributes(hubp, &hubp->curs_attr);
735736

736-
REG_UPDATE(CURSOR_CONTROL,
737-
CURSOR_ENABLE, cur_en);
737+
REG_UPDATE(CURSOR_CONTROL,
738+
CURSOR_ENABLE, cur_en);
739+
}
738740

739741
REG_SET_2(CURSOR_POSITION, 0,
740742
CURSOR_X_POSITION, x_pos,

0 commit comments

Comments
 (0)