diff mbox series

[v2,05/10] drm/fb-helper: Return early in dirty worker

Message ID 20201120102545.4047-6-tzimmermann@suse.de (mailing list archive)
State New, archived
Headers show
Series drm/fb-helper: Various fixes and cleanups | expand

Commit Message

Thomas Zimmermann Nov. 20, 2020, 10:25 a.m. UTC
Returning early in the dirty worker if no update is required makes the
code more readable. No functional changes are made.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/drm_fb_helper.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

Comments

Sam Ravnborg Nov. 23, 2020, 7:23 p.m. UTC | #1
On Fri, Nov 20, 2020 at 11:25:40AM +0100, Thomas Zimmermann wrote:
> Returning early in the dirty worker if no update is required makes the
> code more readable. No functional changes are made.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>

It is a damage worker (both subject and changelog).

Reviewed-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/drm_fb_helper.c | 31 +++++++++++++++----------------
>  1 file changed, 15 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 87d4759de04a..c9018ffff5f9 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -407,24 +407,23 @@ static void drm_fb_helper_damage_work(struct work_struct *work)
>  	clip->x2 = clip->y2 = 0;
>  	spin_unlock_irqrestore(&helper->damage_lock, flags);
>  
> -	/* call dirty callback only when it has been really touched */
> -	if (clip_copy.x1 < clip_copy.x2 && clip_copy.y1 < clip_copy.y2) {
> -
> -		/* Generic fbdev uses a shadow buffer */
> -		if (helper->buffer) {
> -			ret = drm_client_buffer_vmap(helper->buffer, &map);
> -			if (ret)
> -				return;
> -			drm_fb_helper_damage_blit_real(helper, &clip_copy, &map);
> -		}
> -
> -		if (helper->fb->funcs->dirty)
> -			helper->fb->funcs->dirty(helper->fb, NULL, 0, 0,
> -						 &clip_copy, 1);
> +	/* Call damage handlers only if necessary */
> +	if (!(clip_copy.x1 < clip_copy.x2 && clip_copy.y1 < clip_copy.y2))
> +		return;
>  
> -		if (helper->buffer)
> -			drm_client_buffer_vunmap(helper->buffer);
> +	/* Generic fbdev uses a shadow buffer */
> +	if (helper->buffer) {
> +		ret = drm_client_buffer_vmap(helper->buffer, &map);
> +		if (ret)
> +			return;
> +		drm_fb_helper_damage_blit_real(helper, &clip_copy, &map);
>  	}
> +
> +	if (helper->fb->funcs->dirty)
> +		helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, &clip_copy, 1);
> +
> +	if (helper->buffer)
> +		drm_client_buffer_vunmap(helper->buffer);
>  }
>  
>  /**
> -- 
> 2.29.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann Nov. 24, 2020, 9:54 a.m. UTC | #2
Hi

Am 23.11.20 um 20:23 schrieb Sam Ravnborg:
> On Fri, Nov 20, 2020 at 11:25:40AM +0100, Thomas Zimmermann wrote:
>> Returning early in the dirty worker if no update is required makes the
>> code more readable. No functional changes are made.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> 
> It is a damage worker (both subject and changelog).

I changed this before pushing the branches. Thanks!

Best regards
Thomas

> 
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> 
>> ---
>>   drivers/gpu/drm/drm_fb_helper.c | 31 +++++++++++++++----------------
>>   1 file changed, 15 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
>> index 87d4759de04a..c9018ffff5f9 100644
>> --- a/drivers/gpu/drm/drm_fb_helper.c
>> +++ b/drivers/gpu/drm/drm_fb_helper.c
>> @@ -407,24 +407,23 @@ static void drm_fb_helper_damage_work(struct work_struct *work)
>>   	clip->x2 = clip->y2 = 0;
>>   	spin_unlock_irqrestore(&helper->damage_lock, flags);
>>   
>> -	/* call dirty callback only when it has been really touched */
>> -	if (clip_copy.x1 < clip_copy.x2 && clip_copy.y1 < clip_copy.y2) {
>> -
>> -		/* Generic fbdev uses a shadow buffer */
>> -		if (helper->buffer) {
>> -			ret = drm_client_buffer_vmap(helper->buffer, &map);
>> -			if (ret)
>> -				return;
>> -			drm_fb_helper_damage_blit_real(helper, &clip_copy, &map);
>> -		}
>> -
>> -		if (helper->fb->funcs->dirty)
>> -			helper->fb->funcs->dirty(helper->fb, NULL, 0, 0,
>> -						 &clip_copy, 1);
>> +	/* Call damage handlers only if necessary */
>> +	if (!(clip_copy.x1 < clip_copy.x2 && clip_copy.y1 < clip_copy.y2))
>> +		return;
>>   
>> -		if (helper->buffer)
>> -			drm_client_buffer_vunmap(helper->buffer);
>> +	/* Generic fbdev uses a shadow buffer */
>> +	if (helper->buffer) {
>> +		ret = drm_client_buffer_vmap(helper->buffer, &map);
>> +		if (ret)
>> +			return;
>> +		drm_fb_helper_damage_blit_real(helper, &clip_copy, &map);
>>   	}
>> +
>> +	if (helper->fb->funcs->dirty)
>> +		helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, &clip_copy, 1);
>> +
>> +	if (helper->buffer)
>> +		drm_client_buffer_vunmap(helper->buffer);
>>   }
>>   
>>   /**
>> -- 
>> 2.29.2
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 87d4759de04a..c9018ffff5f9 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -407,24 +407,23 @@  static void drm_fb_helper_damage_work(struct work_struct *work)
 	clip->x2 = clip->y2 = 0;
 	spin_unlock_irqrestore(&helper->damage_lock, flags);
 
-	/* call dirty callback only when it has been really touched */
-	if (clip_copy.x1 < clip_copy.x2 && clip_copy.y1 < clip_copy.y2) {
-
-		/* Generic fbdev uses a shadow buffer */
-		if (helper->buffer) {
-			ret = drm_client_buffer_vmap(helper->buffer, &map);
-			if (ret)
-				return;
-			drm_fb_helper_damage_blit_real(helper, &clip_copy, &map);
-		}
-
-		if (helper->fb->funcs->dirty)
-			helper->fb->funcs->dirty(helper->fb, NULL, 0, 0,
-						 &clip_copy, 1);
+	/* Call damage handlers only if necessary */
+	if (!(clip_copy.x1 < clip_copy.x2 && clip_copy.y1 < clip_copy.y2))
+		return;
 
-		if (helper->buffer)
-			drm_client_buffer_vunmap(helper->buffer);
+	/* Generic fbdev uses a shadow buffer */
+	if (helper->buffer) {
+		ret = drm_client_buffer_vmap(helper->buffer, &map);
+		if (ret)
+			return;
+		drm_fb_helper_damage_blit_real(helper, &clip_copy, &map);
 	}
+
+	if (helper->fb->funcs->dirty)
+		helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, &clip_copy, 1);
+
+	if (helper->buffer)
+		drm_client_buffer_vunmap(helper->buffer);
 }
 
 /**