AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: Check all enabled planes in dm_check_crtc_cursor
@ 2023-09-12 10:22 Michel Dänzer
  2023-09-20 13:55 ` Alex Deucher
  2023-09-27 18:24 ` Hamza Mahfooz
  0 siblings, 2 replies; 3+ messages in thread
From: Michel Dänzer @ 2023-09-12 10:22 UTC (permalink / raw)
  To: Alex Deucher, Simon Ser; +Cc: Leo Li, Rodrigo Siqueira, Harry Wentland, amd-gfx

From: Michel Dänzer <mdaenzer@redhat.com>

It was only checking planes which had any state changes in the same
commit. However, it also needs to check other enabled planes.

Not doing this meant that a commit might spuriously "succeed", resulting
in the cursor plane displaying with incorrect scaling. See
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3177#note_1824263
for an example.

Fixes: d1bfbe8a3202 ("amd/display: check cursor plane matches underlying plane")
Signed-off-by: Michel Dänzer <mdaenzer@redhat.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 88ba8b66de1f..81c9d39567db 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -9836,14 +9836,24 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,
 	 * blending properties match the underlying planes'.
 	 */
 
-	new_cursor_state = drm_atomic_get_new_plane_state(state, cursor);
-	if (!new_cursor_state || !new_cursor_state->fb)
+	new_cursor_state = drm_atomic_get_plane_state(state, cursor);
+	if (IS_ERR(new_cursor_state))
+		return PTR_ERR(new_cursor_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;
 
+	/* Need to check all enabled planes, even if this commit doesn't change
+	 * their state
+	 */
+	i = drm_atomic_add_affected_planes(state, crtc);
+	if (i)
+		return i;
+
 	for_each_new_plane_in_state_reverse(state, underlying, new_underlying_state, i) {
 		/* Narrow down to non-cursor planes on the same CRTC as the cursor */
 		if (new_underlying_state->crtc != crtc || underlying == crtc->cursor)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/amd/display: Check all enabled planes in dm_check_crtc_cursor
  2023-09-12 10:22 [PATCH] drm/amd/display: Check all enabled planes in dm_check_crtc_cursor Michel Dänzer
@ 2023-09-20 13:55 ` Alex Deucher
  2023-09-27 18:24 ` Hamza Mahfooz
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2023-09-20 13:55 UTC (permalink / raw)
  To: Michel Dänzer
  Cc: Leo Li, Simon Ser, Rodrigo Siqueira, amd-gfx, Alex Deucher,
	Harry Wentland

On Tue, Sep 12, 2023 at 6:22 AM Michel Dänzer <michel@daenzer.net> wrote:
>
> From: Michel Dänzer <mdaenzer@redhat.com>
>
> It was only checking planes which had any state changes in the same
> commit. However, it also needs to check other enabled planes.
>
> Not doing this meant that a commit might spuriously "succeed", resulting
> in the cursor plane displaying with incorrect scaling. See
> https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3177#note_1824263
> for an example.

This looks correct to me, but someone more familiar with this code
should probably double check me.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

>
> Fixes: d1bfbe8a3202 ("amd/display: check cursor plane matches underlying plane")
> Signed-off-by: Michel Dänzer <mdaenzer@redhat.com>
> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 88ba8b66de1f..81c9d39567db 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -9836,14 +9836,24 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,
>          * blending properties match the underlying planes'.
>          */
>
> -       new_cursor_state = drm_atomic_get_new_plane_state(state, cursor);
> -       if (!new_cursor_state || !new_cursor_state->fb)
> +       new_cursor_state = drm_atomic_get_plane_state(state, cursor);
> +       if (IS_ERR(new_cursor_state))
> +               return PTR_ERR(new_cursor_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;
>
> +       /* Need to check all enabled planes, even if this commit doesn't change
> +        * their state
> +        */
> +       i = drm_atomic_add_affected_planes(state, crtc);
> +       if (i)
> +               return i;
> +
>         for_each_new_plane_in_state_reverse(state, underlying, new_underlying_state, i) {
>                 /* Narrow down to non-cursor planes on the same CRTC as the cursor */
>                 if (new_underlying_state->crtc != crtc || underlying == crtc->cursor)
> --
> 2.40.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/amd/display: Check all enabled planes in dm_check_crtc_cursor
  2023-09-12 10:22 [PATCH] drm/amd/display: Check all enabled planes in dm_check_crtc_cursor Michel Dänzer
  2023-09-20 13:55 ` Alex Deucher
@ 2023-09-27 18:24 ` Hamza Mahfooz
  1 sibling, 0 replies; 3+ messages in thread
From: Hamza Mahfooz @ 2023-09-27 18:24 UTC (permalink / raw)
  To: Michel Dänzer, Alex Deucher, Simon Ser
  Cc: Leo Li, Harry Wentland, Rodrigo Siqueira, amd-gfx

On 9/12/23 06:22, Michel Dänzer wrote:
> From: Michel Dänzer <mdaenzer@redhat.com>
> 
> It was only checking planes which had any state changes in the same
> commit. However, it also needs to check other enabled planes.
> 
> Not doing this meant that a commit might spuriously "succeed", resulting
> in the cursor plane displaying with incorrect scaling. See
> https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3177#note_1824263
> for an example.
> 
> Fixes: d1bfbe8a3202 ("amd/display: check cursor plane matches underlying plane")
> Signed-off-by: Michel Dänzer <mdaenzer@redhat.com>

Applied, thanks!

> ---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 ++++++++++++--
>   1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 88ba8b66de1f..81c9d39567db 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -9836,14 +9836,24 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state,
>   	 * blending properties match the underlying planes'.
>   	 */
>   
> -	new_cursor_state = drm_atomic_get_new_plane_state(state, cursor);
> -	if (!new_cursor_state || !new_cursor_state->fb)
> +	new_cursor_state = drm_atomic_get_plane_state(state, cursor);
> +	if (IS_ERR(new_cursor_state))
> +		return PTR_ERR(new_cursor_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;
>   
> +	/* Need to check all enabled planes, even if this commit doesn't change
> +	 * their state
> +	 */
> +	i = drm_atomic_add_affected_planes(state, crtc);
> +	if (i)
> +		return i;
> +
>   	for_each_new_plane_in_state_reverse(state, underlying, new_underlying_state, i) {
>   		/* Narrow down to non-cursor planes on the same CRTC as the cursor */
>   		if (new_underlying_state->crtc != crtc || underlying == crtc->cursor)
-- 
Hamza


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-27 18:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-12 10:22 [PATCH] drm/amd/display: Check all enabled planes in dm_check_crtc_cursor Michel Dänzer
2023-09-20 13:55 ` Alex Deucher
2023-09-27 18:24 ` Hamza Mahfooz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox