Re: [PATCH v3] serial: uartps: Add TACTIVE bit in cdns_uart_tx_empty function

From: Johan Hovold
Date: Fri Jan 31 2020 - 09:18:37 EST


On Fri, Jan 31, 2020 at 04:34:45PM +0530, Shubhrajyoti Datta wrote:
> From: Raviteja Narayanam <raviteja.narayanam@xxxxxxxxxx>
>
> 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.

Since this is two logical changes I suggest you split it in two patches;
the first removing the wait from set_termios, and the second adding the
TCACTIVE check.

> Signed-off-by: Raviteja Narayanam <raviteja.narayanam@xxxxxxxxxx>
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xxxxxxxxxx>
> ---
> 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;

Please rewrite this to avoid some of the line breaks (e.g. split readl()
from the test).

Johan