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: Daniel Vetter <daniel.vetter@ffwll.ch>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	dri-devel@lists.freedesktop.org
Subject: [PATCH v2 5/6] drm/fb-helper: Schedule deferred-I/O worker after writing to framebuffer
Date: Tue, 15 Nov 2022 12:58:18 +0100	[thread overview]
Message-ID: <20221115115819.23088-6-tzimmermann@suse.de> (raw)
In-Reply-To: <20221115115819.23088-1-tzimmermann@suse.de>

Schedule the deferred-I/O worker instead of the damage worker after
writing to the fbdev framebuffer. The deferred-I/O worker then performs
the dirty-fb update. The fbdev emulation will initialize deferred I/O
for all drivers that require damage updates. It is therefore a valid
assumption that the deferred-I/O worker is present.

It would be possible to perform the damage handling directly from within
the write operation. But doing this could increase the overhead of the
write or interfere with a concurrently scheduled deferred-I/O worker.
Instead, scheduling the deferred-I/O worker with its regular delay of
50 ms removes load off the write operation and allows the deferred-I/O
worker to handle multiple write operations that arrived during the delay
time window.

v2:
	* keep drm_fb_helper_damage() (Daniel)
	* use fb_deferred_io_schedule_flush() (Daniel)
	* clarify comments (Daniel)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_fb_helper.c     | 10 +++++++++-
 drivers/video/fbdev/core/fb_defio.c | 16 ++++++++++++++++
 include/linux/fb.h                  |  1 +
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index cdbf03e941b2b..fbb9088f7defc 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -599,9 +599,17 @@ static void drm_fb_helper_add_damage_clip(struct drm_fb_helper *helper, u32 x, u
 static void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y,
 				 u32 width, u32 height)
 {
+	struct drm_device *dev = helper->dev;
+	struct fb_info *info = helper->info;
+
 	drm_fb_helper_add_damage_clip(helper, x, y, width, height);
 
-	schedule_work(&helper->damage_work);
+	/*
+	 * The current fbdev emulation only flushes buffers if a damage
+	 * update is necessary. And we can assume that deferred I/O has
+	 * been enabled as damage updates require deferred I/O for mmap.
+	 */
+	fb_deferred_io_schedule_flush(info);
 }
 
 /*
diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c
index c730253ab85ce..dec678f72a42f 100644
--- a/drivers/video/fbdev/core/fb_defio.c
+++ b/drivers/video/fbdev/core/fb_defio.c
@@ -332,3 +332,19 @@ void fb_deferred_io_cleanup(struct fb_info *info)
 	mutex_destroy(&fbdefio->lock);
 }
 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
+
+void fb_deferred_io_schedule_flush(struct fb_info *info)
+{
+	struct fb_deferred_io *fbdefio = info->fbdefio;
+
+	if (WARN_ON_ONCE(!fbdefio))
+		return; /* bug in driver logic */
+
+	/*
+	 * There's no requirement from callers to schedule the
+	 * flush immediately. Rather schedule the worker with a
+	 * delay and let a few more writes pile up.
+	 */
+	schedule_delayed_work(&info->deferred_work, fbdefio->delay);
+}
+EXPORT_SYMBOL_GPL(fb_deferred_io_schedule_flush);
diff --git a/include/linux/fb.h b/include/linux/fb.h
index bcb8658f5b64d..172f271520c78 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -663,6 +663,7 @@ extern void fb_deferred_io_open(struct fb_info *info,
 				struct inode *inode,
 				struct file *file);
 extern void fb_deferred_io_cleanup(struct fb_info *info);
+extern void fb_deferred_io_schedule_flush(struct fb_info *info);
 extern int fb_deferred_io_fsync(struct file *file, loff_t start,
 				loff_t end, int datasync);
 
-- 
2.38.1


  parent reply	other threads:[~2022-11-15 11:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-15 11:58 [PATCH v2 0/6] drm/fb-helper: Remove damage worker Thomas Zimmermann
2022-11-15 11:58 ` [PATCH v2 1/6] drm/fb-helper: Set damage-clip area in helper Thomas Zimmermann
2022-11-15 11:58 ` [PATCH v2 2/6] drm/fb-helper: Move dirty-fb update into helper function Thomas Zimmermann
2022-11-15 11:58 ` [PATCH v2 3/6] drm/fb-helper: Remove test for fb_dirty callback from deferred-I/O helper Thomas Zimmermann
2022-11-15 11:58 ` [PATCH v2 4/6] drm/fb-helper: Perform damage handling in " Thomas Zimmermann
2022-11-15 11:58 ` Thomas Zimmermann [this message]
2022-11-15 20:35   ` [PATCH v2 5/6] drm/fb-helper: Schedule deferred-I/O worker after writing to framebuffer kernel test robot
2022-11-15 20:35     ` kernel test robot
2022-11-16  8:48     ` Thomas Zimmermann
     [not found]   ` <CGME20221117125800eucas1p29bc0adbe623ca0c42e903e771bf68b33@eucas1p2.samsung.com>
2022-11-17 12:57     ` [v2,5/6] " Marek Szyprowski
2022-11-17 12:57       ` Marek Szyprowski
2022-11-17 16:07       ` Thomas Zimmermann
2022-11-17 16:07         ` Thomas Zimmermann
2022-11-17 17:21         ` Marek Szyprowski
2022-11-17 17:21           ` Marek Szyprowski
2022-12-05 14:10           ` Marek Szyprowski
2022-12-05 14:10             ` Marek Szyprowski
2022-11-15 11:58 ` [PATCH v2 6/6] drm/fb-helper: Remove damage worker Thomas Zimmermann
2022-11-23  8:28 [PATCH v2 5/6] drm/fb-helper: Schedule deferred-I/O worker after writing to framebuffer Biju Das
2022-11-23  8:28 ` Biju Das
2022-11-23  8:41 ` 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=20221115115819.23088-6-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --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.