diff mbox series

[v2] video: console: clear rows stride-aware in set_row

Message ID 20261004-b4-framebuffer-stride-fix-v2-1-923af6708491@protonmail.com
State Accepted
Commit e16958bc076d842df20c8ea96d9fbec479e54459
Delegated to: Anatolij Gustschin
Headers show
Series [v2] video: console: clear rows stride-aware in set_row | expand

Commit Message

Petr Hodina via B4 Relay Oct. 4, 2026, 7:47 p.m. UTC
From: Petr Hodina <petr.hodina@protonmail.com>

console_set_row() and console_set_row_2() clear a row with a single
contiguous fill assuming line_length == xsize * pbytes. A stride-padded
framebuffer inherited from a prior boot stage (e.g. via
simple-framebuffer) breaks that assumption leaving stale pixels after
scroll.

Use video_fill_part() which already steps per scanline by
line_length.

Signed-off-by: Petr Hodina <petr.hodina@protonmail.com>
---
Found while testing the scrollback viewer against a stride-padded
splash framebuffer inherited via simple-framebuffer.

console_set_row() and console_set_row_2() clear rows assuming
line_length == xsize * pbytes. Fix them to step per scanline by
line_length instead.
---
Changes in v2:
- Switch to video_fill_part() which already handles stride
- Link to v1: https://patch.msgid.link/20261002-b4-framebuffer-stride-fix-v1-1-4a8498416b01@protonmail.com

To: u-boot@lists.u-boot-project.org
Cc: Anatolij Gustschin <ag.dev.uboot@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Petr Hodina <petr.hodina@protonmail.com>
---
 drivers/video/console_normal.c | 26 +++-----------------------
 drivers/video/console_rotate.c | 23 ++++-------------------
 2 files changed, 7 insertions(+), 42 deletions(-)


---
base-commit: ece349ade2973e220f524ce59e59711cc919263f
change-id: 20261002-b4-framebuffer-stride-fix-67c1d7d981e9

Best regards,
--  
Petr Hodina <petr.hodina@protonmail.com>

Comments

Simon Glass Oct. 12, 2026, 2:02 p.m. UTC | #1
On 2026-10-04T19:47:24, Petr Hodina via B4 Relay
<devnull+petr.hodina.protonmail.com@kernel.org> wrote:
> video: console: clear rows stride-aware in set_row
>
> console_set_row() and console_set_row_2() clear a row with a single
> contiguous fill assuming line_length == xsize * pbytes. A stride-padded
> framebuffer inherited from a prior boot stage (e.g. via
> simple-framebuffer) breaks that assumption leaving stale pixels after
> scroll.
>
> Use video_fill_part() which already steps per scanline by
> line_length.
>
> Signed-off-by: Petr Hodina <petr.hodina@protonmail.com>
>
> drivers/video/console_normal.c | 26 +++-----------------------
>  drivers/video/console_rotate.c | 23 ++++-------------------
>  2 files changed, 7 insertions(+), 42 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini Oct. 22, 2026, 2:19 p.m. UTC | #2
On Sun, 04 Oct 2026 21:47:24 +0200, Petr Hodina wrote:

> console_set_row() and console_set_row_2() clear a row with a single
> contiguous fill assuming line_length == xsize * pbytes. A stride-padded
> framebuffer inherited from a prior boot stage (e.g. via
> simple-framebuffer) breaks that assumption leaving stale pixels after
> scroll.
> 
> Use video_fill_part() which already steps per scanline by
> line_length.
> 
> [...]

Applied to u-boot/main, thanks!

[1/1] video: console: clear rows stride-aware in set_row
      commit: e16958bc076d842df20c8ea96d9fbec479e54459
diff mbox series

Patch

diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c
index 07db613ac53..9a3d08aad02 100644
--- a/drivers/video/console_normal.c
+++ b/drivers/video/console_normal.c
@@ -18,30 +18,10 @@  static int console_set_row(struct udevice *dev, uint row, int clr)
 	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
 	struct console_simple_priv *priv = dev_get_priv(dev);
 	struct video_fontdata *fontdata = priv->fontdata;
-	void *line, *dst, *end;
-	int pixels = fontdata->height * vid_priv->xsize;
-	int ret;
-	int i;
-	int pbytes;
 
-	ret = check_bpix_support(vid_priv->bpix);
-	if (ret)
-		return ret;
-
-	line = vid_priv->fb + row * fontdata->height * vid_priv->line_length;
-	dst = line;
-	pbytes = VNBYTES(vid_priv->bpix);
-	for (i = 0; i < pixels; i++)
-		fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes);
-	end = dst;
-
-	video_damage(dev->parent,
-		     0,
-		     fontdata->height * row,
-		     vid_priv->xsize,
-		     fontdata->height);
-
-	return 0;
+	return video_fill_part(dev->parent, 0, row * fontdata->height,
+				vid_priv->xsize,
+				(row + 1) * fontdata->height, clr);
 }
 
 static int console_move_rows(struct udevice *dev, uint rowdst,
diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c
index 886b25dcfaf..6feacd43b6c 100644
--- a/drivers/video/console_rotate.c
+++ b/drivers/video/console_rotate.c
@@ -112,26 +112,11 @@  static int console_set_row_2(struct udevice *dev, uint row, int clr)
 	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
 	struct console_simple_priv *priv = dev_get_priv(dev);
 	struct video_fontdata *fontdata = priv->fontdata;
-	void *start, *line, *dst, *end;
-	int pixels = fontdata->height * vid_priv->xsize;
-	int i;
-	int pbytes = VNBYTES(vid_priv->bpix);
-
-	start = vid_priv->fb + vid_priv->ysize * vid_priv->line_length -
-		(row + 1) * fontdata->height * vid_priv->line_length;
-	line = start;
-	dst = line;
-	for (i = 0; i < pixels; i++)
-		fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes);
-	end = dst;
 
-	video_damage(dev->parent,
-		     0,
-		     vid_priv->ysize - (row + 1) * fontdata->height,
-		     vid_priv->xsize,
-		     fontdata->height);
-
-	return 0;
+	return video_fill_part(dev->parent, 0,
+				vid_priv->ysize - (row + 1) * fontdata->height,
+				vid_priv->xsize,
+				vid_priv->ysize - row * fontdata->height, clr);
 }
 
 static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc,