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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220119162122.jmnz2hxid76p4hli@pengutronix.de>
Date:   Wed, 19 Jan 2022 17:21:22 +0100
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Harald Seiler <hws@...x.de>
Cc:     Ahmad Fatoum <a.fatoum@...gutronix.de>,
        linux-serial@...r.kernel.org,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Sascha Hauer <s.hauer@...gutronix.de>,
        linux-kernel@...r.kernel.org, NXP Linux Team <linux-imx@....com>,
        Fabio Estevam <festevam@...il.com>,
        Shawn Guo <shawnguo@...nel.org>,
        Jiri Slaby <jirislaby@...nel.org>,
        Pengutronix Kernel Team <kernel@...gutronix.de>,
        linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH] tty: serial: imx: Add fast path when rs485 delays are 0

On Wed, Jan 19, 2022 at 04:20:12PM +0100, Harald Seiler wrote:
> Hi,
> 
> On Wed, 2022-01-19 at 16:11 +0100, Uwe Kleine-König wrote:
> > 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@...x.de>
> > > ---
> > >  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 ?
> 
> I am keeping the assignment intentionally, to fall into the
> if(state == WAIT_AFTER_RTS) below (which then sets the state to OFF).
> I originally had the code structured like this:
> 
> 	if (port->rs485.delay_rts_after_send > 0) {
> 		sport->tx_state = WAIT_AFTER_SEND;
> 		start_hrtimer_ms(&sport->trigger_stop_tx,
> 			 port->rs485.delay_rts_after_send);
> 		return;
> 	} else {
> 		/* continue without any delay */
> 		sport->tx_state = WAIT_AFTER_SEND;
> 	}
> 
> This is functionally identical, but maybe a bit more explicit.
> 
> Not sure what is more clear to read?

I didn't oppose to the readability thing. With your patch you skip
starting the stop_tx timer and that would usually care for calling
imx_uart_stop_tx and setting sport->tx_state = OFF. This doesn't happen
with your patch any more.

Best regards
Uwe

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

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ