Re: [PATCHv2] serial: uartps: Add monitoring TACTIVE bit in set_termios

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 07, 2020 at 05:27:03PM +0530, shubhrajyoti.datta@xxxxxxxxx wrote:
> From: Raviteja Narayanam <raviteja.narayanam@xxxxxxxxxx>
> 
> Before setting up baud rate in set_termios function, make sure
> all the data is shifted out from the Uart transmitter by
> monitoring TACTIVE bit in the channel status register.

set_termios() is not supposed to do that unconditionally. Instead the
user specifies whether the output buffer shall been drained (e.g. using
TCSADRAIN) and the tty layer takes care of it.

Almost no other serial driver does this, which is a hint that you're
doing something wrong.

I suggest you remove the check instead and possibly amend tx_empty() if
you need to check CDNS_UART_SR_TACTIVE as well.

> Signed-off-by: Raviteja Narayanam <raviteja.narayanam@xxxxxxxxxx>
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xxxxxxxxxx>
> ---
> v2: fix the signed-off
> 
>  drivers/tty/serial/xilinx_uartps.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
> index 4e55bc3..7424f33 100644
> --- a/drivers/tty/serial/xilinx_uartps.c
> +++ b/drivers/tty/serial/xilinx_uartps.c
> @@ -690,11 +690,15 @@ static void cdns_uart_set_termios(struct uart_port *port,
>  	unsigned int ctrl_reg, mode_reg, val;
>  	int err;
>  
> -	/* Wait for the transmit FIFO to empty before making changes */
> +	/* Wait for the transmit FIFO to empty and Transmitter to shift out
> +	 * all the data 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),
> +					 val, ((val & (CDNS_UART_SR_TXEMPTY |
> +					 CDNS_UART_SR_TACTIVE)) ==
> +					 CDNS_UART_SR_TXEMPTY),
>  					 1000, TX_TIMEOUT);
>  		if (err) {
>  			dev_err(port->dev, "timed out waiting for tx empty");

Johan



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux