Re: [PATCH] tty: serial: imx: Add fast path when rs485 delays are 0

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

 



On Wed, Jan 19, 2022 at 03:52:03PM +0100, Harald Seiler wrote:
> Right now, even when `delay_rts_before_send` and `delay_rts_after_send`
> are 0, the hrtimer is triggered (with timeout 0) which can introduce a
> few 100us of additional overhead on slower i.MX platforms.
> 
> Implement a fast path when the delays are 0, where the RTS signal is
> toggled immediately instead of going through an hrtimer.  This fast path
> behaves identical to the code before delay support was implemented.
> 
> Signed-off-by: Harald Seiler <hws@xxxxxxx>
> ---
>  drivers/tty/serial/imx.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index df8a0c8b8b29..67bbbb69229d 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -455,9 +455,14 @@ static void imx_uart_stop_tx(struct uart_port *port)
>  	if (port->rs485.flags & SER_RS485_ENABLED) {
>  		if (sport->tx_state == SEND) {
>  			sport->tx_state = WAIT_AFTER_SEND;
> -			start_hrtimer_ms(&sport->trigger_stop_tx,
> +
> +			if (port->rs485.delay_rts_after_send > 0) {
> +				start_hrtimer_ms(&sport->trigger_stop_tx,
>  					 port->rs485.delay_rts_after_send);
> -			return;
> +				return;
> +			}
> +
> +			/* continue without any delay */

Is it right to keep the assignment sport->tx_state = WAIT_AFTER_SEND ?

>  		}
>  
>  		if (sport->tx_state == WAIT_AFTER_RTS ||
> @@ -698,9 +703,14 @@ static void imx_uart_start_tx(struct uart_port *port)
>  				imx_uart_stop_rx(port);
>  
>  			sport->tx_state = WAIT_AFTER_RTS;
> -			start_hrtimer_ms(&sport->trigger_start_tx,
> +
> +			if (port->rs485.delay_rts_before_send > 0) {
> +				start_hrtimer_ms(&sport->trigger_start_tx,
>  					 port->rs485.delay_rts_before_send);
> -			return;
> +				return;
> +			}
> +
> +			/* continue without any delay */

Here similar question here about sport->tx_state = WAIT_AFTER_RTS;

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Attachment: signature.asc
Description: PGP signature


[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