Linux Serial subsystem development
 help / color / mirror / Atom feed
* [PATCH] serial: earlycon: bail out on zero progress in SBI DBCN write
@ 2026-11-23  9:48 liutong
  2026-11-23  9:51 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: liutong @ 2026-11-23  9:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Palmer Dabbelt, Anup Patel, linux-serial, linux-riscv,
	linux-kernel, stable

sbi_dbcn_console_write() loops until all bytes are written and exits
early only on an error. When sbi_debug_console_write() returns 0 it
stays in the loop forever.

A zero return is not an error. Per the SBI specification, the call "may
do partial/no writes if the debug console is not able to accept more
bytes".

OpenSBI can return 0 here. Its semihosting console reports 0 when a host
write fails, and SBI passes that number back unchanged.

Fix the check to use <= instead of <, so that a zero return also ends
the loop.

Fixes: c77bf3607a0f ("tty/serial: Add RISC-V SBI debug console based earlycon")
Cc: stable@vger.kernel.org
Signed-off-by: liutong <liutong@iscas.ac.cn>
---
 drivers/tty/serial/earlycon-riscv-sbi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/earlycon-riscv-sbi.c b/drivers/tty/serial/earlycon-riscv-sbi.c
index 0162155f0c83..a8ffee389e15 100644
--- a/drivers/tty/serial/earlycon-riscv-sbi.c
+++ b/drivers/tty/serial/earlycon-riscv-sbi.c
@@ -29,7 +29,7 @@ static void sbi_dbcn_console_write(struct console *con,
 
 	while (n) {
 		ret = sbi_debug_console_write(s, n);
-		if (ret < 0)
+		if (ret <= 0)
 			break;
 
 		s += ret;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] serial: earlycon: bail out on zero progress in SBI DBCN write
  2026-11-23  9:48 [PATCH] serial: earlycon: bail out on zero progress in SBI DBCN write liutong
@ 2026-11-23  9:51 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-23  9:51 UTC (permalink / raw)
  To: liutong; +Cc: linux-serial

> sbi_dbcn_console_write() loops until all bytes are written and exits
> early only on an error. When sbi_debug_console_write() returns 0 it
> stays in the loop forever.
> 
> A zero return is not an error. Per the SBI specification, the call "may
> do partial/no writes if the debug console is not able to accept more
> bytes".
> 
> OpenSBI can return 0 here. Its semihosting console reports 0 when a host
> write fails, and SBI passes that number back unchanged.
> 
> Fix the check to use <= instead of <, so that a zero return also ends
> the loop.
> 
> Fixes: c77bf3607a0f ("tty/serial: Add RISC-V SBI debug console based earlycon")
> Cc: stable@vger.kernel.org
> Signed-off-by: liutong <liutong@iscas.ac.cn>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123094843.540808-1-liutong@iscas.ac.cn?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-23  9:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23  9:48 [PATCH] serial: earlycon: bail out on zero progress in SBI DBCN write liutong
2026-11-23  9:51 ` sashiko-bot

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