Skip to content

Commit 024771f

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. Cc: Mario Limonciello <mario.limonciello@amd.com> Cc: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org Reviewed-by: Sung Lee <sung.lee@amd.com> Signed-off-by: Aric Cyr <Aric.Cyr@amd.com> Signed-off-by: Wayne Lin <wayne.lin@amd.com> Tested-by: Daniel Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 01130f5 commit 024771f

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
@@ -483,10 +483,11 @@ void dpp1_set_cursor_position(
483483
if (src_y_offset + cursor_height <= 0)
484484
cur_en = 0; /* not visible beyond top edge*/
485485

486-
REG_UPDATE(CURSOR0_CONTROL,
487-
CUR0_ENABLE, cur_en);
486+
if (dpp_base->pos.cur0_ctl.bits.cur0_enable != cur_en) {
487+
REG_UPDATE(CURSOR0_CONTROL, CUR0_ENABLE, cur_en);
488488

489-
dpp_base->pos.cur0_ctl.bits.cur0_enable = cur_en;
489+
dpp_base->pos.cur0_ctl.bits.cur0_enable = cur_en;
490+
}
490491
}
491492

492493
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
@@ -742,11 +742,13 @@ void hubp401_cursor_set_position(
742742
dc_fixpt_from_int(dst_x_offset),
743743
param->h_scale_ratio));
744744

745-
if (cur_en && REG_READ(CURSOR_SURFACE_ADDRESS) == 0)
746-
hubp->funcs->set_cursor_attributes(hubp, &hubp->curs_attr);
745+
if (hubp->pos.cur_ctl.bits.cur_enable != cur_en) {
746+
if (cur_en && REG_READ(CURSOR_SURFACE_ADDRESS) == 0)
747+
hubp->funcs->set_cursor_attributes(hubp, &hubp->curs_attr);
747748

748-
REG_UPDATE(CURSOR_CONTROL,
749-
CURSOR_ENABLE, cur_en);
749+
REG_UPDATE(CURSOR_CONTROL,
750+
CURSOR_ENABLE, cur_en);
751+
}
750752

751753
REG_SET_2(CURSOR_POSITION, 0,
752754
CURSOR_X_POSITION, x_pos,

0 commit comments

Comments
 (0)