diff mbox series

[v2,08/10] drm/fb-helper: Restore damage area upon errors

Message ID 20201120102545.4047-9-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
If the damage handling fails, restore the damage area. The next invocation
of the damage worker will then perform the update.

v2:
	* print a single warning if dirty callback fails (Daniel, Sebastian)
	* update comment

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

Comments

Sam Ravnborg Nov. 23, 2020, 7:26 p.m. UTC | #1
On Fri, Nov 20, 2020 at 11:25:43AM +0100, Thomas Zimmermann wrote:
> If the damage handling fails, restore the damage area. The next invocation
> of the damage worker will then perform the update.
> 
> v2:
> 	* print a single warning if dirty callback fails (Daniel, Sebastian)
> 	* update comment
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index b0bde894bf39..b36d9852cdf7 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -432,11 +432,28 @@  static void drm_fb_helper_damage_work(struct work_struct *work)
 	if (helper->buffer) {
 		ret = drm_fb_helper_damage_blit(helper, &clip_copy);
 		if (drm_WARN_ON_ONCE(dev, ret))
-			return;
+			goto err;
 	}
 
-	if (helper->fb->funcs->dirty)
-		helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, &clip_copy, 1);
+	if (helper->fb->funcs->dirty) {
+		ret = helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, &clip_copy, 1);
+		if (drm_WARN_ON_ONCE(dev, ret))
+			goto err;
+	}
+
+	return;
+
+err:
+	/*
+	 * Restore damage clip rectangle on errors. The next run
+	 * of the damage worker will perform the update.
+	 */
+	spin_lock_irqsave(&helper->damage_lock, flags);
+	clip->x1 = min_t(u32, clip->x1, clip_copy.x1);
+	clip->y1 = min_t(u32, clip->y1, clip_copy.y1);
+	clip->x2 = max_t(u32, clip->x2, clip_copy.x2);
+	clip->y2 = max_t(u32, clip->y2, clip_copy.y2);
+	spin_unlock_irqrestore(&helper->damage_lock, flags);
 }
 
 /**