All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@csgraf.de>
To: u-boot@lists.denx.de
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Anatolij Gustschin <agust@denx.de>,
	Simon Glass <sjg@chromium.org>,
	Matthias Brugger <mbrugger@suse.com>, Da Xue <da@libre.computer>
Subject: [PATCH 6/6] video: Only dcache flush damaged lines
Date: Tue,  7 Jun 2022 01:43:36 +0200	[thread overview]
Message-ID: <20220606234336.5021-7-agraf@csgraf.de> (raw)
In-Reply-To: <20220606234336.5021-1-agraf@csgraf.de>

Now that we have a damage area tells us which parts of the frame buffer
actually need updating, let's only dcache flush those on video_sync()
calls. With this optimization in place, frame buffer updates - especially
on large screen such as 4k displays - speed up significantly.

Signed-off-by: Alexander Graf <agraf@csgraf.de>
Reported-by: Da Xue <da@libre.computer>
---
 drivers/video/video-uclass.c | 49 ++++++++++++++++++++++++++++++------
 1 file changed, 42 insertions(+), 7 deletions(-)

diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index 9ac1974670..5661beea38 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -222,6 +222,39 @@ int video_damage(struct udevice *vid, int x, int y, int width, int height)
 }
 #endif
 
+#if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
+static void video_flush_dcache(struct udevice *vid)
+{
+	struct video_priv *priv = dev_get_uclass_priv(vid);
+
+	if (!priv->flush_dcache)
+		return;
+
+#ifdef CONFIG_VIDEO_DAMAGE
+	if (priv->damage.endx && priv->damage.endy) {
+		int lstart = priv->damage.x * VNBYTES(priv->bpix);
+		int lend = priv->damage.endx * VNBYTES(priv->bpix);
+		int y;
+
+		for (y = priv->damage.y; y < priv->damage.endy; y++) {
+			ulong fb = (ulong)priv->fb;
+			ulong start = fb + (y * priv->line_length) + lstart;
+			ulong end = start + lend;
+
+			start = ALIGN_DOWN(start, CONFIG_SYS_CACHELINE_SIZE);
+			end = ALIGN(end, CONFIG_SYS_CACHELINE_SIZE);
+
+			flush_dcache_range(start, end);
+		}
+	}
+#else
+	flush_dcache_range((ulong)priv->fb,
+			   ALIGN((ulong)priv->fb + priv->fb_size,
+				 CONFIG_SYS_CACHELINE_SIZE));
+#endif
+}
+#endif
+
 /* Flush video activity to the caches */
 int video_sync(struct udevice *vid, bool force)
 {
@@ -240,13 +273,7 @@ int video_sync(struct udevice *vid, bool force)
 	 * out whether it exists? For now, ARM is safe.
 	 */
 #if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
-	struct video_priv *priv = dev_get_uclass_priv(vid);
-
-	if (priv->flush_dcache) {
-		flush_dcache_range((ulong)priv->fb,
-				   ALIGN((ulong)priv->fb + priv->fb_size,
-					 CONFIG_SYS_CACHELINE_SIZE));
-	}
+	video_flush_dcache(vid);
 #elif defined(CONFIG_VIDEO_SANDBOX_SDL)
 	struct video_priv *priv = dev_get_uclass_priv(vid);
 	static ulong last_sync;
@@ -256,6 +283,14 @@ int video_sync(struct udevice *vid, bool force)
 		last_sync = get_timer(0);
 	}
 #endif
+
+#ifdef CONFIG_VIDEO_DAMAGE
+	struct video_priv *priv = dev_get_uclass_priv(vid);
+
+	priv->damage.endx = 0;
+	priv->damage.endy = 0;
+#endif
+
 	return 0;
 }
 
-- 
2.32.1 (Apple Git-133)


  parent reply	other threads:[~2022-06-06 23:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-06 23:43 [PATCH 0/6] Add video damage tracking Alexander Graf
2022-06-06 23:43 ` [PATCH 1/6] dm: video: Add damage tracking API Alexander Graf
2022-06-06 23:43 ` [PATCH 2/6] dm: video: Add damage notification on display clear Alexander Graf
2022-06-06 23:43 ` [PATCH 3/6] vidconsole: Add damage notifications to all vidconsole drivers Alexander Graf
2022-06-06 23:43 ` [PATCH 4/6] video: Add damage notification on bmp display Alexander Graf
2022-06-06 23:43 ` [PATCH 5/6] efi_loader: GOP: Add damage notification on BLT Alexander Graf
2022-06-07  7:12   ` Heinrich Schuchardt
2022-06-09 14:55     ` Alexander Graf
2022-06-06 23:43 ` Alexander Graf [this message]
2022-06-07  8:00   ` [PATCH 6/6] video: Only dcache flush damaged lines Heinrich Schuchardt
2022-06-09 14:56     ` Alexander Graf
2022-06-07  8:28 ` [PATCH 0/6] Add video damage tracking Heinrich Schuchardt
2022-06-09 19:04   ` Alexander Graf
2022-06-09 19:26     ` Mark Kettenis
2022-06-09 20:32     ` Heinrich Schuchardt
2022-06-09 21:09       ` Alexander Graf

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=20220606234336.5021-7-agraf@csgraf.de \
    --to=agraf@csgraf.de \
    --cc=agust@denx.de \
    --cc=da@libre.computer \
    --cc=mbrugger@suse.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /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.