linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: shubhrajyoti.datta@gmail.com
Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org,
	jacmet@sunsite.dk, git@xilinx.com,
	Raviteja Narayanam <raviteja.narayanam@xilinx.com>,
	Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Subject: Re: [PATCHv2] serial: uartps: Add monitoring TACTIVE bit in set_termios
Date: Tue, 7 Jan 2020 13:51:17 +0100	[thread overview]
Message-ID: <20200107125117.GG30908@localhost> (raw)
In-Reply-To: <1578398223-27523-1-git-send-email-shubhrajyoti.datta@gmail.com>

On Tue, Jan 07, 2020 at 05:27:03PM +0530, shubhrajyoti.datta@gmail.com wrote:
> From: Raviteja Narayanam <raviteja.narayanam@xilinx.com>
> 
> 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@xilinx.com>
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
> ---
> 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

      reply	other threads:[~2020-01-07 12:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07 11:57 [PATCHv2] serial: uartps: Add monitoring TACTIVE bit in set_termios shubhrajyoti.datta
2020-01-07 12:51 ` Johan Hovold [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200107125117.GG30908@localhost \
    --to=johan@kernel.org \
    --cc=git@xilinx.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jacmet@sunsite.dk \
    --cc=linux-serial@vger.kernel.org \
    --cc=raviteja.narayanam@xilinx.com \
    --cc=shubhrajyoti.datta@gmail.com \
    --cc=shubhrajyoti.datta@xilinx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).