From: Harald Seiler <hws@denx.de>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Fabio Estevam <festevam@gmail.com>,
Ahmad Fatoum <a.fatoum@pengutronix.de>,
linux-serial@vger.kernel.org, Jiri Slaby <jirislaby@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
linux-kernel@vger.kernel.org, NXP Linux Team <linux-imx@nxp.com>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Shawn Guo <shawnguo@kernel.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] tty: serial: imx: Add fast path when rs485 delays are 0
Date: Wed, 19 Jan 2022 16:20:12 +0100 [thread overview]
Message-ID: <0df5d9ea2081f5d798f80297efb973f542dae183.camel@denx.de> (raw)
In-Reply-To: <20220119151145.zft47rzebnabiej2@pengutronix.de>
[-- Attachment #1: Type: text/plain, Size: 2790 bytes --]
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@denx.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?
> > }
> >
> > 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;
Same as above, but with WAIT_AFTER_RTS of course...
--
Harald
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 850 bytes --]
next prev parent reply other threads:[~2022-01-19 15:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-19 14:52 [PATCH] tty: serial: imx: Add fast path when rs485 delays are 0 Harald Seiler
2022-01-19 15:11 ` Uwe Kleine-König
2022-01-19 15:20 ` Harald Seiler [this message]
2022-01-19 16:21 ` Uwe Kleine-König
2022-01-19 16:59 ` Harald Seiler
2022-02-08 10:03 ` Greg Kroah-Hartman
2022-02-08 11:12 ` Uwe Kleine-König
2022-02-09 15:30 ` Uwe Kleine-König
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=0df5d9ea2081f5d798f80297efb973f542dae183.camel@denx.de \
--to=hws@denx.de \
--cc=a.fatoum@pengutronix.de \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
/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).