mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Sverdlin, Alexander" <alexander.sverdlin@siemens.com>
To: "u.kleine-koenig@pengutronix.de" <u.kleine-koenig@pengutronix.de>,
	"sherry.sun@nxp.com" <sherry.sun@nxp.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"ilpo.jarvinen@linux.intel.com" <ilpo.jarvinen@linux.intel.com>,
	"robh@kernel.org" <robh@kernel.org>,
	"shenwei.wang@nxp.com" <shenwei.wang@nxp.com>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"jirislaby@kernel.org" <jirislaby@kernel.org>,
	"robert.hodaszi@digi.com" <robert.hodaszi@digi.com>
Cc: "linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
	"imx@lists.linux.dev" <imx@lists.linux.dev>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"frank.li@nxp.com" <frank.li@nxp.com>
Subject: Re: [PATCH] tty: serial: fsl_lpuart: avoid idle preamble pending if CTS is enabled
Date: Mon, 4 Mar 2024 07:13:32 +0000	[thread overview]
Message-ID: <2e1b1eae2e9d3cedcd270e35cfcf8086b914b7ff.camel@siemens.com> (raw)
In-Reply-To: <20240304020712.238637-1-sherry.sun@nxp.com>

Hi Sherry,

thank you for the fix!

On Mon, 2024-03-04 at 10:07 +0800, Sherry Sun wrote:
> If the remote uart device is not connected or not enabled after booting
> up, the CTS line is high by default. At this time, if we enable the flow
> control when opening the device(for example, using “stty -F /dev/ttyLP4
> crtscts” command), there will be a pending idle preamble(first writing 0
> and then writing 1 to UARTCTRL_TE will queue an idle preamble) that
> cannot be sent out, resulting in the uart port fail to close(waiting for
> TX empty), so the user space stty will have to wait for a long time or
> forever.
> 
> This is an LPUART IP bug(idle preamble has higher priority than CTS),
> here add a workaround patch to enable TX CTS after enabling UARTCTRL_TE,
> so that the idle preamble does not get stuck due to CTS is deasserted.
> 
> Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> ---
>  drivers/tty/serial/fsl_lpuart.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
> index 5ddf110aedbe..dce1b5851de0 100644
> --- a/drivers/tty/serial/fsl_lpuart.c
> +++ b/drivers/tty/serial/fsl_lpuart.c
> @@ -2345,8 +2345,12 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
>  
>         lpuart32_write(&sport->port, bd, UARTBAUD);
>         lpuart32_serial_setbrg(sport, baud);
> -       lpuart32_write(&sport->port, modem, UARTMODIR);
> +       /* disable CTS before enabling UARTCTRL_TE to avoid pending idle preamble */
> +       lpuart32_write(&sport->port, modem & ~UARTMODIR_TXCTSE, UARTMODIR);
>         lpuart32_write(&sport->port, ctrl, UARTCTRL);
> +       /* re-enable the CTS if needed */
> +       lpuart32_write(&sport->port, modem, UARTMODIR);
> +
>         /* restore control register */

The fix makes sense to me!
I see only one issue with above comment, which commit 380c966c093e7
already have put quite sub-optimal (after the actual write), but
your commit now shifts it even further making it completely dangling.
Should it be before last UARTCTRL write? 

>  
>         if ((ctrl & (UARTCTRL_PE | UARTCTRL_M)) == UARTCTRL_PE)

-- 
Alexander Sverdlin
Siemens AG
www.siemens.com

  reply	other threads:[~2024-03-04  7:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-04  2:07 Sherry Sun
2024-03-04  7:13 ` Sverdlin, Alexander [this message]
2024-03-04  7:31   ` Sherry Sun
2024-03-04 11:09     ` Fabio Estevam
2024-03-04 11:11       ` Sherry Sun

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=2e1b1eae2e9d3cedcd270e35cfcf8086b914b7ff.camel@siemens.com \
    --to=alexander.sverdlin@siemens.com \
    --cc=frank.li@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=imx@lists.linux.dev \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=robert.hodaszi@digi.com \
    --cc=robh@kernel.org \
    --cc=shenwei.wang@nxp.com \
    --cc=sherry.sun@nxp.com \
    --cc=tglx@linutronix.de \
    --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

all inboxes | Powered by JetHome®