[PATCH] serial: sifive: remove busy-loops from getc and putc ops
Naveen Kumar Chaudhary
naveen.osdev at gmail.com
Sun Jun 7 17:36:31 CEST 2026
The DM serial framework in __serial_getc() and __serial_putc() already
retries when driver ops return -EAGAIN, calling schedule() between
attempts to service the watchdog.
sifive_serial_getc() and sifive_serial_putc() spin internally on
-EAGAIN, which prevents the framework from calling schedule(). This can
lead to watchdog timeouts when waiting for RX data or TX FIFO space.
Remove the busy-loops and return -EAGAIN directly from the underlying
helpers, letting the framework handle retries with proper watchdog
servicing. This is consistent with how other DM serial drivers (pl01x,
meson, cortina, etc.) implement their ops.
Signed-off-by: Naveen Kumar Chaudhary <naveen.osdev at gmail.com>
---
drivers/serial/serial_sifive.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/serial/serial_sifive.c b/drivers/serial/serial_sifive.c
index e47828e4d6a..0203e2fc37c 100644
--- a/drivers/serial/serial_sifive.c
+++ b/drivers/serial/serial_sifive.c
@@ -144,23 +144,16 @@ static int sifive_serial_probe(struct udevice *dev)
static int sifive_serial_getc(struct udevice *dev)
{
- int c;
struct sifive_uart_plat *plat = dev_get_plat(dev);
- struct uart_sifive *regs = plat->regs;
-
- while ((c = _sifive_serial_getc(regs)) == -EAGAIN) ;
- return c;
+ return _sifive_serial_getc(plat->regs);
}
static int sifive_serial_putc(struct udevice *dev, const char ch)
{
- int rc;
struct sifive_uart_plat *plat = dev_get_plat(dev);
- while ((rc = _sifive_serial_putc(plat->regs, ch)) == -EAGAIN) ;
-
- return rc;
+ return _sifive_serial_putc(plat->regs, ch);
}
static int sifive_serial_pending(struct udevice *dev, bool input)
--
2.43.0
More information about the U-Boot
mailing list