diff mbox series

[2/2] drm/fbdev: Move damage clip check to higher level

Message ID 20221221111902.1742095-3-jouni.hogander@intel.com (mailing list archive)
State New, archived
Headers show
Series Fixes for intel fb helper | expand

Commit Message

Hogander, Jouni Dec. 21, 2022, 11:19 a.m. UTC
Checking if damage clip is valid is common to all fb helpers.
Makes more sense to check it in higher level than adding into
all helpers.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
---
 drivers/gpu/drm/drm_fb_helper.c     | 4 ++++
 drivers/gpu/drm/drm_fbdev_generic.c | 4 ----
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Thomas Zimmermann Dec. 21, 2022, 12:05 p.m. UTC | #1
Hi

Am 21.12.22 um 12:19 schrieb Jouni Högander:
> Checking if damage clip is valid is common to all fb helpers.
> Makes more sense to check it in higher level than adding into
> all helpers.

It was a deliberate decision to separate damage clipping and dirty 
updates; done in [1]. Clipping is an optional hint in our regular damage 
handling via drm_framebuffer_funcs.dirty. The fb_dirty callback now 
follows that semantics.

I mentioned that it would be better to implement those fb_ops callbacks 
for i915. But if you go with fb_dirty, please implement the clipping 
test in your callback.

Best regards
Thomas

[1] https://patchwork.freedesktop.org/patch/509958/?series=109943&rev=3

> 
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
> ---
>   drivers/gpu/drm/drm_fb_helper.c     | 4 ++++
>   drivers/gpu/drm/drm_fbdev_generic.c | 4 ----
>   2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index b3a731b9170a..78c889dbc610 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -384,6 +384,10 @@ static void drm_fb_helper_fb_dirty(struct drm_fb_helper *helper)
>   	clip->x2 = clip->y2 = 0;
>   	spin_unlock_irqrestore(&helper->damage_lock, flags);
>   
> +	/* Call damage handlers only if necessary */
> +	if (!(clip_copy.x1 < clip_copy.x2 && clip_copy.y1 < clip_copy.y2))
> +		return;
> +
>   	ret = helper->funcs->fb_dirty(helper, &clip_copy);
>   	if (ret)
>   		goto err;
> diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c
> index 0a4c160e0e58..6c6bb0dd2ea8 100644
> --- a/drivers/gpu/drm/drm_fbdev_generic.c
> +++ b/drivers/gpu/drm/drm_fbdev_generic.c
> @@ -334,10 +334,6 @@ static int drm_fbdev_fb_dirty(struct drm_fb_helper *helper, struct drm_clip_rect
>   	if (!drm_fbdev_use_shadow_fb(helper))
>   		return 0;
>   
> -	/* Call damage handlers only if necessary */
> -	if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2))
> -		return 0;
> -
>   	if (helper->buffer) {
>   		ret = drm_fbdev_damage_blit(helper, clip);
>   		if (drm_WARN_ONCE(dev, ret, "Damage blitter failed: ret=%d\n", ret))
Hogander, Jouni Dec. 21, 2022, 3:41 p.m. UTC | #2
On Wed, 2022-12-21 at 13:05 +0100, Thomas Zimmermann wrote:
> Hi
> 
> Am 21.12.22 um 12:19 schrieb Jouni Högander:
> > Checking if damage clip is valid is common to all fb helpers.
> > Makes more sense to check it in higher level than adding into
> > all helpers.
> 
> It was a deliberate decision to separate damage clipping and dirty 
> updates; done in [1]. Clipping is an optional hint in our regular
> damage 
> handling via drm_framebuffer_funcs.dirty. The fb_dirty callback now 
> follows that semantics.
> 
> I mentioned that it would be better to implement those fb_ops
> callbacks 
> for i915. But if you go with fb_dirty, please implement the clipping 
> test in your callback.

Thank you for your comments. I have sent a new version. Please check.

> 
> Best regards
> Thomas
> 
> [1]
> https://patchwork.freedesktop.org/patch/509958/?series=109943&rev=3
> 
> > 
> > Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > Cc: Jani Nikula <jani.nikula@intel.com>
> > Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
> > ---
> >   drivers/gpu/drm/drm_fb_helper.c     | 4 ++++
> >   drivers/gpu/drm/drm_fbdev_generic.c | 4 ----
> >   2 files changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_fb_helper.c
> > b/drivers/gpu/drm/drm_fb_helper.c
> > index b3a731b9170a..78c889dbc610 100644
> > --- a/drivers/gpu/drm/drm_fb_helper.c
> > +++ b/drivers/gpu/drm/drm_fb_helper.c
> > @@ -384,6 +384,10 @@ static void drm_fb_helper_fb_dirty(struct
> > drm_fb_helper *helper)
> >         clip->x2 = clip->y2 = 0;
> >         spin_unlock_irqrestore(&helper->damage_lock, flags);
> >   
> > +       /* Call damage handlers only if necessary */
> > +       if (!(clip_copy.x1 < clip_copy.x2 && clip_copy.y1 <
> > clip_copy.y2))
> > +               return;
> > +
> >         ret = helper->funcs->fb_dirty(helper, &clip_copy);
> >         if (ret)
> >                 goto err;
> > diff --git a/drivers/gpu/drm/drm_fbdev_generic.c
> > b/drivers/gpu/drm/drm_fbdev_generic.c
> > index 0a4c160e0e58..6c6bb0dd2ea8 100644
> > --- a/drivers/gpu/drm/drm_fbdev_generic.c
> > +++ b/drivers/gpu/drm/drm_fbdev_generic.c
> > @@ -334,10 +334,6 @@ static int drm_fbdev_fb_dirty(struct
> > drm_fb_helper *helper, struct drm_clip_rect
> >         if (!drm_fbdev_use_shadow_fb(helper))
> >                 return 0;
> >   
> > -       /* Call damage handlers only if necessary */
> > -       if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2))
> > -               return 0;
> > -
> >         if (helper->buffer) {
> >                 ret = drm_fbdev_damage_blit(helper, clip);
> >                 if (drm_WARN_ONCE(dev, ret, "Damage blitter failed:
> > ret=%d\n", ret))
> 
> -- 
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Ivo Totev
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index b3a731b9170a..78c889dbc610 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -384,6 +384,10 @@  static void drm_fb_helper_fb_dirty(struct drm_fb_helper *helper)
 	clip->x2 = clip->y2 = 0;
 	spin_unlock_irqrestore(&helper->damage_lock, flags);
 
+	/* Call damage handlers only if necessary */
+	if (!(clip_copy.x1 < clip_copy.x2 && clip_copy.y1 < clip_copy.y2))
+		return;
+
 	ret = helper->funcs->fb_dirty(helper, &clip_copy);
 	if (ret)
 		goto err;
diff --git a/drivers/gpu/drm/drm_fbdev_generic.c b/drivers/gpu/drm/drm_fbdev_generic.c
index 0a4c160e0e58..6c6bb0dd2ea8 100644
--- a/drivers/gpu/drm/drm_fbdev_generic.c
+++ b/drivers/gpu/drm/drm_fbdev_generic.c
@@ -334,10 +334,6 @@  static int drm_fbdev_fb_dirty(struct drm_fb_helper *helper, struct drm_clip_rect
 	if (!drm_fbdev_use_shadow_fb(helper))
 		return 0;
 
-	/* Call damage handlers only if necessary */
-	if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2))
-		return 0;
-
 	if (helper->buffer) {
 		ret = drm_fbdev_damage_blit(helper, clip);
 		if (drm_WARN_ONCE(dev, ret, "Damage blitter failed: ret=%d\n", ret))