All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: daniel@ffwll.ch, airlied@gmail.com, javierm@redhat.com,
	mripard@kernel.org, maarten.lankhorst@linux.intel.com
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 3/5] drm/fb-helper: Perform damage handling in deferred-I/O helper
Date: Thu, 10 Nov 2022 14:55:17 +0100	[thread overview]
Message-ID: <20221110135519.30029-4-tzimmermann@suse.de> (raw)
In-Reply-To: <20221110135519.30029-1-tzimmermann@suse.de>

Call fb_dirty directly from drm_fb_helper_deferred_io() to avoid the
latency of running the damage worker.

The deferred-I/O helper drm_fb_helper_deferred_io() runs in a worker
thread at regular intervals as part of writing to mmaped framebuffer
memory. It used to schedule the fbdev damage worker to flush the
framebuffer. Changing this to flushing the framebuffer directly avoids
the latency introduced by the damage worker.

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

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index be8ecb5e50b56..ebc44ed1bf4a2 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -644,10 +644,14 @@ static void drm_fb_helper_memory_range_to_clip(struct fb_info *info, off_t off,
 void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagereflist)
 {
 	struct drm_fb_helper *helper = info->par;
+	struct drm_device *dev = helper->dev;
 	unsigned long start, end, min_off, max_off;
 	struct fb_deferred_io_pageref *pageref;
 	struct drm_rect damage_area;
 
+	if (drm_WARN_ON(dev, !helper->funcs->fb_dirty))
+		return;
+
 	min_off = ULONG_MAX;
 	max_off = 0;
 	list_for_each_entry(pageref, pagereflist, list) {
@@ -656,22 +660,26 @@ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagerefli
 		min_off = min(min_off, start);
 		max_off = max(max_off, end);
 	}
-	if (min_off >= max_off)
-		return;
 
-	if (helper->funcs->fb_dirty) {
-		/*
-		 * As we can only track pages, we might reach beyond the end
-		 * of the screen and account for non-existing scanlines. Hence,
-		 * keep the covered memory area within the screen buffer.
-		 */
-		max_off = min(max_off, info->screen_size);
+	/*
+	 * As we can only track pages, we might reach beyond the end
+	 * of the screen and account for non-existing scanlines. Hence,
+	 * keep the covered memory area within the screen buffer.
+	 */
+	max_off = min(max_off, info->screen_size);
 
+	if (min_off < max_off) {
 		drm_fb_helper_memory_range_to_clip(info, min_off, max_off - min_off, &damage_area);
-		drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1,
-				     drm_rect_width(&damage_area),
-				     drm_rect_height(&damage_area));
+		drm_fb_helper_add_damage_clip(helper, damage_area.x1, damage_area.y1,
+					      drm_rect_width(&damage_area),
+					      drm_rect_height(&damage_area));
 	}
+
+	/*
+	 * Flushes all dirty pages from mmap's pageref list and the
+	 * areas that have been written by struct fb_ops callbacks.
+	 */
+	drm_fb_helper_fb_dirty(helper);
 }
 EXPORT_SYMBOL(drm_fb_helper_deferred_io);
 
-- 
2.38.0


  parent reply	other threads:[~2022-11-10 13:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10 13:55 [PATCH 0/5] drm/fb-helper: Remove damage worker Thomas Zimmermann
2022-11-10 13:55 ` [PATCH 1/5] drm/fb-helper: Set damage-clip area in helper Thomas Zimmermann
2022-11-11  9:15   ` Daniel Vetter
2022-11-10 13:55 ` [PATCH 2/5] drm/fb-helper: Move dirty-fb update into helper function Thomas Zimmermann
2022-11-11  9:18   ` Daniel Vetter
2022-11-10 13:55 ` Thomas Zimmermann [this message]
2022-11-11  9:23   ` [PATCH 3/5] drm/fb-helper: Perform damage handling in deferred-I/O helper Daniel Vetter
2022-11-10 13:55 ` [PATCH 4/5] drm/fb-helper: Schedule deferred-I/O worker after writing to framebuffer Thomas Zimmermann
2022-11-10 14:28   ` Daniel Vetter
2022-11-11  9:28   ` Daniel Vetter
2022-11-15 10:05     ` Thomas Zimmermann
2022-11-16  9:21       ` Daniel Vetter
2022-11-10 13:55 ` [PATCH 5/5] drm/fb-helper: Remove damage worker Thomas Zimmermann
2022-11-11  9:42   ` Daniel Vetter
2022-11-15 11:30     ` Thomas Zimmermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221110135519.30029-4-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.