From: Simon Glass <simon.glass@canonical.com> When characters cannot be sent to the serial port, return an error code so that the uclass can try again. This fixes a problem with gnome-terminal which seems to get behind and then drop output when a large amount of output is produced quickly (e.g. 100K in under a second). Since sandbox often writes to the device one character at a time it does place a substantial load on the other end of the PTY. Quite possibly it does not empty the pipe quickly enough and so writing to the PTY fails. Signed-off-by: Simon Glass <simon.glass@canonical.com> --- drivers/serial/sandbox.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c index cc0491bc3c8..227524ae911 100644 --- a/drivers/serial/sandbox.c +++ b/drivers/serial/sandbox.c @@ -94,13 +94,16 @@ static void sandbox_print_color(struct udevice *dev) static int sandbox_serial_putc(struct udevice *dev, const char ch) { struct sandbox_serial_priv *priv = dev_get_priv(dev); + ssize_t ret; if (ch == '\n') priv->start_of_line = true; if (sandbox_serial_enabled) { sandbox_print_color(dev); - os_write(1, &ch, 1); + ret = os_write(1, &ch, 1); + if (ret != 1) + return -EAGAIN; } _sandbox_serial_written += 1; return 0; @@ -120,6 +123,8 @@ static ssize_t sandbox_serial_puts(struct udevice *dev, const char *s, ret = os_write(1, s, len); if (ret < 0) return ret; + if (ret != len) + return -EAGAIN; } else { ret = len; } -- 2.43.0