[PATCH] drm/gud: Merge damage clips in full update mode

Sophie D posted 1 patch 2 weeks, 3 days ago
drivers/gpu/drm/gud/gud_pipe.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
[PATCH] drm/gud: Merge damage clips in full update mode
Posted by Sophie D 2 weeks, 3 days ago
When running in full update mode, previously small updates (such as
moving the mouse across the screen) would cause many full frames to be
generated. This would bog down the bus and lower the effective framerate
significantly - I was seeing a drop from 60 FPS to 2 FPS.

This patch fixes the bug by merging damage clips together.

Fixes: 73cfd166e045 ("drm/gud: Replace simple display pipe with DRM atomic helpers")
Cc: <stable@vger.kernel.org> # 6.18.x
Signed-off-by: Sophie D <patches@scd31.com>
---
 drivers/gpu/drm/gud/gud_pipe.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c
index 5ef887d84..20418bf81 100644
--- a/drivers/gpu/drm/gud/gud_pipe.c
+++ b/drivers/gpu/drm/gud/gud_pipe.c
@@ -647,9 +647,14 @@ void gud_plane_atomic_update(struct drm_plane *plane,
 	if (ret)
 		goto out;
 
-	drm_atomic_helper_damage_iter_init(&iter, old_state, new_state);
-	drm_atomic_for_each_plane_damage(&iter, &damage)
-		gud_fb_handle_damage(gdrm, fb, &shadow_plane_state->data[0], &damage);
+	if (gdrm->flags & GUD_DISPLAY_FLAG_FULL_UPDATE) {
+		if (drm_atomic_helper_damage_merged(old_state, new_state, &damage))
+			gud_fb_handle_damage(gdrm, fb, &shadow_plane_state->data[0], &damage);
+	} else {
+		drm_atomic_helper_damage_iter_init(&iter, old_state, new_state);
+		drm_atomic_for_each_plane_damage(&iter, &damage)
+			gud_fb_handle_damage(gdrm, fb, &shadow_plane_state->data[0], &damage);
+	}
 
 	drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
 
-- 
2.55.0
Re: [PATCH] drm/gud: Merge damage clips in full update mode
Posted by Thomas Zimmermann 2 weeks, 3 days ago
Hi

Am 08.09.26 um 01:08 schrieb Sophie D:
> When running in full update mode, previously small updates (such as
> moving the mouse across the screen) would cause many full frames to be
> generated. This would bog down the bus and lower the effective framerate
> significantly - I was seeing a drop from 60 FPS to 2 FPS.
>
> This patch fixes the bug by merging damage clips together.
>
> Fixes: 73cfd166e045 ("drm/gud: Replace simple display pipe with DRM atomic helpers")
> Cc: <stable@vger.kernel.org> # 6.18.x
> Signed-off-by: Sophie D <patches@scd31.com>
> ---
>   drivers/gpu/drm/gud/gud_pipe.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c
> index 5ef887d84..20418bf81 100644
> --- a/drivers/gpu/drm/gud/gud_pipe.c
> +++ b/drivers/gpu/drm/gud/gud_pipe.c
> @@ -647,9 +647,14 @@ void gud_plane_atomic_update(struct drm_plane *plane,
>   	if (ret)
>   		goto out;
>   
> -	drm_atomic_helper_damage_iter_init(&iter, old_state, new_state);
> -	drm_atomic_for_each_plane_damage(&iter, &damage)
> -		gud_fb_handle_damage(gdrm, fb, &shadow_plane_state->data[0], &damage);
> +	if (gdrm->flags & GUD_DISPLAY_FLAG_FULL_UPDATE) {
> +		if (drm_atomic_helper_damage_merged(old_state, new_state, &damage))
> +			gud_fb_handle_damage(gdrm, fb, &shadow_plane_state->data[0], &damage);
> +	} else {
> +		drm_atomic_helper_damage_iter_init(&iter, old_state, new_state);
> +		drm_atomic_for_each_plane_damage(&iter, &damage)
> +			gud_fb_handle_damage(gdrm, fb, &shadow_plane_state->data[0], &damage);
> +	}

Such state needs to be checked much earlier. Please set 
plane_state->ignore_damage_clips [1] at the end of 
gud_plane_atomic_check [2] if in full-update mode.  The damage iterator 
will then do the right thing.

[1] 
https://elixir.bootlin.com/linux/v7.2.2/source/include/drm/drm_plane.h#L207
[2] 
https://elixir.bootlin.com/linux/v7.2.2/source/drivers/gpu/drm/gud/gud_pipe.c#L569

Best regards
Thomas

>   
>   	drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
>   

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, (HRB 36809, AG Nürnberg)


Re: [PATCH] drm/gud: Merge damage clips in full update mode
Posted by Sophie D 2 weeks, 1 day ago
Hello,

>
> Such state needs to be checked much earlier. Please set 
> plane_state->ignore_damage_clips [1] at the end of 
> gud_plane_atomic_check [2] if in full-update mode.  The damage iterator 
> will then do the right thing.

Thank you for reviewing! I've made this change and have tested it on my
hardware.

Sophie
[PATCH v2] drm/gud: Ignore damage clips in full update mode
Posted by Sophie D 2 weeks, 1 day ago
When running in full update mode, previously small updates (such as
moving the mouse across the screen) would cause many full frames to be
generated. This would bog down the bus and lower the effective framerate
significantly - I was seeing a drop from 60 FPS to 2 FPS.

Set ignore_damage_clips in full update mode so the damage iterator
yields a single full-plane rectangle instead of one per clip.

Fixes: 73cfd166e045 ("drm/gud: Replace simple display pipe with DRM atomic helpers")
Cc: <stable@vger.kernel.org> # 6.18.x
Signed-off-by: Sophie D <patches@scd31.com>
---
v2: set ignore_damage_clips in atomic_check instead of merging clips in
    atomic_update (Thomas Zimmermann)

 drivers/gpu/drm/gud/gud_pipe.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c
index 5ef887d84..3388fdc8e 100644
--- a/drivers/gpu/drm/gud/gud_pipe.c
+++ b/drivers/gpu/drm/gud/gud_pipe.c
@@ -482,6 +482,9 @@ int gud_plane_atomic_check(struct drm_plane *plane,
 	if (!new_plane_state->visible)
 		return 0;
 
+	if (gdrm->flags & GUD_DISPLAY_FLAG_FULL_UPDATE)
+		new_plane_state->ignore_damage_clips = true;
+
 	if (old_plane_state->rotation != new_plane_state->rotation)
 		crtc_state->mode_changed = true;
 
-- 
2.55.0
Re: [PATCH v2] drm/gud: Ignore damage clips in full update mode
Posted by Thomas Zimmermann 2 weeks, 1 day ago

Am 10.09.26 um 03:49 schrieb Sophie D:
> When running in full update mode, previously small updates (such as
> moving the mouse across the screen) would cause many full frames to be
> generated. This would bog down the bus and lower the effective framerate
> significantly - I was seeing a drop from 60 FPS to 2 FPS.
>
> Set ignore_damage_clips in full update mode so the damage iterator
> yields a single full-plane rectangle instead of one per clip.
>
> Fixes: 73cfd166e045 ("drm/gud: Replace simple display pipe with DRM atomic helpers")
> Cc: <stable@vger.kernel.org> # 6.18.x
> Signed-off-by: Sophie D <patches@scd31.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

Thanks for the fix.

> ---
> v2: set ignore_damage_clips in atomic_check instead of merging clips in
>      atomic_update (Thomas Zimmermann)
>
>   drivers/gpu/drm/gud/gud_pipe.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c
> index 5ef887d84..3388fdc8e 100644
> --- a/drivers/gpu/drm/gud/gud_pipe.c
> +++ b/drivers/gpu/drm/gud/gud_pipe.c
> @@ -482,6 +482,9 @@ int gud_plane_atomic_check(struct drm_plane *plane,
>   	if (!new_plane_state->visible)
>   		return 0;
>   
> +	if (gdrm->flags & GUD_DISPLAY_FLAG_FULL_UPDATE)
> +		new_plane_state->ignore_damage_clips = true;
> +
>   	if (old_plane_state->rotation != new_plane_state->rotation)
>   		crtc_state->mode_changed = true;
>   

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, (HRB 36809, AG Nürnberg)


Re: [PATCH v2] drm/gud: Ignore damage clips in full update mode
Posted by Ruben Wauters 1 week, 6 days ago
On Thu, 2026-09-10 at 08:17 +0200, Thomas Zimmermann wrote:
> 
> Am 10.09.26 um 03:49 schrieb Sophie D:
> > When running in full update mode, previously small updates (such as
> > moving the mouse across the screen) would cause many full frames to be
> > generated. This would bog down the bus and lower the effective framerate
> > significantly - I was seeing a drop from 60 FPS to 2 FPS.
> > 
> > Set ignore_damage_clips in full update mode so the damage iterator
> > yields a single full-plane rectangle instead of one per clip.
> > 
> > Fixes: 73cfd166e045 ("drm/gud: Replace simple display pipe with DRM atomic helpers")
> > Cc: <stable@vger.kernel.org> # 6.18.x
> > Signed-off-by: Sophie D <patches@scd31.com>
> 
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Ruben Wauters <rubenru09@aol.com>
> 
> Thanks for the fix.
> 
> > ---
> > v2: set ignore_damage_clips in atomic_check instead of merging clips in
> >      atomic_update (Thomas Zimmermann)
> > 
> >   drivers/gpu/drm/gud/gud_pipe.c | 3 +++
> >   1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c
> > index 5ef887d84..3388fdc8e 100644
> > --- a/drivers/gpu/drm/gud/gud_pipe.c
> > +++ b/drivers/gpu/drm/gud/gud_pipe.c
> > @@ -482,6 +482,9 @@ int gud_plane_atomic_check(struct drm_plane *plane,
> >   	if (!new_plane_state->visible)
> >   		return 0;
> >   
> > +	if (gdrm->flags & GUD_DISPLAY_FLAG_FULL_UPDATE)
> > +		new_plane_state->ignore_damage_clips = true;
> > +
> >   	if (old_plane_state->rotation != new_plane_state->rotation)
> >   		crtc_state->mode_changed = true;
> >