Linux Serial subsystem development
 help / color / mirror / Atom feed
* [PATCH v2 04/10] lib/fonts: Clean up Makefile
From: Thomas Zimmermann @ 2026-04-07  9:23 UTC (permalink / raw)
  To: deller, gregkh, jirislaby, geert, simona, sam
  Cc: linux-fbdev, dri-devel, linux-kernel, linux-serial,
	Thomas Zimmermann
In-Reply-To: <20260407092555.58816-1-tzimmermann@suse.de>

Simplify the Makefile. Drop font-obj-y and sort the fonts by dictionary
order. Done in preparation for supporting optional font rotation.

v2:
- sort Makefile font entries by Family/Size in ascending order (Geert, Jiri)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 lib/fonts/Makefile | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/lib/fonts/Makefile b/lib/fonts/Makefile
index 30a85a4292fa..b176af53d53e 100644
--- a/lib/fonts/Makefile
+++ b/lib/fonts/Makefile
@@ -1,23 +1,22 @@
 # SPDX-License-Identifier: GPL-2.0
 # Font handling
 
-font-objs := fonts.o
+font-y := fonts.o
 
-font-objs-$(CONFIG_FONT_SUN8x16)   += font_sun8x16.o
-font-objs-$(CONFIG_FONT_SUN12x22)  += font_sun12x22.o
-font-objs-$(CONFIG_FONT_8x8)       += font_8x8.o
-font-objs-$(CONFIG_FONT_8x16)      += font_8x16.o
-font-objs-$(CONFIG_FONT_6x11)      += font_6x11.o
-font-objs-$(CONFIG_FONT_7x14)      += font_7x14.o
-font-objs-$(CONFIG_FONT_10x18)     += font_10x18.o
-font-objs-$(CONFIG_FONT_PEARL_8x8) += font_pearl_8x8.o
-font-objs-$(CONFIG_FONT_ACORN_8x8) += font_acorn_8x8.o
-font-objs-$(CONFIG_FONT_MINI_4x6)  += font_mini_4x6.o
-font-objs-$(CONFIG_FONT_6x10)      += font_6x10.o
-font-objs-$(CONFIG_FONT_TER10x18)  += font_ter10x18.o
-font-objs-$(CONFIG_FONT_TER16x32)  += font_ter16x32.o
-font-objs-$(CONFIG_FONT_6x8)       += font_6x8.o
+# Built-in fonts; sorted by Family-Size in ascending order
+font-$(CONFIG_FONT_6x8)       += font_6x8.o
+font-$(CONFIG_FONT_6x10)      += font_6x10.o
+font-$(CONFIG_FONT_6x11)      += font_6x11.o
+font-$(CONFIG_FONT_7x14)      += font_7x14.o
+font-$(CONFIG_FONT_8x8)       += font_8x8.o
+font-$(CONFIG_FONT_8x16)      += font_8x16.o
+font-$(CONFIG_FONT_10x18)     += font_10x18.o
+font-$(CONFIG_FONT_ACORN_8x8) += font_acorn_8x8.o
+font-$(CONFIG_FONT_MINI_4x6)  += font_mini_4x6.o
+font-$(CONFIG_FONT_PEARL_8x8) += font_pearl_8x8.o
+font-$(CONFIG_FONT_SUN8x16)   += font_sun8x16.o
+font-$(CONFIG_FONT_SUN12x22)  += font_sun12x22.o
+font-$(CONFIG_FONT_TER10x18)  += font_ter10x18.o
+font-$(CONFIG_FONT_TER16x32)  += font_ter16x32.o
 
-font-objs += $(font-objs-y)
-
-obj-$(CONFIG_FONT_SUPPORT)         += font.o
+obj-$(CONFIG_FONT_SUPPORT) += font.o
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 07/10] lib/fonts: Refactor glyph-rotation helpers
From: Thomas Zimmermann @ 2026-04-07  9:23 UTC (permalink / raw)
  To: deller, gregkh, jirislaby, geert, simona, sam
  Cc: linux-fbdev, dri-devel, linux-kernel, linux-serial,
	Thomas Zimmermann
In-Reply-To: <20260407092555.58816-1-tzimmermann@suse.de>

Change the signatures of the glyph-rotation helpers to match their
public interfaces. Drop the inline qualifier.

Rename several variables to better match their meaning. Especially
rename variables to bit_pitch (or a variant thereof) if they store
a pitch value in bits per scanline. The original code is fairly
confusing about this. Move the calculation of the bit pitch into the
new helper font_glyph_bit_pitch().

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 lib/fonts/font_rotate.c | 85 ++++++++++++++++++++++++-----------------
 1 file changed, 49 insertions(+), 36 deletions(-)

diff --git a/lib/fonts/font_rotate.c b/lib/fonts/font_rotate.c
index d79ec5eef712..09f6218e036f 100644
--- a/lib/fonts/font_rotate.c
+++ b/lib/fonts/font_rotate.c
@@ -15,6 +15,12 @@
 
 #include "font.h"
 
+/* number of bits per line */
+static unsigned int font_glyph_bit_pitch(unsigned int width)
+{
+	return round_up(width, 8);
+}
+
 static unsigned int __font_glyph_pos(unsigned int x, unsigned int y, unsigned int bit_pitch,
 				     unsigned int *bit)
 {
@@ -44,18 +50,21 @@ static void font_glyph_set_bit(unsigned char *glyph, unsigned int x, unsigned in
 	glyph[i] |= bit;
 }
 
-static inline void rotate_cw(const char *in, char *out, u32 width, u32 height)
+static void __font_glyph_rotate_90(const unsigned char *glyph,
+				   unsigned int width, unsigned int height,
+				   unsigned char *out)
 {
-	int i, j, h = height, w = width;
-	int shift = (8 - (height % 8)) & 7;
-
-	width = (width + 7) & ~7;
-	height = (height + 7) & ~7;
-
-	for (i = 0; i < h; i++) {
-		for (j = 0; j < w; j++) {
-			if (font_glyph_test_bit(in, j, i, width))
-				font_glyph_set_bit(out, height - 1 - i - shift, j, height);
+	unsigned int x, y;
+	unsigned int shift = (8 - (height % 8)) & 7;
+	unsigned int bit_pitch = font_glyph_bit_pitch(width);
+	unsigned int out_bit_pitch = font_glyph_bit_pitch(height);
+
+	for (y = 0; y < height; y++) {
+		for (x = 0; x < width; x++) {
+			if (font_glyph_test_bit(glyph, x, y, bit_pitch)) {
+				font_glyph_set_bit(out, out_bit_pitch - 1 - y - shift, x,
+						   out_bit_pitch);
+			}
 		}
 	}
 }
@@ -79,22 +88,24 @@ void font_glyph_rotate_90(const unsigned char *glyph, unsigned int width, unsign
 {
 	memset(out, 0, font_glyph_size(height, width)); /* flip width/height */
 
-	rotate_cw(glyph, out, width, height);
+	__font_glyph_rotate_90(glyph, width, height, out);
 }
 EXPORT_SYMBOL_GPL(font_glyph_rotate_90);
 
-static inline void rotate_ud(const char *in, char *out, u32 width, u32 height)
+static void __font_glyph_rotate_180(const unsigned char *glyph,
+				    unsigned int width, unsigned int height,
+				    unsigned char *out)
 {
-	int i, j;
-	int shift = (8 - (width % 8)) & 7;
-
-	width = (width + 7) & ~7;
-
-	for (i = 0; i < height; i++) {
-		for (j = 0; j < width - shift; j++) {
-			if (font_glyph_test_bit(in, j, i, width))
-				font_glyph_set_bit(out, width - (1 + j + shift),
-						   height - (1 + i), width);
+	unsigned int x, y;
+	unsigned int shift = (8 - (width % 8)) & 7;
+	unsigned int bit_pitch = font_glyph_bit_pitch(width);
+
+	for (y = 0; y < height; y++) {
+		for (x = 0; x < width; x++) {
+			if (font_glyph_test_bit(glyph, x, y, bit_pitch)) {
+				font_glyph_set_bit(out, width - (1 + x + shift), height - (1 + y),
+						   bit_pitch);
+			}
 		}
 	}
 }
@@ -115,22 +126,24 @@ void font_glyph_rotate_180(const unsigned char *glyph, unsigned int width, unsig
 {
 	memset(out, 0, font_glyph_size(width, height));
 
-	rotate_ud(glyph, out, width, height);
+	__font_glyph_rotate_180(glyph, width, height, out);
 }
 EXPORT_SYMBOL_GPL(font_glyph_rotate_180);
 
-static inline void rotate_ccw(const char *in, char *out, u32 width, u32 height)
+static void __font_glyph_rotate_270(const unsigned char *glyph,
+				    unsigned int width, unsigned int height,
+				    unsigned char *out)
 {
-	int i, j, h = height, w = width;
-	int shift = (8 - (width % 8)) & 7;
-
-	width = (width + 7) & ~7;
-	height = (height + 7) & ~7;
-
-	for (i = 0; i < h; i++) {
-		for (j = 0; j < w; j++) {
-			if (font_glyph_test_bit(in, j, i, width))
-				font_glyph_set_bit(out, i, width - 1 - j - shift, height);
+	unsigned int x, y;
+	unsigned int shift = (8 - (width % 8)) & 7;
+	unsigned int bit_pitch = font_glyph_bit_pitch(width);
+	unsigned int out_bit_pitch = font_glyph_bit_pitch(height);
+
+	for (y = 0; y < height; y++) {
+		for (x = 0; x < width; x++) {
+			if (font_glyph_test_bit(glyph, x, y, bit_pitch))
+				font_glyph_set_bit(out, y, bit_pitch - 1 - x - shift,
+						   out_bit_pitch);
 		}
 	}
 }
@@ -154,6 +167,6 @@ void font_glyph_rotate_270(const unsigned char *glyph, unsigned int width, unsig
 {
 	memset(out, 0, font_glyph_size(height, width)); /* flip width/height */
 
-	rotate_ccw(glyph, out, width, height);
+	__font_glyph_rotate_270(glyph, width, height, out);
 }
 EXPORT_SYMBOL_GPL(font_glyph_rotate_270);
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2 10/10] fbcon: Put font-rotation state into separate struct
From: Thomas Zimmermann @ 2026-04-07  9:23 UTC (permalink / raw)
  To: deller, gregkh, jirislaby, geert, simona, sam
  Cc: linux-fbdev, dri-devel, linux-kernel, linux-serial,
	Thomas Zimmermann
In-Reply-To: <20260407092555.58816-1-tzimmermann@suse.de>

Move all temporary state of the font-rotation code into the struct
rotated in struct fbcon_par. Protect it with the Kconfig symbol
CONFIG_FRAMEBUFFER_CONSOLE_ROTATION. Avoids mixing it up with fbcon's
regular state.

v2:
- fix typos

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/core/fbcon.c        |  8 ++++++--
 drivers/video/fbdev/core/fbcon.h        | 12 +++++++----
 drivers/video/fbdev/core/fbcon_ccw.c    |  8 ++++----
 drivers/video/fbdev/core/fbcon_cw.c     |  8 ++++----
 drivers/video/fbdev/core/fbcon_rotate.c | 27 +++++++++++++------------
 drivers/video/fbdev/core/fbcon_ud.c     | 10 ++++-----
 6 files changed, 41 insertions(+), 32 deletions(-)

diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index ff4c69e971f8..b0e3e765360d 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -787,7 +787,9 @@ static void fbcon_release(struct fb_info *info)
 		kfree(par->cursor_state.mask);
 		kfree(par->cursor_data);
 		kfree(par->cursor_src);
-		kfree(par->fontbuffer);
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
+		kfree(par->rotated.buf);
+#endif
 		kfree(info->fbcon_par);
 		info->fbcon_par = NULL;
 	}
@@ -1040,7 +1042,9 @@ static const char *fbcon_startup(void)
 	par = info->fbcon_par;
 	par->currcon = -1;
 	par->graphics = 1;
-	par->cur_rotate = -1;
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
+	par->rotated.buf_rotate = -1;
+#endif
 
 	p->con_rotate = initial_rotation;
 	if (p->con_rotate == -1)
diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fbcon.h
index bb0727b70631..321cc7f44baa 100644
--- a/drivers/video/fbdev/core/fbcon.h
+++ b/drivers/video/fbdev/core/fbcon.h
@@ -80,13 +80,17 @@ struct fbcon_par {
 	int    graphics;
 	bool   initialized;
 	int    rotate;
-	int    cur_rotate;
 	char  *cursor_data;
-	u8          *fontbuffer;
-	const u8    *fontdata;
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
+	struct {
+		font_data_t *fontdata;  /* source font */
+		u8 *buf;                /* rotated glyphs */
+		size_t bufsize;
+		int buf_rotate;         /* rotation of buf */
+	} rotated;
+#endif
 	u8    *cursor_src;
 	u32    cursor_size;
-	size_t fd_size;
 
 	const struct fbcon_bitops *bitops;
 };
diff --git a/drivers/video/fbdev/core/fbcon_ccw.c b/drivers/video/fbdev/core/fbcon_ccw.c
index 723d9a33067f..33f02d579e02 100644
--- a/drivers/video/fbdev/core/fbcon_ccw.c
+++ b/drivers/video/fbdev/core/fbcon_ccw.c
@@ -106,7 +106,7 @@ static inline void ccw_putcs_aligned(struct vc_data *vc, struct fb_info *info,
 	u8 *src;
 
 	while (cnt--) {
-		src = par->fontbuffer + (scr_readw(s--) & charmask) * cellsize;
+		src = par->rotated.buf + (scr_readw(s--) & charmask) * cellsize;
 
 		if (attr) {
 			ccw_update_attr(buf, src, attr, vc);
@@ -142,7 +142,7 @@ static void ccw_putcs(struct vc_data *vc, struct fb_info *info,
 	u8 *dst, *buf = NULL;
 	u32 vyres = GETVYRES(par->p, info);
 
-	if (!par->fontbuffer)
+	if (!par->rotated.buf)
 		return;
 
 	image.fg_color = fg;
@@ -232,14 +232,14 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
 	char *src;
 	u32 vyres = GETVYRES(par->p, info);
 
-	if (!par->fontbuffer)
+	if (!par->rotated.buf)
 		return;
 
 	cursor.set = 0;
 
  	c = scr_readw((u16 *) vc->vc_pos);
 	attribute = get_attribute(info, c);
-	src = par->fontbuffer + ((c & charmask) * (w * vc->vc_font.width));
+	src = par->rotated.buf + ((c & charmask) * (w * vc->vc_font.width));
 
 	if (par->cursor_state.image.data != src ||
 	    par->cursor_reset) {
diff --git a/drivers/video/fbdev/core/fbcon_cw.c b/drivers/video/fbdev/core/fbcon_cw.c
index 732d093d462f..bde820967eb9 100644
--- a/drivers/video/fbdev/core/fbcon_cw.c
+++ b/drivers/video/fbdev/core/fbcon_cw.c
@@ -91,7 +91,7 @@ static inline void cw_putcs_aligned(struct vc_data *vc, struct fb_info *info,
 	u8 *src;
 
 	while (cnt--) {
-		src = par->fontbuffer + (scr_readw(s++) & charmask) * cellsize;
+		src = par->rotated.buf + (scr_readw(s++) & charmask) * cellsize;
 
 		if (attr) {
 			cw_update_attr(buf, src, attr, vc);
@@ -127,7 +127,7 @@ static void cw_putcs(struct vc_data *vc, struct fb_info *info,
 	u8 *dst, *buf = NULL;
 	u32 vxres = GETVXRES(par->p, info);
 
-	if (!par->fontbuffer)
+	if (!par->rotated.buf)
 		return;
 
 	image.fg_color = fg;
@@ -215,14 +215,14 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
 	char *src;
 	u32 vxres = GETVXRES(par->p, info);
 
-	if (!par->fontbuffer)
+	if (!par->rotated.buf)
 		return;
 
 	cursor.set = 0;
 
  	c = scr_readw((u16 *) vc->vc_pos);
 	attribute = get_attribute(info, c);
-	src = par->fontbuffer + ((c & charmask) * (w * vc->vc_font.width));
+	src = par->rotated.buf + ((c & charmask) * (w * vc->vc_font.width));
 
 	if (par->cursor_state.image.data != src ||
 	    par->cursor_reset) {
diff --git a/drivers/video/fbdev/core/fbcon_rotate.c b/drivers/video/fbdev/core/fbcon_rotate.c
index 74206f5a6e98..6cdbc96eeca6 100644
--- a/drivers/video/fbdev/core/fbcon_rotate.c
+++ b/drivers/video/fbdev/core/fbcon_rotate.c
@@ -18,34 +18,35 @@
 int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc)
 {
 	struct fbcon_par *par = info->fbcon_par;
-	unsigned char *fontbuffer;
+	unsigned char *buf;
 	int ret;
 
-	if (vc->vc_font.data == par->fontdata &&
-	    par->p->con_rotate == par->cur_rotate)
+	if (par->p->fontdata == par->rotated.fontdata && par->rotate == par->rotated.buf_rotate)
 		return 0;
 
-	par->fontdata = vc->vc_font.data;
-	par->cur_rotate = par->p->con_rotate;
+	par->rotated.fontdata = par->p->fontdata;
+	par->rotated.buf_rotate = par->rotate;
 
 	if (info->fbops->fb_sync)
 		info->fbops->fb_sync(info);
 
-	fontbuffer = font_data_rotate(par->p->fontdata, vc->vc_font.width,
-				      vc->vc_font.height, vc->vc_font.charcount,
-				      par->rotate, par->fontbuffer, &par->fd_size);
-	if (IS_ERR(fontbuffer)) {
-		ret = PTR_ERR(fontbuffer);
+	buf = font_data_rotate(par->rotated.fontdata, vc->vc_font.width,
+			       vc->vc_font.height, vc->vc_font.charcount,
+			       par->rotated.buf_rotate, par->rotated.buf,
+			       &par->rotated.bufsize);
+	if (IS_ERR(buf)) {
+		ret = PTR_ERR(buf);
 		goto err_kfree;
 	}
 
-	par->fontbuffer = fontbuffer;
+	par->rotated.buf = buf;
 
 	return 0;
 
 err_kfree:
-	kfree(par->fontbuffer);
-	par->fontbuffer = NULL; /* clear here to avoid output */
+	kfree(par->rotated.buf);
+	par->rotated.buf = NULL; /* clear here to avoid output */
+	par->rotated.bufsize = 0;
 
 	return ret;
 }
diff --git a/drivers/video/fbdev/core/fbcon_ud.c b/drivers/video/fbdev/core/fbcon_ud.c
index a1981fa4701a..eaf08999e249 100644
--- a/drivers/video/fbdev/core/fbcon_ud.c
+++ b/drivers/video/fbdev/core/fbcon_ud.c
@@ -92,7 +92,7 @@ static inline void ud_putcs_aligned(struct vc_data *vc, struct fb_info *info,
 	u8 *src;
 
 	while (cnt--) {
-		src = par->fontbuffer + (scr_readw(s--) & charmask) * cellsize;
+		src = par->rotated.buf + (scr_readw(s--) & charmask) * cellsize;
 
 		if (attr) {
 			ud_update_attr(buf, src, attr, vc);
@@ -127,7 +127,7 @@ static inline void ud_putcs_unaligned(struct vc_data *vc,
 	u8 *src;
 
 	while (cnt--) {
-		src = par->fontbuffer + (scr_readw(s--) & charmask) * cellsize;
+		src = par->rotated.buf + (scr_readw(s--) & charmask) * cellsize;
 
 		if (attr) {
 			ud_update_attr(buf, src, attr, vc);
@@ -164,7 +164,7 @@ static void ud_putcs(struct vc_data *vc, struct fb_info *info,
 	u32 vyres = GETVYRES(par->p, info);
 	u32 vxres = GETVXRES(par->p, info);
 
-	if (!par->fontbuffer)
+	if (!par->rotated.buf)
 		return;
 
 	image.fg_color = fg;
@@ -262,14 +262,14 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
 	u32 vyres = GETVYRES(par->p, info);
 	u32 vxres = GETVXRES(par->p, info);
 
-	if (!par->fontbuffer)
+	if (!par->rotated.buf)
 		return;
 
 	cursor.set = 0;
 
  	c = scr_readw((u16 *) vc->vc_pos);
 	attribute = get_attribute(info, c);
-	src = par->fontbuffer + ((c & charmask) * (w * vc->vc_font.height));
+	src = par->rotated.buf + ((c & charmask) * (w * vc->vc_font.height));
 
 	if (par->cursor_state.image.data != src ||
 	    par->cursor_reset) {
-- 
2.53.0


^ permalink raw reply related

* [PATCH v2] tty: serial: ip22zilog: Fix section mismatch warning
From: Thomas Bogendoerfer @ 2026-04-07 10:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Thomas Bogendoerfer, linux-kernel,
	linux-serial
  Cc: kernel test robot, Randy Dunlap

ip22zilog_prepare() is now called by driver probe routine, so it
shouldn't be in the __init section any longer.

Fixes: 3fc36ae6abd2 ("tty: serial: ip22zilog: Use platform device for probing")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202604020945.c9jAvCPs-lkp@intel.com/
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
Changes in v2:
- Fixed typo in subject
- Added Acked-by from Randy

 drivers/tty/serial/ip22zilog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/ip22zilog.c b/drivers/tty/serial/ip22zilog.c
index 6e19c6713849..a12101dc0554 100644
--- a/drivers/tty/serial/ip22zilog.c
+++ b/drivers/tty/serial/ip22zilog.c
@@ -1025,7 +1025,7 @@ static struct uart_driver ip22zilog_reg = {
 #endif
 };
 
-static void __init ip22zilog_prepare(struct uart_ip22zilog_port *up)
+static void ip22zilog_prepare(struct uart_ip22zilog_port *up)
 {
 	unsigned char sysrq_on = IS_ENABLED(CONFIG_SERIAL_IP22_ZILOG_CONSOLE);
 	int brg;
-- 
2.43.0


^ permalink raw reply related

* [PATCH] serial: rsci: Remove goto and refactor baud rate clock selection
From: Biju @ 2026-04-07 15:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Biju Das, Geert Uytterhoeven, Lad Prabhakar, Wolfram Sang,
	Thierry Bultel, linux-kernel, linux-serial, Biju Das,
	linux-renesas-soc, Pavel Machek

From: Biju Das <biju.das.jz@bp.renesas.com>

Replace the early-exit goto pattern in rsci_set_termios() with a
positive conditional block. When baud rate is zero, the clock
selection logic is now simply skipped rather than jumping to a
'done' label, eliminating the goto entirely.

No functional change intended.

Reported-by: Pavel Machek <pavel@nabladev.com>
Closes: https://lore.kernel.org/all/abPpZULsXhRmXTX9@duo.ucw.cz/
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/tty/serial/rsci.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/tty/serial/rsci.c b/drivers/tty/serial/rsci.c
index b00c9e385169..0b92173f8f45 100644
--- a/drivers/tty/serial/rsci.c
+++ b/drivers/tty/serial/rsci.c
@@ -265,20 +265,18 @@ static void rsci_set_termios(struct uart_port *port, struct ktermios *termios,
 	}
 
 	baud = uart_get_baud_rate(port, termios, old, 0, max_freq);
-	if (!baud)
-		goto done;
-
-	/* Divided Functional Clock using standard Bit Rate Register */
-	err = sci_scbrr_calc(s, baud, &brr1, &srr1, &cks1);
-	if (abs(err) < abs(min_err)) {
-		best_clk = SCI_FCK;
-		ccr0_val = 0;
-		min_err = err;
-		brr = brr1;
-		cks = cks1;
+	if (baud) {
+		/* Divided Functional Clock using standard Bit Rate Register */
+		err = sci_scbrr_calc(s, baud, &brr1, &srr1, &cks1);
+		if (abs(err) < abs(min_err)) {
+			best_clk = SCI_FCK;
+			ccr0_val = 0;
+			min_err = err;
+			brr = brr1;
+			cks = cks1;
+		}
 	}
 
-done:
 	if (best_clk >= 0)
 		dev_dbg(port->dev, "Using clk %pC for %u%+d bps\n",
 			s->clks[best_clk], baud, min_err);
-- 
2.43.0


^ permalink raw reply related

* Re: [PATCH v2 05/10] lib/fonts: Implement glyph rotation
From: Helge Deller @ 2026-04-07 15:48 UTC (permalink / raw)
  To: Thomas Zimmermann, gregkh, jirislaby, geert, simona, sam
  Cc: linux-fbdev, dri-devel, linux-kernel, linux-serial
In-Reply-To: <20260407092555.58816-6-tzimmermann@suse.de>

Hi Thomas,

On 4/7/26 11:23, Thomas Zimmermann wrote:
> Move the glyph rotation helpers from fbcon to the font library. Wrap them
> behind clean interfaces. Also clear the output memory to zero. Previously,
> the implementation relied on the caller to do that.
> 
> Go through the fbcon code and callers of the glyph-rotation helpers. In
> addition to the font rotation, there's also the cursor code, which uses
> the rotation helpers.
> 
> The font-rotation relied on a single memset to zero for the whole font.
> This is now multiple memsets on each glyph. This will be sorted out when
> the font library also implements font rotation.
> 
> Building glyph rotation in the font library still depends on
> CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y. If we get more users of the code,
> we can still add a dedicated Kconfig symbol to the font library.
> 
> No changes have been made to the actual implementation of the rotate_*()
> and pattern_*() functions. These will be refactored as separate changes.
> 
> v2:
> - fix typos
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
>   drivers/video/fbdev/core/fbcon_ccw.c    |   4 +-
>   drivers/video/fbdev/core/fbcon_cw.c     |   4 +-
>   drivers/video/fbdev/core/fbcon_rotate.c |  12 +-
>   drivers/video/fbdev/core/fbcon_rotate.h |  71 -----------
>   include/linux/font.h                    |   8 ++
>   lib/fonts/Makefile                      |   1 +
>   lib/fonts/font_rotate.c                 | 150 ++++++++++++++++++++++++

Patch is Ok.
But since you move/add the file lib/fonts/font_rotate.c,
it should be reflected in MAINTAINERS file.
Do you mind sending a follow-up patch which adds /lib/fonts/* to the
FRAMEBUFFER LAYER and FRAMEBUFFER CORE entries in the MAINTAINERS file?

Other than that, I've now added this series to the fbdev git tree.

Thanks!
Helge

^ permalink raw reply

* [syzbot] [serial?] KASAN: slab-use-after-free Read in kbd_event (2)
From: syzbot @ 2026-04-07 20:35 UTC (permalink / raw)
  To: gregkh, jirislaby, linux-kernel, linux-serial, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    5619b098e2fb Merge tag 'for-7.0-rc6-tag' of git://git.kern..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=101c41ca580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=45cb3c58fd963c27
dashboard link: https://syzkaller.appspot.com/bug?extid=098cefc0911c68db5dab
compiler:       Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/63964c15e763/disk-5619b098.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/86e80eed2888/vmlinux-5619b098.xz
kernel image: https://storage.googleapis.com/syzbot-assets/17dba94dbc66/bzImage-5619b098.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+098cefc0911c68db5dab@syzkaller.appspotmail.com

==================================================================
BUG: KASA[  730.192938][ T7920] BUG: KASAN: slab-use-after-free in kbd_keycode drivers/tty/vt/keyboard.c:1435 [inline]
BUG: KASA[  730.192938][ T7920] BUG: KASAN: slab-use-after-free in kbd_event+0x3330/0x40d0 drivers/tty/vt/keyboard.c:1515
Read of size 4 at addr ffff88806944e35c by task syz.2.13424/7920

CPU: 1 UID: 0 PID: 7920 Comm: syz.2.13424 Tainted: G             L      syzkaller #0 PREEMPT_{RT,(full)} 
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/18/2026
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0xba/0x230 mm/kasan/report.c:482
 kasan_report+0x117/0x150 mm/kasan/report.c:595
 kbd_keycode drivers/tty/vt/keyboard.c:1435 [inline]
 kbd_event+0x3330/0x40d0 drivers/tty/vt/keyboard.c:1515
 input_handle_events_default+0xd4/0x1a0 drivers/input/input.c:2541
 input_pass_values+0x288/0x890 drivers/input/input.c:128
 input_event_dispose+0x330/0x6b0 drivers/input/input.c:342
 input_inject_event+0x1d8/0x330 drivers/input/input.c:424
 evdev_write+0x328/0x4c0 drivers/input/evdev.c:528
 vfs_write+0x2a3/0xba0 fs/read_write.c:686
 ksys_write+0x156/0x270 fs/read_write.c:740
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5547bac819
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f5545dfe028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f5547e25fa0 RCX: 00007f5547bac819
RDX: 0000000000002250 RSI: 0000200000000040 RDI: 0000000000000003
RBP: 00007f5547c42c91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f5547e26038 R14: 00007f5547e25fa0 R15: 00007ffe04f8cf48
 </TASK>

Allocated by task 7915:
 kasan_save_stack mm/kasan/common.c:57 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
 poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
 __kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:415
 kasan_kmalloc include/linux/kasan.h:263 [inline]
 __kmalloc_cache_noprof+0x3a6/0x690 mm/slub.c:5380
 kmalloc_noprof include/linux/slab.h:950 [inline]
 kzalloc_noprof include/linux/slab.h:1188 [inline]
 alloc_tty_struct+0xa6/0x7b0 drivers/tty/tty_io.c:3102
 tty_init_dev+0x59/0x4d0 drivers/tty/tty_io.c:1400
 tty_open_by_driver drivers/tty/tty_io.c:2073 [inline]
 tty_open+0x86e/0xd80 drivers/tty/tty_io.c:2120
 chrdev_open+0x4d0/0x5f0 fs/char_dev.c:411
 do_dentry_open+0x83d/0x13e0 fs/open.c:949
 vfs_open+0x3b/0x350 fs/open.c:1081
 do_open fs/namei.c:4677 [inline]
 path_openat+0x2e43/0x38a0 fs/namei.c:4836
 do_file_open+0x23e/0x4a0 fs/namei.c:4865
 do_sys_openat2+0x113/0x200 fs/open.c:1366
 do_sys_open fs/open.c:1372 [inline]
 __do_sys_openat fs/open.c:1388 [inline]
 __se_sys_openat fs/open.c:1383 [inline]
 __x64_sys_openat+0x138/0x170 fs/open.c:1383
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 15095:
 kasan_save_stack mm/kasan/common.c:57 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
 kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:584
 poison_slab_object mm/kasan/common.c:253 [inline]
 __kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:2685 [inline]
 slab_free mm/slub.c:6165 [inline]
 kfree+0x1c1/0x6c0 mm/slub.c:6483
 process_one_work kernel/workqueue.c:3276 [inline]
 process_scheduled_works+0xb6e/0x18c0 kernel/workqueue.c:3359
 worker_thread+0xa53/0xfc0 kernel/workqueue.c:3440
 kthread+0x388/0x470 kernel/kthread.c:436
 ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

Last potentially related work creation:
 kasan_save_stack+0x3e/0x60 mm/kasan/common.c:57
 kasan_record_aux_stack+0xbd/0xd0 mm/kasan/generic.c:556
 insert_work+0x3d/0x330 kernel/workqueue.c:2199
 __queue_work+0xcc6/0xff0 kernel/workqueue.c:2354
 queue_work_on+0x106/0x1d0 kernel/workqueue.c:2405
 tty_release_struct+0xb8/0xd0 drivers/tty/tty_io.c:1692
 tty_release+0xcb6/0x1710 drivers/tty/tty_io.c:1852
 __fput+0x461/0xa90 fs/file_table.c:469
 task_work_run+0x1d9/0x270 kernel/task_work.c:233
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 __exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
 exit_to_user_mode_loop+0xed/0x480 kernel/entry/common.c:98
 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:226 [inline]
 syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:256 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:325 [inline]
 do_syscall_64+0x32d/0xf80 arch/x86/entry/syscall_64.c:100
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff88806944e000
 which belongs to the cache kmalloc-cg-2k of size 2048
The buggy address is located 860 bytes inside of
 freed 2048-byte region [ffff88806944e000, ffff88806944e800)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x69448
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
memcg:ffff888069448811
flags: 0x80000000000040(head|node=0|zone=1)
page_type: f5(slab)
raw: 0080000000000040 ffff88813fe363c0 dead000000000100 dead000000000122
raw: 0000000000000000 0000100000080008 00000000f5000000 ffff888069448811
head: 0080000000000040 ffff88813fe363c0 dead000000000100 dead000000000122
head: 0000000000000000 0000100000080008 00000000f5000000 ffff888069448811
head: 0080000000000003 ffffea0001a51201 00000000ffffffff 00000000ffffffff
head: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000008
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5878, tgid 5878 (syz-executor), ts 463972954830, free_ts 463959021215
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x231/0x280 mm/page_alloc.c:1889
 prep_new_page mm/page_alloc.c:1897 [inline]
 get_page_from_freelist+0x28bb/0x2950 mm/page_alloc.c:3962
 __alloc_frozen_pages_noprof+0x18d/0x380 mm/page_alloc.c:5250
 alloc_slab_page mm/slub.c:3292 [inline]
 allocate_slab+0x77/0x660 mm/slub.c:3481
 new_slab mm/slub.c:3539 [inline]
 refill_objects+0x334/0x3c0 mm/slub.c:7175
 refill_sheaf mm/slub.c:2812 [inline]
 __pcs_replace_empty_main+0x35c/0x710 mm/slub.c:4615
 alloc_from_pcs mm/slub.c:4717 [inline]
 slab_alloc_node mm/slub.c:4851 [inline]
 __do_kmalloc_node mm/slub.c:5259 [inline]
 __kvmalloc_node_noprof+0x6f4/0x8e0 mm/slub.c:6752
 alloc_fdtable+0x101/0x2c0 fs/file.c:219
 dup_fd+0x879/0xb70 fs/file.c:420
 copy_files+0xc8/0x120 kernel/fork.c:1636
 copy_process+0x1767/0x3cd0 kernel/fork.c:2211
 kernel_clone+0x249/0x840 kernel/fork.c:2653
 __do_sys_clone kernel/fork.c:2794 [inline]
 __se_sys_clone kernel/fork.c:2778 [inline]
 __x64_sys_clone+0x1b6/0x230 kernel/fork.c:2778
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
page last free pid 1186 tgid 1186 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 __free_pages_prepare mm/page_alloc.c:1433 [inline]
 __free_frozen_pages+0xfe3/0x1170 mm/page_alloc.c:2978
 __folio_put+0x25d/0x310 mm/swap.c:112
 put_netmem include/net/netmem.h:420 [inline]
 skb_page_unref include/linux/skbuff_ref.h:43 [inline]
 __skb_frag_unref include/linux/skbuff_ref.h:56 [inline]
 skb_release_data+0x4cb/0x940 net/core/skbuff.c:1122
 skb_release_all net/core/skbuff.c:1203 [inline]
 __kfree_skb+0x5d/0x210 net/core/skbuff.c:1217
 skb_defer_free_flush+0x191/0x260 net/core/dev.c:6837
 net_rx_action+0x4a6/0xe00 net/core/dev.c:7910
 handle_softirqs+0x1de/0x6f0 kernel/softirq.c:622
 __do_softirq kernel/softirq.c:656 [inline]
 __local_bh_enable_ip+0x170/0x2b0 kernel/softirq.c:302
 local_bh_enable include/linux/bottom_half.h:33 [inline]
 irq_forced_thread_fn+0xe9/0x120 kernel/irq/manage.c:1168
 irq_thread+0x4c9/0x740 kernel/irq/manage.c:1271
 kthread+0x388/0x470 kernel/kthread.c:436
 ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

Memory state around the buggy address:
 ffff88806944e200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88806944e280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88806944e300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff88806944e380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88806944e400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

^ permalink raw reply

* Re: [PATCH v5 0/9] driver core: Fix some race conditions
From: Danilo Krummrich @ 2026-04-07 22:58 UTC (permalink / raw)
  To: Douglas Anderson, m.szyprowski, Robin Murphy
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, Alan Stern,
	Alexey Kardashevskiy, Johan Hovold, Eric Dumazet, Leon Romanovsky,
	Christoph Hellwig, maz, Alexander Lobakin, Saravana Kannan,
	Andrew Morton, Frank.Li, Jason Gunthorpe, alex, alexander.stein,
	andre.przywara, andrew, andrew, andriy.shevchenko, aou, ardb,
	astewart, bhelgaas, brgl, broonie, catalin.marinas, chleroy,
	davem, david, devicetree, dmaengine, driver-core, gbatra,
	gregory.clement, hkallweit1, iommu, jirislaby, joel, joro, kees,
	kevin.brodsky, kuba, lenb, lgirdwood, linux-acpi,
	linux-arm-kernel, linux-aspeed, linux-cxl, linux-kernel,
	linux-mips, linux-mm, linux-pci, linux-riscv, linux-serial,
	linux-snps-arc, linux-usb, linux, linuxppc-dev, maddy, mani,
	miko.lenczewski, mpe, netdev, npiggin, osalvador, oupton, pabeni,
	palmer, peter.ujfalusi, peterz, pjw, robh, sebastian.hesselbarth,
	tglx, tsbogend, vgupta, vkoul, will, willy, yangyicong,
	yeoreum.yun
In-Reply-To: <20260406232444.3117516-1-dianders@chromium.org>

On Tue Apr 7, 2026 at 1:22 AM CEST, Douglas Anderson wrote:

Applied to driver-core-testing, thanks!

> Douglas Anderson (9):
>   driver core: Don't let a device probe until it's ready
>   driver core: Replace dev->can_match with dev_can_match()
>   driver core: Replace dev->dma_iommu with dev_dma_iommu()
>   driver core: Replace dev->dma_skip_sync with dev_dma_skip_sync()
>   driver core: Replace dev->dma_ops_bypass with dev_dma_ops_bypass()
>   driver core: Replace dev->state_synced with dev_state_synced()
>   driver core: Replace dev->dma_coherent with dev_dma_coherent()

    [ Since all DEV_FLAG_DMA_COHERENT accessors are exposed unconditionally,
      also drop the CONFIG guards around dev_assign_dma_coherent() in
      device_initialize() to ensure a correct default value. - Danilo ]

>   driver core: Replace dev->of_node_reused with dev_of_node_reused()
>   driver core: Replace dev->offline + ->offline_disabled with accessors

^ permalink raw reply

* [PATCH] tty: serial: pch_uart: add check for dma_alloc_coherent()
From: Zhaoyang Yu @ 2026-04-08  7:24 UTC (permalink / raw)
  To: gregkh, jirislaby
  Cc: andriy.shevchenko, kees, fourier.thomas, linux-serial,
	linux-kernel, gszhai, 2426767509

From: Zhaoyang Yu <2426767509@qq.com>

Add a check for dma_alloc_coherent() failure to prevent a potential
NULL pointer dereference in dma_handle_rx(). Properly release DMA
channels and the PCI device reference using a goto ladder if the
allocation fails.

Signed-off-by: Zhaoyang Yu <2426767509@qq.com>
---
 drivers/tty/serial/pch_uart.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index 6729d8e83c3c..ba1fcd663fe2 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -689,8 +689,7 @@ static void pch_request_dma(struct uart_port *port)
 	if (!chan) {
 		dev_err(priv->port.dev, "%s:dma_request_channel FAILS(Tx)\n",
 			__func__);
-		pci_dev_put(dma_dev);
-		return;
+		goto err_pci_get;
 	}
 	priv->chan_tx = chan;
 
@@ -704,18 +703,26 @@ static void pch_request_dma(struct uart_port *port)
 	if (!chan) {
 		dev_err(priv->port.dev, "%s:dma_request_channel FAILS(Rx)\n",
 			__func__);
-		dma_release_channel(priv->chan_tx);
-		priv->chan_tx = NULL;
-		pci_dev_put(dma_dev);
-		return;
+		goto err_req_tx;
 	}
 
 	/* Get Consistent memory for DMA */
 	priv->rx_buf_virt = dma_alloc_coherent(port->dev, port->fifosize,
 				    &priv->rx_buf_dma, GFP_KERNEL);
+	if (!priv->rx_buf_virt)
+		goto err_req_rx;
 	priv->chan_rx = chan;
 
 	pci_dev_put(dma_dev);
+	return;
+
+err_req_rx:
+	dma_release_channel(chan);
+err_req_tx:
+	dma_release_channel(priv->chan_tx);
+	priv->chan_tx = NULL;
+err_pci_get:
+	pci_dev_put(dma_dev);
 }
 
 static void pch_dma_rx_complete(void *arg)
-- 
2.50.1


^ permalink raw reply related

* Re: [PATCH] serial: rsci: Remove goto and refactor baud rate clock selection
From: Geert Uytterhoeven @ 2026-04-08  8:22 UTC (permalink / raw)
  To: Biju
  Cc: Greg Kroah-Hartman, Jiri Slaby, Biju Das, Lad Prabhakar,
	Wolfram Sang, Thierry Bultel, linux-kernel, linux-serial,
	linux-renesas-soc, Pavel Machek
In-Reply-To: <20260407151210.102693-1-biju.das.jz@bp.renesas.com>

Hi Biju,

On Tue, 7 Apr 2026 at 17:12, Biju <biju.das.au@gmail.com> wrote:
> From: Biju Das <biju.das.jz@bp.renesas.com>
>
> Replace the early-exit goto pattern in rsci_set_termios() with a
> positive conditional block. When baud rate is zero, the clock
> selection logic is now simply skipped rather than jumping to a
> 'done' label, eliminating the goto entirely.
>
> No functional change intended.
>
> Reported-by: Pavel Machek <pavel@nabladev.com>
> Closes: https://lore.kernel.org/all/abPpZULsXhRmXTX9@duo.ucw.cz/
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>

Thanks for your patch!

> --- a/drivers/tty/serial/rsci.c
> +++ b/drivers/tty/serial/rsci.c
> @@ -265,20 +265,18 @@ static void rsci_set_termios(struct uart_port *port, struct ktermios *termios,
>         }
>
>         baud = uart_get_baud_rate(port, termios, old, 0, max_freq);
> -       if (!baud)
> -               goto done;

As RSCI has only a single possible input clock for bit rate selection,
there is indeed no need for the "done" label.

> -
> -       /* Divided Functional Clock using standard Bit Rate Register */
> -       err = sci_scbrr_calc(s, baud, &brr1, &srr1, &cks1);
> -       if (abs(err) < abs(min_err)) {
> -               best_clk = SCI_FCK;
> -               ccr0_val = 0;
> -               min_err = err;
> -               brr = brr1;
> -               cks = cks1;
> +       if (baud) {
> +               /* Divided Functional Clock using standard Bit Rate Register */
> +               err = sci_scbrr_calc(s, baud, &brr1, &srr1, &cks1);
> +               if (abs(err) < abs(min_err)) {

This check is always true.

> +                       best_clk = SCI_FCK;

best_clk can be removed...

> +                       ccr0_val = 0;
> +                       min_err = err;

... just like min_err...

> +                       brr = brr1;
> +                       cks = cks1;

and the brr1, srr1, and cks1 intermediaries.

> +               }
>         }
>
> -done:
>         if (best_clk >= 0)
>                 dev_dbg(port->dev, "Using clk %pC for %u%+d bps\n",
>                         s->clks[best_clk], baud, min_err);

This dev_dbg() can be moved inside the "if (baud)" check.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* Re: [PATCH] tty: serial: pch_uart: add check for dma_alloc_coherent()
From: Andy Shevchenko @ 2026-04-08 13:22 UTC (permalink / raw)
  To: Zhaoyang Yu
  Cc: gregkh, jirislaby, kees, fourier.thomas, linux-serial,
	linux-kernel, gszhai, 2426767509
In-Reply-To: <20260408072421.831-1-23120469@bjtu.edu.cn>

On Wed, Apr 08, 2026 at 03:24:21PM +0800, Zhaoyang Yu wrote:

> Add a check for dma_alloc_coherent() failure to prevent a potential
> NULL pointer dereference in dma_handle_rx(). Properly release DMA
> channels and the PCI device reference using a goto ladder if the
> allocation fails.

Looks like it deserves a Fixes tag.

Also ideally this driver should be converted to one of 8250 cases.
The latter has already DMA support. Note, if you are going this
direction, I have the hardware to test.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply

* RE: [PATCH] serial: rsci: Remove goto and refactor baud rate clock selection
From: Biju Das @ 2026-04-08 13:57 UTC (permalink / raw)
  To: geert, biju.das.au
  Cc: Greg Kroah-Hartman, Jiri Slaby, Prabhakar Mahadev Lad,
	wsa+renesas, Thierry Bultel, linux-kernel@vger.kernel.org,
	linux-serial@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Pavel Machek
In-Reply-To: <CAMuHMdVXRKHuV0F4gSu+SsyWAS6RYxhd-XBCjXD1jbYznXup1w@mail.gmail.com>

Hi Geert,

Thanks for the feedback.

> -----Original Message-----
> From: Geert Uytterhoeven <geert@linux-m68k.org>
> Sent: 08 April 2026 09:22
> Subject: Re: [PATCH] serial: rsci: Remove goto and refactor baud rate clock selection
> 
> Hi Biju,
> 
> On Tue, 7 Apr 2026 at 17:12, Biju <biju.das.au@gmail.com> wrote:
> > From: Biju Das <biju.das.jz@bp.renesas.com>
> >
> > Replace the early-exit goto pattern in rsci_set_termios() with a
> > positive conditional block. When baud rate is zero, the clock
> > selection logic is now simply skipped rather than jumping to a 'done'
> > label, eliminating the goto entirely.
> >
> > No functional change intended.
> >
> > Reported-by: Pavel Machek <pavel@nabladev.com>
> > Closes: https://lore.kernel.org/all/abPpZULsXhRmXTX9@duo.ucw.cz/
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> 
> Thanks for your patch!
> 
> > --- a/drivers/tty/serial/rsci.c
> > +++ b/drivers/tty/serial/rsci.c
> > @@ -265,20 +265,18 @@ static void rsci_set_termios(struct uart_port *port, struct ktermios *termios,
> >         }
> >
> >         baud = uart_get_baud_rate(port, termios, old, 0, max_freq);
> > -       if (!baud)
> > -               goto done;
> 
> As RSCI has only a single possible input clock for bit rate selection, there is indeed no need for the
> "done" label.
> 
> > -
> > -       /* Divided Functional Clock using standard Bit Rate Register */
> > -       err = sci_scbrr_calc(s, baud, &brr1, &srr1, &cks1);
> > -       if (abs(err) < abs(min_err)) {
> > -               best_clk = SCI_FCK;
> > -               ccr0_val = 0;
> > -               min_err = err;
> > -               brr = brr1;
> > -               cks = cks1;
> > +       if (baud) {
> > +               /* Divided Functional Clock using standard Bit Rate Register */
> > +               err = sci_scbrr_calc(s, baud, &brr1, &srr1, &cks1);
> > +               if (abs(err) < abs(min_err)) {
> 
> This check is always true.

Ok will drop this.

> 
> > +                       best_clk = SCI_FCK;
> 
> best_clk can be removed...

OK.

> 
> > +                       ccr0_val = 0;
> > +                       min_err = err;
> 
> ... just like min_err...
OK.
> 
> > +                       brr = brr1;
> > +                       cks = cks1;
> 
> and the brr1, srr1, and cks1 intermediaries.

OK.

> 
> > +               }
> >         }
> >
> > -done:
> >         if (best_clk >= 0)
> >                 dev_dbg(port->dev, "Using clk %pC for %u%+d bps\n",
> >                         s->clks[best_clk], baud, min_err);
> 
> This dev_dbg() can be moved inside the "if (baud)" check.

Agreed.

Will send v2, fixing these.

Cheers,
Biju

^ permalink raw reply

* [PATCH v2 0/2] serial: sh-sci/rsci: Fix divide by zero and clean up baud rate logic
From: Biju @ 2026-04-08 14:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Biju Das, Geert Uytterhoeven, Thierry Bultel, Wolfram Sang,
	Lad Prabhakar, linux-kernel, linux-serial, Biju Das,
	linux-renesas-soc

From: Biju Das <biju.das.jz@bp.renesas.com>

This series fixes a divide-by-zero in the sh-sci and rsci serial drivers
and follows up with a cleanup of the baud rate clock selection logic in
rsci that the fix exposed as unnecessarily complex.

Patch 1 guards both uart_update_timeout() call sites in sci_set_termios()
and rsci_set_termios() with a baud != 0 check. uart_update_timeout()
divides by the baud rate internally, so passing zero causes a divide-by-
zero fault when the hardware returns an unsupported or invalid rate.

Patch 2 addresses a related issue reported by Pavel Machek: the goto-based
early-exit pattern in rsci_set_termios() was obscuring the control flow.
Since RSCI only ever uses a single clock source (SCI_FCK), the multi-clock
candidate tracking variables (best_clk, min_err, brr1, srr1, cks1) were
redundant. These are removed and the goto is replaced with a straight
forward positive conditional block. ccr0_val and ccr4_val are also dropped
in favour of hardcoded 0 at their writes.

v1->v2:
 * Add a patch for avoiding divide-by-zero fault.
 * Dropped the check (abs(err) < abs(min_err) as it is always true.
 * Dropped variables best_clk and min_err as they are no longer needed.
 * Dropped intermediate variables brr1, cks1 and srr1; results are now
   written directly into brr, cks and srr.
 * Moved dev_dbg() inside the if (baud) block.
 * Dropped ccr0_val and ccr4_val, replaced with hardcoded 0 at their
   write sites, as they were never modified from their initial values.
 * Scoped variables err and srr locally within the if (baud) block.
 * Updated commit description.

Biju Das (2):
  serial: sh-sci: Avoid divide by zero
  serial: rsci: Remove goto and refactor baud rate clock selection

 drivers/tty/serial/rsci.c   | 36 +++++++++++++-----------------------
 drivers/tty/serial/sh-sci.c |  3 ++-
 2 files changed, 15 insertions(+), 24 deletions(-)

-- 
2.43.0


^ permalink raw reply

* [PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero fault
From: Biju @ 2026-04-08 14:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Biju Das, Geert Uytterhoeven, Thierry Bultel, Wolfram Sang,
	Lad Prabhakar, linux-kernel, linux-serial, Biju Das,
	linux-renesas-soc
In-Reply-To: <20260408142105.310210-1-biju.das.jz@bp.renesas.com>

From: Biju Das <biju.das.jz@bp.renesas.com>

uart_update_timeout() computes a timeout value by dividing by the baud
rate. If baud is zero — which can occur when the hardware returns an
unsupported or invalid rate — this results in a divide-by-zero fault.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v2:
 * New patch
---
 drivers/tty/serial/rsci.c   | 3 ++-
 drivers/tty/serial/sh-sci.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/rsci.c b/drivers/tty/serial/rsci.c
index b00c9e385169..a0858bab0822 100644
--- a/drivers/tty/serial/rsci.c
+++ b/drivers/tty/serial/rsci.c
@@ -286,7 +286,8 @@ static void rsci_set_termios(struct uart_port *port, struct ktermios *termios,
 	sci_port_enable(s);
 	uart_port_lock_irqsave(port, &flags);
 
-	uart_update_timeout(port, termios->c_cflag, baud);
+	if (baud)
+		uart_update_timeout(port, termios->c_cflag, baud);
 
 	rsci_serial_out(port, CCR0, ccr0_val);
 
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 6c819b6b2425..429e89106ee3 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -2805,7 +2805,8 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
 
 	sci_reset(port);
 
-	uart_update_timeout(port, termios->c_cflag, baud);
+	if (baud)
+		uart_update_timeout(port, termios->c_cflag, baud);
 
 	/* byte size and parity */
 	bits = tty_get_frame_size(termios->c_cflag);
-- 
2.43.0


^ permalink raw reply related

* [PATCH v2 2/2] serial: rsci: Remove goto and refactor baud rate clock selection
From: Biju @ 2026-04-08 14:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Biju Das, Geert Uytterhoeven, Thierry Bultel, Wolfram Sang,
	Lad Prabhakar, linux-kernel, linux-serial, Biju Das,
	linux-renesas-soc, Pavel Machek
In-Reply-To: <20260408142105.310210-1-biju.das.jz@bp.renesas.com>

From: Biju Das <biju.das.jz@bp.renesas.com>

Replace the goto done pattern in rsci_set_termios() with a positive
conditional block. When baud rate is zero, the clock selection logic
is now simply skipped rather than jumping to a 'done' label, eliminating
the goto entirely.

Since RSCI only uses a single clock source (SCI_FCK), the multi-clock
tracking variables (best_clk, min_err, brr1, srr1, cks1) are redundant
and removed. ccr0_val and ccr4_val are likewise dropped, replaced with
hardcoded 0 at their write sites, as they were never modified from their
initial zero values.

No functional change intended.

Reported-by: Pavel Machek <pavel@nabladev.com>
Closes: https://lore.kernel.org/all/abPpZULsXhRmXTX9@duo.ucw.cz/
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v1->v2:
 * Dropped the check (abs(err) < abs(min_err) as it is always true.
 * Dropped the check (abs(err) < abs(min_err) as it is always true.
 * Dropped variables best_clk and min_err as they are no longer needed.
 * Dropped intermediate variables brr1, cks1 and srr1; results are now
   written directly into brr, cks and srr.
 * Moved dev_dbg() inside the if (baud) block.
 * Dropped ccr0_val and ccr4_val, replaced with hardcoded 0 at their
   write sites, as they were never modified from their initial values.
 * Scoped variables err and srr locally within the if (baud) block.
 * Updated commit description.
---
 drivers/tty/serial/rsci.c | 33 +++++++++++----------------------
 1 file changed, 11 insertions(+), 22 deletions(-)

diff --git a/drivers/tty/serial/rsci.c b/drivers/tty/serial/rsci.c
index a0858bab0822..c2440fd5c02d 100644
--- a/drivers/tty/serial/rsci.c
+++ b/drivers/tty/serial/rsci.c
@@ -217,16 +217,13 @@ static void rsci_set_termios(struct uart_port *port, struct ktermios *termios,
 			     const struct ktermios *old)
 {
 	unsigned int ccr2_val = CCR2_INIT, ccr3_val = CCR3_INIT;
-	unsigned int ccr0_val = 0, ccr1_val = 0, ccr4_val = 0;
-	unsigned int brr1 = 255, cks1 = 0, srr1 = 15;
 	struct sci_port *s = to_sci_port(port);
 	unsigned int brr = 255, cks = 0;
-	int min_err = INT_MAX, err;
-	unsigned long max_freq = 0;
+	unsigned int ccr1_val = 0;
+	unsigned long max_freq;
 	unsigned int baud, i;
 	unsigned long flags;
 	unsigned int ctrl;
-	int best_clk = -1;
 
 	if ((termios->c_cflag & CSIZE) == CS7) {
 		ccr3_val |= CCR3_CHR0;
@@ -265,23 +262,15 @@ static void rsci_set_termios(struct uart_port *port, struct ktermios *termios,
 	}
 
 	baud = uart_get_baud_rate(port, termios, old, 0, max_freq);
-	if (!baud)
-		goto done;
-
-	/* Divided Functional Clock using standard Bit Rate Register */
-	err = sci_scbrr_calc(s, baud, &brr1, &srr1, &cks1);
-	if (abs(err) < abs(min_err)) {
-		best_clk = SCI_FCK;
-		ccr0_val = 0;
-		min_err = err;
-		brr = brr1;
-		cks = cks1;
-	}
+	if (baud) {
+		unsigned int srr;
+		int err;
 
-done:
-	if (best_clk >= 0)
+		/* Divided Functional Clock using standard Bit Rate Register */
+		err = sci_scbrr_calc(s, baud, &brr, &srr, &cks);
 		dev_dbg(port->dev, "Using clk %pC for %u%+d bps\n",
-			s->clks[best_clk], baud, min_err);
+			s->clks[SCI_FCK], baud, err);
+	}
 
 	sci_port_enable(s);
 	uart_port_lock_irqsave(port, &flags);
@@ -289,7 +278,7 @@ static void rsci_set_termios(struct uart_port *port, struct ktermios *termios,
 	if (baud)
 		uart_update_timeout(port, termios->c_cflag, baud);
 
-	rsci_serial_out(port, CCR0, ccr0_val);
+	rsci_serial_out(port, CCR0, 0);
 
 	ccr3_val |= CCR3_FM;
 	rsci_serial_out(port, CCR3, ccr3_val);
@@ -298,7 +287,7 @@ static void rsci_set_termios(struct uart_port *port, struct ktermios *termios,
 	rsci_serial_out(port, CCR2, ccr2_val);
 
 	rsci_serial_out(port, CCR1, ccr1_val);
-	rsci_serial_out(port, CCR4, ccr4_val);
+	rsci_serial_out(port, CCR4, 0);
 
 	ctrl = rsci_serial_in(port, FCR);
 	ctrl |= (FCR_RFRST | FCR_TFRST);
-- 
2.43.0


^ permalink raw reply related

* Re: [PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero fault
From: Geert Uytterhoeven @ 2026-04-08 15:39 UTC (permalink / raw)
  To: Biju
  Cc: Greg Kroah-Hartman, Jiri Slaby, Biju Das, Thierry Bultel,
	Wolfram Sang, Lad Prabhakar, linux-kernel, linux-serial,
	linux-renesas-soc
In-Reply-To: <20260408142105.310210-2-biju.das.jz@bp.renesas.com>

Hi Biju,

On Wed, 8 Apr 2026 at 16:21, Biju <biju.das.au@gmail.com> wrote:
> From: Biju Das <biju.das.jz@bp.renesas.com>
>
> uart_update_timeout() computes a timeout value by dividing by the baud
> rate. If baud is zero — which can occur when the hardware returns an
> unsupported or invalid rate — this results in a divide-by-zero fault.
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>

Thanks for your patch!

> --- a/drivers/tty/serial/rsci.c
> +++ b/drivers/tty/serial/rsci.c
> @@ -286,7 +286,8 @@ static void rsci_set_termios(struct uart_port *port, struct ktermios *termios,
>         sci_port_enable(s);
>         uart_port_lock_irqsave(port, &flags);
>
> -       uart_update_timeout(port, termios->c_cflag, baud);
> +       if (baud)
> +               uart_update_timeout(port, termios->c_cflag, baud);
>
>         rsci_serial_out(port, CCR0, ccr0_val);
>
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index 6c819b6b2425..429e89106ee3 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -2805,7 +2805,8 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
>
>         sci_reset(port);
>
> -       uart_update_timeout(port, termios->c_cflag, baud);
> +       if (baud)
> +               uart_update_timeout(port, termios->c_cflag, baud);

Nice catches!

>
>         /* byte size and parity */
>         bits = tty_get_frame_size(termios->c_cflag);

I think there's another one out of context, which can even trigger with
baud == 75:

        s->rx_frame = (10000 * bits) / (baud / 100);

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* Re: [PATCH v2 2/2] serial: rsci: Remove goto and refactor baud rate clock selection
From: Geert Uytterhoeven @ 2026-04-08 15:45 UTC (permalink / raw)
  To: Biju
  Cc: Greg Kroah-Hartman, Jiri Slaby, Biju Das, Thierry Bultel,
	Wolfram Sang, Lad Prabhakar, linux-kernel, linux-serial,
	linux-renesas-soc, Pavel Machek
In-Reply-To: <20260408142105.310210-3-biju.das.jz@bp.renesas.com>

On Wed, 8 Apr 2026 at 16:21, Biju <biju.das.au@gmail.com> wrote:
> From: Biju Das <biju.das.jz@bp.renesas.com>
>
> Replace the goto done pattern in rsci_set_termios() with a positive
> conditional block. When baud rate is zero, the clock selection logic
> is now simply skipped rather than jumping to a 'done' label, eliminating
> the goto entirely.
>
> Since RSCI only uses a single clock source (SCI_FCK), the multi-clock
> tracking variables (best_clk, min_err, brr1, srr1, cks1) are redundant
> and removed. ccr0_val and ccr4_val are likewise dropped, replaced with
> hardcoded 0 at their write sites, as they were never modified from their
> initial zero values.
>
> No functional change intended.
>
> Reported-by: Pavel Machek <pavel@nabladev.com>
> Closes: https://lore.kernel.org/all/abPpZULsXhRmXTX9@duo.ucw.cz/
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v1->v2:
>  * Dropped the check (abs(err) < abs(min_err) as it is always true.
>  * Dropped the check (abs(err) < abs(min_err) as it is always true.
>  * Dropped variables best_clk and min_err as they are no longer needed.
>  * Dropped intermediate variables brr1, cks1 and srr1; results are now
>    written directly into brr, cks and srr.
>  * Moved dev_dbg() inside the if (baud) block.
>  * Dropped ccr0_val and ccr4_val, replaced with hardcoded 0 at their
>    write sites, as they were never modified from their initial values.
>  * Scoped variables err and srr locally within the if (baud) block.
>  * Updated commit description.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* Re: [PATCH v2 2/2] serial: rsci: Remove goto and refactor baud rate clock selection
From: Geert Uytterhoeven @ 2026-04-08 15:53 UTC (permalink / raw)
  To: Biju
  Cc: Greg Kroah-Hartman, Jiri Slaby, Biju Das, Thierry Bultel,
	Wolfram Sang, Lad Prabhakar, linux-kernel, linux-serial,
	linux-renesas-soc, Pavel Machek
In-Reply-To: <CAMuHMdXVbWg=nz-E0VTet2YgCP-GvmVY_3MJeZbE0Thp-mMpHQ@mail.gmail.com>

Hi Biju,

On Wed, 8 Apr 2026 at 17:45, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> On Wed, 8 Apr 2026 at 16:21, Biju <biju.das.au@gmail.com> wrote:
> > From: Biju Das <biju.das.jz@bp.renesas.com>
> >
> > Replace the goto done pattern in rsci_set_termios() with a positive
> > conditional block. When baud rate is zero, the clock selection logic
> > is now simply skipped rather than jumping to a 'done' label, eliminating
> > the goto entirely.
> >
> > Since RSCI only uses a single clock source (SCI_FCK), the multi-clock
> > tracking variables (best_clk, min_err, brr1, srr1, cks1) are redundant
> > and removed. ccr0_val and ccr4_val are likewise dropped, replaced with
> > hardcoded 0 at their write sites, as they were never modified from their
> > initial zero values.
> >
> > No functional change intended.
> >
> > Reported-by: Pavel Machek <pavel@nabladev.com>
> > Closes: https://lore.kernel.org/all/abPpZULsXhRmXTX9@duo.ucw.cz/
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> > v1->v2:
> >  * Dropped the check (abs(err) < abs(min_err) as it is always true.
> >  * Dropped the check (abs(err) < abs(min_err) as it is always true.
> >  * Dropped variables best_clk and min_err as they are no longer needed.
> >  * Dropped intermediate variables brr1, cks1 and srr1; results are now
> >    written directly into brr, cks and srr.
> >  * Moved dev_dbg() inside the if (baud) block.
> >  * Dropped ccr0_val and ccr4_val, replaced with hardcoded 0 at their
> >    write sites, as they were never modified from their initial values.
> >  * Scoped variables err and srr locally within the if (baud) block.
> >  * Updated commit description.
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

I spoke too soon, you need one more change to make it build:

--- a/drivers/tty/serial/rsci.c
+++ b/drivers/tty/serial/rsci.c
@@ -308,8 +308,7 @@ static void rsci_set_termios(struct uart_port
*port, struct ktermios *termios,
        rsci_serial_out(port, CFCLR, CFCLR_CLRFLAG);
        rsci_serial_out(port, FFCLR, FFCLR_DRC);

-       ccr0_val |= CCR0_RE;
-       rsci_serial_out(port, CCR0, ccr0_val);
+       rsci_serial_out(port, CCR0, CCR0_RE);

        if ((termios->c_cflag & CREAD) != 0)
                rsci_start_rx(port);

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* RE: [PATCH v2 2/2] serial: rsci: Remove goto and refactor baud rate clock selection
From: Biju Das @ 2026-04-08 16:01 UTC (permalink / raw)
  To: geert, biju.das.au
  Cc: Greg Kroah-Hartman, Jiri Slaby, Thierry Bultel, wsa+renesas,
	Prabhakar Mahadev Lad, linux-kernel@vger.kernel.org,
	linux-serial@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Pavel Machek
In-Reply-To: <CAMuHMdVnD7XxQood1qy7_7gz5nzFz7QDiCXP_Fo5s12zZ_qSCg@mail.gmail.com>

Hi Geert,

> -----Original Message-----
> From: Geert Uytterhoeven <geert@linux-m68k.org>
> Sent: 08 April 2026 16:53
> Subject: Re: [PATCH v2 2/2] serial: rsci: Remove goto and refactor baud rate clock selection
> 
> Hi Biju,
> 
> On Wed, 8 Apr 2026 at 17:45, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > On Wed, 8 Apr 2026 at 16:21, Biju <biju.das.au@gmail.com> wrote:
> > > From: Biju Das <biju.das.jz@bp.renesas.com>
> > >
> > > Replace the goto done pattern in rsci_set_termios() with a positive
> > > conditional block. When baud rate is zero, the clock selection logic
> > > is now simply skipped rather than jumping to a 'done' label,
> > > eliminating the goto entirely.
> > >
> > > Since RSCI only uses a single clock source (SCI_FCK), the
> > > multi-clock tracking variables (best_clk, min_err, brr1, srr1, cks1)
> > > are redundant and removed. ccr0_val and ccr4_val are likewise
> > > dropped, replaced with hardcoded 0 at their write sites, as they
> > > were never modified from their initial zero values.
> > >
> > > No functional change intended.
> > >
> > > Reported-by: Pavel Machek <pavel@nabladev.com>
> > > Closes: https://lore.kernel.org/all/abPpZULsXhRmXTX9@duo.ucw.cz/
> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > > ---
> > > v1->v2:
> > >  * Dropped the check (abs(err) < abs(min_err) as it is always true.
> > >  * Dropped the check (abs(err) < abs(min_err) as it is always true.
> > >  * Dropped variables best_clk and min_err as they are no longer needed.
> > >  * Dropped intermediate variables brr1, cks1 and srr1; results are now
> > >    written directly into brr, cks and srr.
> > >  * Moved dev_dbg() inside the if (baud) block.
> > >  * Dropped ccr0_val and ccr4_val, replaced with hardcoded 0 at their
> > >    write sites, as they were never modified from their initial values.
> > >  * Scoped variables err and srr locally within the if (baud) block.
> > >  * Updated commit description.
> >
> > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> I spoke too soon, you need one more change to make it build:
> 
> --- a/drivers/tty/serial/rsci.c
> +++ b/drivers/tty/serial/rsci.c
> @@ -308,8 +308,7 @@ static void rsci_set_termios(struct uart_port *port, struct ktermios *termios,
>         rsci_serial_out(port, CFCLR, CFCLR_CLRFLAG);
>         rsci_serial_out(port, FFCLR, FFCLR_DRC);
> 
> -       ccr0_val |= CCR0_RE;
> -       rsci_serial_out(port, CCR0, ccr0_val);
> +       rsci_serial_out(port, CCR0, CCR0_RE);

Oops, I missed this.

Cheers,
Biju

^ permalink raw reply

* RE: [PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero fault
From: Biju Das @ 2026-04-08 16:05 UTC (permalink / raw)
  To: geert, biju.das.au
  Cc: Greg Kroah-Hartman, Jiri Slaby, Thierry Bultel, wsa+renesas,
	Prabhakar Mahadev Lad, linux-kernel@vger.kernel.org,
	linux-serial@vger.kernel.org, linux-renesas-soc@vger.kernel.org
In-Reply-To: <CAMuHMdW5_k+iBekmV47W+Qqt5qDLMrLMRWZnnH5wCNP8E30N3A@mail.gmail.com>

Hi Geert,

Thanks for the feedback.

> -----Original Message-----
> From: Geert Uytterhoeven <geert@linux-m68k.org>
> Sent: 08 April 2026 16:39
> Subject: Re: [PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero fault
> 
> Hi Biju,
> 
> On Wed, 8 Apr 2026 at 16:21, Biju <biju.das.au@gmail.com> wrote:
> > From: Biju Das <biju.das.jz@bp.renesas.com>
> >
> > uart_update_timeout() computes a timeout value by dividing by the baud
> > rate. If baud is zero — which can occur when the hardware returns an
> > unsupported or invalid rate — this results in a divide-by-zero fault.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> 
> Thanks for your patch!
> 
> > --- a/drivers/tty/serial/rsci.c
> > +++ b/drivers/tty/serial/rsci.c
> > @@ -286,7 +286,8 @@ static void rsci_set_termios(struct uart_port *port, struct ktermios *termios,
> >         sci_port_enable(s);
> >         uart_port_lock_irqsave(port, &flags);
> >
> > -       uart_update_timeout(port, termios->c_cflag, baud);
> > +       if (baud)
> > +               uart_update_timeout(port, termios->c_cflag, baud);
> >
> >         rsci_serial_out(port, CCR0, ccr0_val);
> >
> > diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> > index 6c819b6b2425..429e89106ee3 100644
> > --- a/drivers/tty/serial/sh-sci.c
> > +++ b/drivers/tty/serial/sh-sci.c
> > @@ -2805,7 +2805,8 @@ static void sci_set_termios(struct uart_port
> > *port, struct ktermios *termios,
> >
> >         sci_reset(port);
> >
> > -       uart_update_timeout(port, termios->c_cflag, baud);
> > +       if (baud)
> > +               uart_update_timeout(port, termios->c_cflag, baud);
> 
> Nice catches!
> 
> >
> >         /* byte size and parity */
> >         bits = tty_get_frame_size(termios->c_cflag);
> 
> I think there's another one out of context, which can even trigger with baud == 75:
> 

Will add a check, if (baud > 99)

Cheers,
Biju

>         s->rx_frame = (10000 * bits) / (baud / 100);
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But when I'm talking to
> journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds

^ permalink raw reply

* RE: [PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero fault
From: Biju Das @ 2026-04-08 16:35 UTC (permalink / raw)
  To: Hugo Villeneuve, biju.das.au
  Cc: Greg Kroah-Hartman, Jiri Slaby, Geert Uytterhoeven,
	Thierry Bultel, wsa+renesas, Prabhakar Mahadev Lad,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org
In-Reply-To: <20260408123039.922a75327fd7672df3bd61da@hugovil.com>

Hi Hugo,

Thanks for the feedback.

> -----Original Message-----
> From: Hugo Villeneuve <hugo@hugovil.com>
> Sent: 08 April 2026 17:31
> Subject: Re: [PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero fault
> 
> Hi Biju,
> 
> On Wed,  8 Apr 2026 15:20:58 +0100
> Biju <biju.das.au@gmail.com> wrote:
> 
> > From: Biju Das <biju.das.jz@bp.renesas.com>
> >
> > uart_update_timeout() computes a timeout value by dividing by the baud
> > rate. If baud is zero — which can occur when the hardware returns an
> > unsupported or invalid rate — this results in a divide-by-zero fault.
> 
> baud is returned by uart_get_baud_rate(), so this is not returned by the hardware?

You are tight, Will update commit description.
> 
> 
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> 
> Missing Fixes tag?

I will split patch into 2 adding Fixes tag.

> 
> 
> > ---
> > v2:
> >  * New patch
> > ---
> >  drivers/tty/serial/rsci.c   | 3 ++-
> >  drivers/tty/serial/sh-sci.c | 3 ++-
> >  2 files changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/tty/serial/rsci.c b/drivers/tty/serial/rsci.c
> > index b00c9e385169..a0858bab0822 100644
> > --- a/drivers/tty/serial/rsci.c
> > +++ b/drivers/tty/serial/rsci.c
> > @@ -286,7 +286,8 @@ static void rsci_set_termios(struct uart_port *port, struct ktermios *termios,
> >  	sci_port_enable(s);
> >  	uart_port_lock_irqsave(port, &flags);
> >
> > -	uart_update_timeout(port, termios->c_cflag, baud);
> > +	if (baud)
> > +		uart_update_timeout(port, termios->c_cflag, baud);
> >
> >  	rsci_serial_out(port, CCR0, ccr0_val);
> >
> > diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> > index 6c819b6b2425..429e89106ee3 100644
> > --- a/drivers/tty/serial/sh-sci.c
> > +++ b/drivers/tty/serial/sh-sci.c
> > @@ -2805,7 +2805,8 @@ static void sci_set_termios(struct uart_port
> > *port, struct ktermios *termios,
> >
> >  	sci_reset(port);
> >
> > -	uart_update_timeout(port, termios->c_cflag, baud);
> > +	if (baud)
> > +		uart_update_timeout(port, termios->c_cflag, baud);
> 
> After this patch, have you re-tested if having baud = 0 produces any other errors? A litle bit later in
> the same function, there is this
> code:

+	/* Avoid divide-by-zero fault in divider operations */
+	if (!baud)
+		baud = 100;
+

Plan is to update the code with the above change, that will cover
All divide-by-zero case in this function.

Cheers,
Biju

^ permalink raw reply

* Re: [PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero fault
From: Hugo Villeneuve @ 2026-04-08 16:30 UTC (permalink / raw)
  To: Biju
  Cc: Greg Kroah-Hartman, Jiri Slaby, Biju Das, Geert Uytterhoeven,
	Thierry Bultel, Wolfram Sang, Lad Prabhakar, linux-kernel,
	linux-serial, linux-renesas-soc
In-Reply-To: <20260408142105.310210-2-biju.das.jz@bp.renesas.com>

Hi Biju,

On Wed,  8 Apr 2026 15:20:58 +0100
Biju <biju.das.au@gmail.com> wrote:

> From: Biju Das <biju.das.jz@bp.renesas.com>
> 
> uart_update_timeout() computes a timeout value by dividing by the baud
> rate. If baud is zero — which can occur when the hardware returns an
> unsupported or invalid rate — this results in a divide-by-zero fault.

baud is returned by uart_get_baud_rate(), so this is not returned
by the hardware?


> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>

Missing Fixes tag?


> ---
> v2:
>  * New patch
> ---
>  drivers/tty/serial/rsci.c   | 3 ++-
>  drivers/tty/serial/sh-sci.c | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/rsci.c b/drivers/tty/serial/rsci.c
> index b00c9e385169..a0858bab0822 100644
> --- a/drivers/tty/serial/rsci.c
> +++ b/drivers/tty/serial/rsci.c
> @@ -286,7 +286,8 @@ static void rsci_set_termios(struct uart_port *port, struct ktermios *termios,
>  	sci_port_enable(s);
>  	uart_port_lock_irqsave(port, &flags);
>  
> -	uart_update_timeout(port, termios->c_cflag, baud);
> +	if (baud)
> +		uart_update_timeout(port, termios->c_cflag, baud);
>  
>  	rsci_serial_out(port, CCR0, ccr0_val);
>  
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index 6c819b6b2425..429e89106ee3 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -2805,7 +2805,8 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
>  
>  	sci_reset(port);
>  
> -	uart_update_timeout(port, termios->c_cflag, baud);
> +	if (baud)
> +		uart_update_timeout(port, termios->c_cflag, baud);

After this patch, have you re-tested if having baud = 0 produces any
other errors? A litle bit later in the same function, there is this
code:

    /* Calculate delay for 2 DMA buffers (4 FIFO). */
    s->rx_frame = (10000 * bits) / (baud / 100);

Does this trigger a division by zero fault?

There is also this:

	if ((srr + 1 == 5) &&
	    (s->type == PORT_SCIFA || s->type == PORT_SCIFB)) {
            ...
		udelay(DIV_ROUND_UP(10 * 1000000, baud));

Can this also trigger a division by zero fault?


>  
>  	/* byte size and parity */
>  	bits = tty_get_frame_size(termios->c_cflag);
> -- 
> 2.43.0
> 
> 


-- 
Hugo Villeneuve

^ permalink raw reply

* Re: [PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero fault
From: Hugo Villeneuve @ 2026-04-08 16:51 UTC (permalink / raw)
  To: Biju Das
  Cc: biju.das.au, Greg Kroah-Hartman, Jiri Slaby, Geert Uytterhoeven,
	Thierry Bultel, wsa+renesas, Prabhakar Mahadev Lad,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org
In-Reply-To: <TYCPR01MB11332B594964DDF0763499184865B2@TYCPR01MB11332.jpnprd01.prod.outlook.com>

Hi Biju,

On Wed, 8 Apr 2026 16:35:44 +0000
Biju Das <biju.das.jz@bp.renesas.com> wrote:

> Hi Hugo,
> 
> Thanks for the feedback.
> 
> > -----Original Message-----
> > From: Hugo Villeneuve <hugo@hugovil.com>
> > Sent: 08 April 2026 17:31
> > Subject: Re: [PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero fault
> > 
> > Hi Biju,
> > 
> > On Wed,  8 Apr 2026 15:20:58 +0100
> > Biju <biju.das.au@gmail.com> wrote:
> > 
> > > From: Biju Das <biju.das.jz@bp.renesas.com>
> > >
> > > uart_update_timeout() computes a timeout value by dividing by the baud
> > > rate. If baud is zero — which can occur when the hardware returns an
> > > unsupported or invalid rate — this results in a divide-by-zero fault.
> > 
> > baud is returned by uart_get_baud_rate(), so this is not returned by the hardware?
> 
> You are tight, Will update commit description.

How can uart_get_baud_rate() return a zero value? If I am not mistaken
even for the B0 case, it will return 9600?

What are other consequences if a zero value is returned apart
from the division by zero fault? Is it ok (or logical) then to proceed
with the rest of the configuration?

> > 
> > 
> > >
> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > 
> > Missing Fixes tag?
> 
> I will split patch into 2 adding Fixes tag.
> 
> > 
> > 
> > > ---
> > > v2:
> > >  * New patch
> > > ---
> > >  drivers/tty/serial/rsci.c   | 3 ++-
> > >  drivers/tty/serial/sh-sci.c | 3 ++-
> > >  2 files changed, 4 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/tty/serial/rsci.c b/drivers/tty/serial/rsci.c
> > > index b00c9e385169..a0858bab0822 100644
> > > --- a/drivers/tty/serial/rsci.c
> > > +++ b/drivers/tty/serial/rsci.c
> > > @@ -286,7 +286,8 @@ static void rsci_set_termios(struct uart_port *port, struct ktermios *termios,
> > >  	sci_port_enable(s);
> > >  	uart_port_lock_irqsave(port, &flags);
> > >
> > > -	uart_update_timeout(port, termios->c_cflag, baud);
> > > +	if (baud)
> > > +		uart_update_timeout(port, termios->c_cflag, baud);
> > >
> > >  	rsci_serial_out(port, CCR0, ccr0_val);
> > >
> > > diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> > > index 6c819b6b2425..429e89106ee3 100644
> > > --- a/drivers/tty/serial/sh-sci.c
> > > +++ b/drivers/tty/serial/sh-sci.c
> > > @@ -2805,7 +2805,8 @@ static void sci_set_termios(struct uart_port
> > > *port, struct ktermios *termios,
> > >
> > >  	sci_reset(port);
> > >
> > > -	uart_update_timeout(port, termios->c_cflag, baud);
> > > +	if (baud)
> > > +		uart_update_timeout(port, termios->c_cflag, baud);
> > 
> > After this patch, have you re-tested if having baud = 0 produces any other errors? A litle bit later in
> > the same function, there is this
> > code:
> 
> +	/* Avoid divide-by-zero fault in divider operations */
> +	if (!baud)
> +		baud = 100;
> +
> 
> Plan is to update the code with the above change, that will cover
> All divide-by-zero case in this function.

As stated above, does it makes sense to proceed if baud was zero?

> 
> Cheers,
> Biju


-- 
Hugo Villeneuve

^ permalink raw reply

* RE: [PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero fault
From: Biju Das @ 2026-04-08 17:25 UTC (permalink / raw)
  To: Hugo Villeneuve
  Cc: biju.das.au, Greg Kroah-Hartman, Jiri Slaby, Geert Uytterhoeven,
	Thierry Bultel, wsa+renesas, Prabhakar Mahadev Lad,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org
In-Reply-To: <20260408125142.24cd94f094ba3ca512e7f346@hugovil.com>

Hi Hugo,

> -----Original Message-----
> From: Hugo Villeneuve <hugo@hugovil.com>
> Sent: 08 April 2026 17:52
> Subject: Re: [PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero fault
> 
> Hi Biju,
> 
> On Wed, 8 Apr 2026 16:35:44 +0000
> Biju Das <biju.das.jz@bp.renesas.com> wrote:
> 
> > Hi Hugo,
> >
> > Thanks for the feedback.
> >
> > > -----Original Message-----
> > > From: Hugo Villeneuve <hugo@hugovil.com>
> > > Sent: 08 April 2026 17:31
> > > Subject: Re: [PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero
> > > fault
> > >
> > > Hi Biju,
> > >
> > > On Wed,  8 Apr 2026 15:20:58 +0100
> > > Biju <biju.das.au@gmail.com> wrote:
> > >
> > > > From: Biju Das <biju.das.jz@bp.renesas.com>
> > > >
> > > > uart_update_timeout() computes a timeout value by dividing by the
> > > > baud rate. If baud is zero — which can occur when the hardware
> > > > returns an unsupported or invalid rate — this results in a divide-by-zero fault.
> > >
> > > baud is returned by uart_get_baud_rate(), so this is not returned by the hardware?
> >
> > You are tight, Will update commit description.
> 
> How can uart_get_baud_rate() return a zero value? If I am not mistaken even for the B0 case, it will
> return 9600?

As per the comment and code, this API can return 0.

* If the new baud rate is invalid, try the @old termios setting. If it's still
* invalid, we try 9600 baud. If that is also invalid 0 is returned.

In drives/tty currently only 1 driver is checking the return value
and it calls panic

https://elixir.bootlin.com/linux/v7.0-rc7/source/drivers/tty/serial/apbuart.c#L214


I believe we should call panic, if baud =0, instead of proceeding.

Geert, any thoughts??

Cheers,
Biju

^ permalink raw reply

* Re: [PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero fault
From: Hugo Villeneuve @ 2026-04-08 18:15 UTC (permalink / raw)
  To: Biju Das
  Cc: biju.das.au, Greg Kroah-Hartman, Jiri Slaby, Geert Uytterhoeven,
	Thierry Bultel, wsa+renesas, Prabhakar Mahadev Lad,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org
In-Reply-To: <TYCPR01MB11332859E901171C91C543061865B2@TYCPR01MB11332.jpnprd01.prod.outlook.com>

Hi Biju,

On Wed, 8 Apr 2026 17:25:19 +0000
Biju Das <biju.das.jz@bp.renesas.com> wrote:

> Hi Hugo,
> 
> > -----Original Message-----
> > From: Hugo Villeneuve <hugo@hugovil.com>
> > Sent: 08 April 2026 17:52
> > Subject: Re: [PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero fault
> > 
> > Hi Biju,
> > 
> > On Wed, 8 Apr 2026 16:35:44 +0000
> > Biju Das <biju.das.jz@bp.renesas.com> wrote:
> > 
> > > Hi Hugo,
> > >
> > > Thanks for the feedback.
> > >
> > > > -----Original Message-----
> > > > From: Hugo Villeneuve <hugo@hugovil.com>
> > > > Sent: 08 April 2026 17:31
> > > > Subject: Re: [PATCH v2 1/2] serial: sh-sci: Avoid divide-by-zero
> > > > fault
> > > >
> > > > Hi Biju,
> > > >
> > > > On Wed,  8 Apr 2026 15:20:58 +0100
> > > > Biju <biju.das.au@gmail.com> wrote:
> > > >
> > > > > From: Biju Das <biju.das.jz@bp.renesas.com>
> > > > >
> > > > > uart_update_timeout() computes a timeout value by dividing by the
> > > > > baud rate. If baud is zero — which can occur when the hardware
> > > > > returns an unsupported or invalid rate — this results in a divide-by-zero fault.
> > > >
> > > > baud is returned by uart_get_baud_rate(), so this is not returned by the hardware?
> > >
> > > You are tight, Will update commit description.
> > 
> > How can uart_get_baud_rate() return a zero value? If I am not mistaken even for the B0 case, it will
> > return 9600?
> 
> As per the comment and code, this API can return 0.
> 
> * If the new baud rate is invalid, try the @old termios setting. If it's still
> * invalid, we try 9600 baud. If that is also invalid 0 is returned.
> 
> In drives/tty currently only 1 driver is checking the return value
> and it calls panic
> 
> https://elixir.bootlin.com/linux/v7.0-rc7/source/drivers/tty/serial/apbuart.c#L214

Hmmm, more than 1:

icom.c:
    if (!baud)
         baud = 9600;    /* B0 transition handled in rs_set_termios */

8250/8250_fintek.c:
    if (!baud)
         goto exit;

> I believe we should call panic, if baud =0, instead of proceeding.
> Geert, any thoughts??

There once was a warning, removed by:

commit 23bf72faaebdf2cb199c0ef8cf96467b10904b35
Author: Max Filippov <jcmvbkbc@gmail.com>
Date:   Tue Oct 10 01:59:22 2023 -0700
    serial: core: tidy invalid baudrate handling in uart_get_baud_rate
    ...
    Clarify that 0 can be (and always could be) returned from the
    uart_get_baud_rate. Don't issue a warning in that case.
    ...

-- 
Hugo Villeneuve

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox