lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 10 Sep 2014 21:33:21 +0200
From:	Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To:	Jiri Slaby <jslaby@...e.cz>,
	Peter Hurley <peter@...leysoftware.com>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org,
	Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Subject: [RFC PATCH] tty: serial: core: Only invoke ->start_tx() if there is data to send

I noticed that the serial8250_tx_dma() is invoked sometimes while
uart_circ_empty() says that the buffer is empty.

I tracked one occuring down to:

n_tty_write()
	 => O_OPOST(tty))
	   => the while loop did something but neither tty's ->write()
	      nor its ->uart_put_char() callback was invoked().
	   => tty->ops->flush_chars() is invoked with an empty buffer.

For the 8250 uart driver we end up with:
- DMA enabled
  nothing, just return (except there is DMA_TX bug or runtime-PM then we
  behave like in the no DMA case)

- no DMA
  enable THRI interrupt, wait for it, disable THRI interrupt again
  because there is nothing to be done.

While I don't know if it safe to drop that flush in n_tty if the buffer
is empty, it should not do any harm in serial's core part to not invoke
->start_tx() if the buffer is empty.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
---
 drivers/tty/serial/serial_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 5a78f6940760..e55724a911d5 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -90,7 +90,8 @@ static void __uart_start(struct tty_struct *tty)
 	struct uart_state *state = tty->driver_data;
 	struct uart_port *port = state->uart_port;
 
-	if (!tty->stopped && !tty->hw_stopped)
+	if (!tty->stopped && !tty->hw_stopped &&
+			!uart_circ_empty(&port->state->xmit))
 		port->ops->start_tx(port);
 }
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ