All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Organov <sorganov@gmail.com>
To: Fabio Estevam <festevam@gmail.com>
Cc: linux-serial@vger.kernel.org,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Jiri Slaby" <jirislaby@kernel.org>,
	"NXP Linux Team" <linux-imx@nxp.com>,
	"Pengutronix Kernel Team" <kernel@pengutronix.de>,
	"Sascha Hauer" <s.hauer@pengutronix.de>,
	"Shawn Guo" <shawnguo@kernel.org>,
	"Tomasz Moń <tomasz.mon@camlingroup.com>"
	<k.drobinski@camlintechnologies.com>
Subject: Re: serial: imx: sudden rx flood: hardware bug?
Date: Fri, 16 Dec 2022 20:08:04 +0300	[thread overview]
Message-ID: <87k02ruvij.fsf@osv.gnss.ru> (raw)
In-Reply-To: <CAOMZO5DFth_0wzBb8HHeHoNGkT1rexb7xvakvfiNgdY=cHJSfg@mail.gmail.com> (Fabio Estevam's message of "Thu, 15 Dec 2022 18:38:58 -0300")

Hi Fabio,

Fabio Estevam <festevam@gmail.com> writes:

> Hi Sergey,
>
> On Thu, Dec 15, 2022 at 5:57 PM Sergey Organov <sorganov@gmail.com> wrote:
>
>> An effective method to reproduce the issue is to send isolated start bit
>> at baud rate that is about 2.4 times higher than the one configured on
>> the iMX UART while corresponding TTY is open on iMX. At these
>> conditions the problem appears with about 90% probability, i.e., about 9
>> out of 10 "sent" 0xff chars provoke continuous "receiving" of 0xff
>> chars by the UART, at intervals corresponding to the UART baud rate,
>
> I recall seeing this storm of receiving 0xff  before.
>
> I fixed it a long time ago with the following commit:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.1&id=b38cb7d2571197b56cefae8967f9db15c9361113

This patch looks correct to me, and it's there in my version as well.

> Looking at the current code, I see that the UCR3_ADNIMP bit is only
> set conditionally.

I don't see how it is relevant, as the bit is set on both ways of
corresponding condition, i.e., correctly set anyway.

>
> Could you try the change below?

This change looks wrong though, as the bit is now first set, and then is
cleared afterwards, see below.

Anyway, I checked that UCR3_ADNIMP bit is set in UCR3 register when the
problem appears in my case. Overall, I figure the problem is still there
even if UCR3_ADNIMP is set, and is only more difficult to reproduce.

>
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 757825edb0cd..997681ec354f 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -2399,6 +2399,12 @@ static int imx_uart_probe(struct platform_device *pdev)
>                 imx_uart_writel(sport, ucr2, UCR2);
>         }
>
> +       if (!imx_uart_is_imx1(sport)) {
> +               u32 ucr3 = imx_uart_readl(sport, UCR3);
> +               ucr3 |= UCR3_ADNIMP;
> +               imx_uart_writel(sport, ucr2, UCR3);
> +       }
> +

Here we set the bit in UCR3.

>         if (!imx_uart_is_imx1(sport) && sport->dte_mode) {
>                 /*
>                  * The DCEDTE bit changes the direction of DSR, DCD, DTR and RI
> @@ -2416,8 +2422,7 @@ static int imx_uart_probe(struct platform_device *pdev)
>                  * (confirmed on i.MX25) which makes them unusable.
>                  */
>                 imx_uart_writel(sport,
> -                               IMX21_UCR3_RXDMUXSEL | UCR3_ADNIMP | UCR3_DSR,
> -                               UCR3);
> +                               IMX21_UCR3_RXDMUXSEL | UCR3_DSR, UCR3);

And here it's now cleared.

>
>         } else {
>                 u32 ucr3 = UCR3_DSR;
> @@ -2426,7 +2431,7 @@ static int imx_uart_probe(struct platform_device *pdev)
>                         imx_uart_writel(sport, ufcr & ~UFCR_DCEDTE, UFCR);
>
>                 if (!imx_uart_is_imx1(sport))
> -                       ucr3 |= IMX21_UCR3_RXDMUXSEL | UCR3_ADNIMP;
> +                       ucr3 |= IMX21_UCR3_RXDMUXSEL;
>                 imx_uart_writel(sport, ucr3, UCR3);

And here it's cleared as well, as we don't read-modify-write UCR3 here.

Thanks,
-- Sergey Organov

  parent reply	other threads:[~2022-12-16 17:08 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87bko4e65y.fsf@osv.gnss.ru>
2022-12-15 21:38 ` serial: imx: sudden rx flood: hardware bug? Fabio Estevam
2022-12-15 22:58   ` Fabio Estevam
2022-12-16 17:08   ` Sergey Organov [this message]
2023-01-13 18:43 ` [PATCH 0/8] serial: imx: work-around for hardware RX flood, and then isr improvements Sergey Organov
2023-01-13 18:43   ` Sergey Organov
2023-01-13 18:43   ` [PATCH 1/8] serial: imx: factor-out common code to imx_uart_soft_reset() Sergey Organov
2023-01-13 18:43     ` Sergey Organov
2023-01-16 10:30     ` Ilpo Järvinen
2023-01-16 10:30       ` Ilpo Järvinen
2023-01-17 13:42       ` Sergey Organov
2023-01-17 13:42         ` Sergey Organov
2023-01-13 18:43   ` [PATCH 2/8] serial: imx: work-around for hardware RX flood Sergey Organov
2023-01-13 18:43     ` Sergey Organov
2023-01-13 18:43   ` [PATCH 3/8] serial: imx: do not sysrq broken chars Sergey Organov
2023-01-13 18:43     ` Sergey Organov
2023-01-16 10:41     ` Ilpo Järvinen
2023-01-16 10:41       ` Ilpo Järvinen
2023-01-16 15:24     ` Johan Hovold
2023-01-16 15:24       ` Johan Hovold
2023-01-17 17:35       ` Sergey Organov
2023-01-17 17:35         ` Sergey Organov
2023-01-18  8:06         ` Johan Hovold
2023-01-18  8:06           ` Johan Hovold
2023-01-13 18:43   ` [PATCH 4/8] serial: imx: do not break from FIFO reading loop prematurely Sergey Organov
2023-01-13 18:43     ` Sergey Organov
2023-01-13 18:43   ` [PATCH 5/8] serial: imx: remove redundant USR2 read from FIFO reading loop Sergey Organov
2023-01-13 18:43     ` Sergey Organov
2023-01-16 10:50     ` Ilpo Järvinen
2023-01-16 10:50       ` Ilpo Järvinen
2023-01-13 18:43   ` [PATCH 6/8] serial: imx: stop using USR2 in " Sergey Organov
2023-01-13 18:43     ` Sergey Organov
2023-01-16 10:54     ` Ilpo Järvinen
2023-01-16 10:54       ` Ilpo Järvinen
2023-01-17 13:30       ` Sergey Organov
2023-01-17 13:30         ` Sergey Organov
2023-01-13 18:43   ` [PATCH 7/8] serial: imx: use readl() to optimize " Sergey Organov
2023-01-13 18:43     ` Sergey Organov
2023-01-16 11:03     ` Ilpo Järvinen
2023-01-16 11:03       ` Ilpo Järvinen
2023-01-17 17:43       ` Sergey Organov
2023-01-17 17:43         ` Sergey Organov
2023-01-18  8:24         ` Ilpo Järvinen
2023-01-18  8:24           ` Ilpo Järvinen
2023-01-18 15:43           ` Sergey Organov
2023-01-18 15:43             ` Sergey Organov
2023-01-18 19:29             ` Ilpo Järvinen
2023-01-18 19:29               ` Ilpo Järvinen
2023-01-17 10:20     ` Sherry Sun
2023-01-17 10:20       ` Sherry Sun
2023-01-17 17:48       ` Sergey Organov
2023-01-17 17:48         ` Sergey Organov
2023-01-17 11:32     ` Uwe Kleine-König
2023-01-17 11:32       ` Uwe Kleine-König
2023-01-17 13:22       ` Sergey Organov
2023-01-17 13:22         ` Sergey Organov
2023-01-17 21:27         ` Uwe Kleine-König
2023-01-17 21:27           ` Uwe Kleine-König
2023-01-18 15:40           ` Sergey Organov
2023-01-18 15:40             ` Sergey Organov
2023-01-19  7:01             ` Uwe Kleine-König
2023-01-19  7:01               ` Uwe Kleine-König
2023-01-21 18:04               ` Sergey Organov
2023-01-21 18:04                 ` Sergey Organov
2023-01-13 18:43   ` [PATCH 8/8] serial: imx: refine local variables in rxint() Sergey Organov
2023-01-13 18:43     ` Sergey Organov
2023-01-21 15:36 ` [PATCH v1 0/7] serial: imx: work-around for hardware RX flood, and then isr improvements Sergey Organov
2023-01-21 15:36   ` Sergey Organov
2023-01-21 15:36   ` [PATCH v1 1/7] serial: imx: factor-out common code to imx_uart_soft_reset() Sergey Organov
2023-01-21 15:36     ` Sergey Organov
2023-01-21 15:36   ` [PATCH v1 2/7] serial: imx: work-around for hardware RX flood Sergey Organov
2023-01-21 15:36     ` Sergey Organov
2023-01-21 15:36   ` [PATCH v1 3/7] serial: imx: do not sysrq broken chars Sergey Organov
2023-01-21 15:36     ` Sergey Organov
2023-01-21 16:12     ` Stefan Wahren
2023-01-21 16:12       ` Stefan Wahren
2023-01-21 21:04       ` Sergey Organov
2023-01-21 21:04         ` Sergey Organov
2023-01-23 12:38         ` Ilpo Järvinen
2023-01-23 12:38           ` Ilpo Järvinen
2023-01-23 16:34           ` Sergey Organov
2023-01-23 16:34             ` Sergey Organov
2023-01-21 15:36   ` [PATCH v1 4/7] serial: imx: do not break from FIFO reading loop prematurely Sergey Organov
2023-01-21 15:36     ` Sergey Organov
2023-01-21 15:36   ` [PATCH v1 5/7] serial: imx: remove redundant USR2 read from FIFO reading loop Sergey Organov
2023-01-21 15:36     ` Sergey Organov
2023-01-21 15:36   ` [PATCH v1 6/7] serial: imx: stop using USR2 in " Sergey Organov
2023-01-21 15:36     ` Sergey Organov
2023-01-21 15:36   ` [PATCH v1 7/7] serial: imx: refine local variables in rxint() Sergey Organov
2023-01-21 15:36     ` Sergey Organov
2023-02-01 14:16 ` [PATCH RESEND] serial: imx: get rid of registers shadowing Sergey Organov
2023-02-01 14:16   ` Sergey Organov
2023-02-01 14:26 ` [PATCH v1 RESEND 0/7] serial: imx: work-around for hardware RX flood, and then isr improvements Sergey Organov
2023-02-01 14:26   ` Sergey Organov
2023-02-01 14:26   ` [PATCH v1 1/7] serial: imx: factor-out common code to imx_uart_soft_reset() Sergey Organov
2023-02-01 14:26     ` Sergey Organov
2023-02-01 14:26   ` [PATCH v1 2/7] serial: imx: work-around for hardware RX flood Sergey Organov
2023-02-01 14:26     ` Sergey Organov
2023-02-01 14:26   ` [PATCH v1 3/7] serial: imx: do not sysrq broken chars Sergey Organov
2023-02-01 14:26     ` Sergey Organov
2023-02-01 14:26   ` [PATCH v1 4/7] serial: imx: do not break from FIFO reading loop prematurely Sergey Organov
2023-02-01 14:26     ` Sergey Organov
2023-02-01 14:26   ` [PATCH v1 5/7] serial: imx: remove redundant USR2 read from FIFO reading loop Sergey Organov
2023-02-01 14:26     ` Sergey Organov
2023-02-01 14:26   ` [PATCH v1 6/7] serial: imx: stop using USR2 in " Sergey Organov
2023-02-01 14:26     ` Sergey Organov
2023-02-01 14:27   ` [PATCH v1 7/7] serial: imx: refine local variables in rxint() Sergey Organov
2023-02-01 14:27     ` Sergey Organov

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=87k02ruvij.fsf@osv.gnss.ru \
    --to=sorganov@gmail.com \
    --cc=festevam@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=k.drobinski@camlintechnologies.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-imx@nxp.com \
    --cc=linux-serial@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.