[PATCH v2 09/11] video: lcdif: drain write-combine framebuffer in fb_damage

Johannes Schneider <[email protected]>
Newsgroups org.infradead.lists.barebox
Message-ID <20260604065006.2933142-10-johannes.schneider@leica-geosystems.com>
From: Thomas Haemmerle <[email protected]>

The framebuffer is allocated Normal Non-Cacheable (write-combine).
After the splash command's memcpy() from a cached shadow buffer into
the hardware framebuffer (see gu_screen_blit()), stores may still
reside in the CPU write-combine buffer when scanout next fetches --
visible as partial / corrupted rendering at the bottom of the image.

dsb() alone is not sufficient: it orders subsequent instructions
against the outstanding writes but doesn't actively drain the WC
buffer to memory.  A readback of any byte inside the WC region does,
since the load cannot complete until prior stores to the buffer have
been retired.

Wire lcdif_fb_damage to do that readback after each blit.  Keep
fb_flush bound to lcdif_crtc_atomic_flush so the SHADOW_LOAD_EN
re-latch still fires on fb_close / fbtest paths.

Suggested-by: Lucas Stach <[email protected]>
Signed-off-by: Thomas Haemmerle <[email protected]>
---
 drivers/video/lcdif_kms.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/video/lcdif_kms.c b/drivers/video/lcdif_kms.c
index e3d1985dc9..57ca92b4be 100644
--- a/drivers/video/lcdif_kms.c
+++ b/drivers/video/lcdif_kms.c
@@ -396,10 +396,17 @@ static void lcdif_disable_fb_controller(struct fb_info *info)
 	lcdif_disable_controller(lcdif);
 }
 
+static void lcdif_fb_damage(struct fb_info *info, const struct fb_rect *rect)
+{
+	/* readback drains the write-combine buffer (dsb() doesn't) */
+	(void)*(volatile u8 *)info->screen_base;
+}
+
 static struct fb_ops lcdif_fb_ops = {
 	.fb_enable = lcdif_enable_fb_controller,
 	.fb_disable = lcdif_disable_fb_controller,
 	.fb_flush = lcdif_crtc_atomic_flush,
+	.fb_damage = lcdif_fb_damage,
 };
 
 /* -----------------------------------------------------------------------------
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.