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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 31 Jan 2020 16:34:45 +0530
From:   Shubhrajyoti Datta <shubhrajyoti.datta@...inx.com>
To:     linux-serial@...r.kernel.org
Cc:     gregkh@...uxfoundation.org, jslaby@...e.com,
        michal.simek@...inx.com, linux-kernel@...r.kernel.org,
        Raviteja Narayanam <raviteja.narayanam@...inx.com>,
        Shubhrajyoti Datta <shubhrajyoti.datta@...inx.com>
Subject: [PATCH v3] serial: uartps: Add TACTIVE bit in cdns_uart_tx_empty function

From: Raviteja Narayanam <raviteja.narayanam@...inx.com>

Make sure that all the bytes are transmitted out of Uart by monitoring
TACTIVE bit as well.
Before setting up baud rate in set termios function, do not wait for
Tx empty as it is taken care by the tty layer if user specified.

Signed-off-by: Raviteja Narayanam <raviteja.narayanam@...inx.com>
Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@...inx.com>
---
v3:
removed the wait from the set_termios and added the TACTIVE to cdns_uart_tx_empty
As suggested by Johan.

 drivers/tty/serial/xilinx_uartps.c | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index ed2f325..ebd0a74 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -32,7 +32,6 @@
 #define CDNS_UART_NAME		"xuartps"
 #define CDNS_UART_FIFO_SIZE	64	/* FIFO size */
 #define CDNS_UART_REGISTER_SPACE	0x1000
-#define TX_TIMEOUT		500000
 
 /* Rx Trigger level */
 static int rx_trigger_level = 56;
@@ -656,8 +655,9 @@ static unsigned int cdns_uart_tx_empty(struct uart_port *port)
 {
 	unsigned int status;
 
-	status = readl(port->membase + CDNS_UART_SR) &
-				CDNS_UART_SR_TXEMPTY;
+	status = ((readl(port->membase + CDNS_UART_SR) &
+				(CDNS_UART_SR_TXEMPTY |
+				CDNS_UART_SR_TACTIVE)) == CDNS_UART_SR_TXEMPTY);
 	return status ? TIOCSER_TEMT : 0;
 }
 
@@ -700,20 +700,8 @@ static void cdns_uart_set_termios(struct uart_port *port,
 	u32 cval = 0;
 	unsigned int baud, minbaud, maxbaud;
 	unsigned long flags;
-	unsigned int ctrl_reg, mode_reg, val;
-	int err;
-
-	/* Wait for the transmit FIFO to empty before making changes */
-	if (!(readl(port->membase + CDNS_UART_CR) &
-				CDNS_UART_CR_TX_DIS)) {
-		err = readl_poll_timeout(port->membase + CDNS_UART_SR,
-					 val, (val & CDNS_UART_SR_TXEMPTY),
-					 1000, TX_TIMEOUT);
-		if (err) {
-			dev_err(port->dev, "timed out waiting for tx empty");
-			return;
-		}
-	}
+	unsigned int ctrl_reg, mode_reg;
+
 	spin_lock_irqsave(&port->lock, flags);
 
 	/* Disable the TX and RX to set baud rate */
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ