drm/amd/display: Refactor dm_get_plane_scale helper
Subsystems (3)
PATCH 1/2 drm/amd/display: Refactor dm_get_plane_scale helper
From: Michel Dänzer <[email protected]>
Cleanup, no functional change intended.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +14 -9
@@ -9892,6 +9892,17 @@ static void dm_get_oriented_plane_size(struct drm_plane_state *plane_state, } } +static void +dm_get_plane_scale (struct drm_plane_state *plane_state, +int *out_plane_scale_w,int *out_plane_scale_h) +{ +int plane_src_w, plane_src_h; + +dm_get_oriented_plane_size (plane_state, &plane_src_w, &plane_src_h); + *out_plane_scale_w = plane_state->crtc_w *1000 / plane_src_w; + *out_plane_scale_h = plane_state->crtc_h *1000 / plane_src_h; +} +static int dm_check_crtc_cursor (struct drm_atomic_state *state,struct drm_crtc *crtc,struct drm_crtc_state *new_crtc_state)
@@ -9900,8 +9911,6 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,struct drm_plane_state *new_cursor_state, *new_underlying_state;int i;int cursor_scale_w, cursor_scale_h, underlying_scale_w, underlying_scale_h; -int cursor_src_w, cursor_src_h; -int underlying_src_w, underlying_src_h;/* On DCE and DCN there is no dedicated hardware cursor plane. We get a * cursor per pipe but it's going to inherit the scaling and
@@ -9916,9 +9925,7 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,if (!new_cursor_state->fb)return 0 ; -dm_get_oriented_plane_size (new_cursor_state, &cursor_src_w, &cursor_src_h); - cursor_scale_w = new_cursor_state->crtc_w *1000 / cursor_src_w; - cursor_scale_h = new_cursor_state->crtc_h *1000 / cursor_src_h; +dm_get_plane_scale (new_cursor_state, &cursor_scale_w, &cursor_scale_h);/* Need to check all enabled planes, even if this commit doesn't change * their state
@@ -9936,10 +9943,8 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,if (!new_underlying_state->fb)continue ; -dm_get_oriented_plane_size (new_underlying_state, - &underlying_src_w, &underlying_src_h); - underlying_scale_w = new_underlying_state->crtc_w *1000 / underlying_src_w; - underlying_scale_h = new_underlying_state->crtc_h *1000 / underlying_src_h; +dm_get_plane_scale (new_underlying_state, + &underlying_scale_w, &underlying_scale_h);if (cursor_scale_w != underlying_scale_w || cursor_scale_h != underlying_scale_h) {
Signature · 1 line
2.42.0
PATCH 2/2 drm/amd/display: Bail from dm_check_crtc_cursor if no relevant change
From: Michel Dänzer <[email protected]>
If no plane was newly enabled or changed scaling, there can be no new scaling mismatch with the cursor plane.
By not pulling non-cursor plane states into all atomic commits while the cursor plane is enabled, this avoids synchronizing all cursor plane changes to vertical blank, which caused the following IGT tests to fail:
kms_cursor_legacy@cursor-vs-flip.*
kms_cursor_legacy@flip-vs-cursor.*
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +32 -1
@@ -9907,10 +9907,12 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,struct drm_crtc *crtc, struct drm_crtc_state *new_crtc_state) { - struct drm_plane *cursor = crtc->cursor, *underlying; + struct drm_plane *cursor = crtc->cursor, *plane, *underlying; +struct drm_plane_state *old_plane_state, *new_plane_state;struct drm_plane_state *new_cursor_state, *new_underlying_state;int i;int cursor_scale_w, cursor_scale_h, underlying_scale_w, underlying_scale_h; +bool any_relevant_change = false;/* On DCE and DCN there is no dedicated hardware cursor plane. We get a * cursor per pipe but it's going to inherit the scaling and
@@ -9918,6 +9920,35 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,* blending properties match the underlying planes'. */ +/* If no plane was enabled or changed scaling, no need to check again */ +for_each_oldnew_plane_in_state (state, plane, old_plane_state, new_plane_state, i) { +int new_scale_w, new_scale_h, old_scale_w, old_scale_h; + +if (!new_plane_state || !new_plane_state->fb || new_plane_state->crtc != crtc) +continue ; + +if (!old_plane_state || !old_plane_state->fb || old_plane_state->crtc != crtc) { + any_relevant_change = true; +break ; + } + +if (new_plane_state->fb == old_plane_state->fb && + new_plane_state->crtc_w == old_plane_state->crtc_w && + new_plane_state->crtc_h == old_plane_state->crtc_h) +continue ; + +dm_get_plane_scale (new_plane_state, &new_scale_w, &new_scale_h); +dm_get_plane_scale (old_plane_state, &old_scale_w, &old_scale_h); + +if (new_scale_w != old_scale_w || new_scale_h != old_scale_h) { + any_relevant_change = true; +break ; + } + } + +if (!any_relevant_change) +return 0 ; + new_cursor_state =drm_atomic_get_plane_state (state, cursor);if (IS_ERR (new_cursor_state))return PTR_ERR (new_cursor_state);
Signature · 1 line
2.42.0
Quoted 5 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
Cleanup, no functional change intended.
Signed-off-by Michel Dänzer <[email protected]>
Seems like this series does indeed fix the issue, so I have applied it instead of the revert.
Quoted 59 lines
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +14
-9@@ -9892,6 +9892,17 @@ static void dm_get_oriented_plane_size(struct drm_plane_state *plane_state, } } +static void +dm_get_plane_scale (struct drm_plane_state *plane_state, +int *out_plane_scale_w,int *out_plane_scale_h) +{ +int plane_src_w, plane_src_h; + +dm_get_oriented_plane_size (plane_state, &plane_src_w, &plane_src_h); + *out_plane_scale_w = plane_state->crtc_w *1000 / plane_src_w; + *out_plane_scale_h = plane_state->crtc_h *1000 / plane_src_h; +} +static int dm_check_crtc_cursor (struct drm_atomic_state *state,struct drm_crtc *crtc,struct drm_crtc_state *new_crtc_state)@@ -9900,8 +9911,6 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,struct drm_plane_state *new_cursor_state, *new_underlying_state;int i;int cursor_scale_w, cursor_scale_h, underlying_scale_w, underlying_scale_h; -int cursor_src_w, cursor_src_h; -int underlying_src_w, underlying_src_h;/* On DCE and DCN there is no dedicated hardware cursor plane. We get a * cursor per pipe but it's going to inherit the scaling and @@ -9916,9 +9925,7 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,if (!new_cursor_state->fb)return 0 ; -dm_get_oriented_plane_size (new_cursor_state, &cursor_src_w, &cursor_src_h); - cursor_scale_w = new_cursor_state->crtc_w *1000 / cursor_src_w; - cursor_scale_h = new_cursor_state->crtc_h *1000 / cursor_src_h; +dm_get_plane_scale (new_cursor_state, &cursor_scale_w, &cursor_scale_h);/* Need to check all enabled planes, even if this commit doesn't change * their state @@ -9936,10 +9943,8 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,if (!new_underlying_state->fb)continue ; -dm_get_oriented_plane_size (new_underlying_state, - &underlying_src_w, &underlying_src_h); - underlying_scale_w = new_underlying_state->crtc_w *1000 / underlying_src_w; - underlying_scale_h = new_underlying_state->crtc_h *1000 / underlying_src_h; +dm_get_plane_scale (new_underlying_state, + &underlying_scale_w, &underlying_scale_h);if (cursor_scale_w != underlying_scale_w || cursor_scale_h != underlying_scale_h) {
Signature · 1 line
Hamza