All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Kazuhiro Fujita <kazuhiro.fujita.jg@renesas.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>,
	"open list:SERIAL DRIVERS" <linux-serial@vger.kernel.org>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
	Prabhakar <prabhakar.csengg@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Hao Bui <hao.bui.yg@renesas.com>,
	KAZUMI HARADA <kazumi.harada.rh@renesas.com>,
	Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	Sasha Levin <sashal@kernel.org>,
	Chris Brandt <Chris.Brandt@renesas.com>
Subject: Re: [PATCH] serial: sh-sci: Make sure status register SCxSR is read in correct sequence
Date: Tue, 31 Mar 2020 17:17:39 +0200	[thread overview]
Message-ID: <CAMuHMdW+u5r6zyxFJsVzj21BYDrKCr=Q6Ojk5VeN+mkhvXX9Jw@mail.gmail.com> (raw)
In-Reply-To: <1585333048-31828-1-git-send-email-kazuhiro.fujita.jg@renesas.com>

Hi Fujita-san,

CC -stable, +sasha, +seebe

On Fri, Mar 27, 2020 at 7:17 PM Kazuhiro Fujita
<kazuhiro.fujita.jg@renesas.com> wrote:
> For SCIF and HSCIF interfaces the SCxSR register holds the status of
> data that is to be read next from SCxRDR register, But where as for
> SCIFA and SCIFB interfaces SCxSR register holds status of data that is
> previously read from SCxRDR register.
>
> This patch makes sure the status register is read depending on the port
> types so that errors are caught accordingly.
>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Kazuhiro Fujita <kazuhiro.fujita.jg@renesas.com>
> Signed-off-by: Hao Bui <hao.bui.yg@renesas.com>
> Signed-off-by: KAZUMI HARADA <kazumi.harada.rh@renesas.com>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Thanks for your patch!

> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -870,9 +870,16 @@ static void sci_receive_chars(struct uart_port *port)
>                                 tty_insert_flip_char(tport, c, TTY_NORMAL);
>                 } else {
>                         for (i = 0; i < count; i++) {
> -                               char c = serial_port_in(port, SCxRDR);
> -
> -                               status = serial_port_in(port, SCxSR);
> +                               char c;
> +
> +                               if (port->type == PORT_SCIF ||
> +                                   port->type == PORT_HSCIF) {
> +                                       status = serial_port_in(port, SCxSR);
> +                                       c = serial_port_in(port, SCxRDR);
> +                               } else {
> +                                       c = serial_port_in(port, SCxRDR);
> +                                       status = serial_port_in(port, SCxSR);
> +                               }
>                                 if (uart_handle_sysrq_char(port, c)) {
>                                         count--; i--;
>                                         continue;

I can confirm that the documentation for the Serial Status Register on
  1. (H)SCIF on R-Car Gen1/2/3 says the framing/error flag applies to
     the data that is "to be read next" from the FIFO., and that the
     "Sample Flowchart for Serial Reception (2)" confirms this,
  2. SCIF[AB] on R-Car Gen2, SH-Mobile AG5, R-Mobile A1 and APE6 says
     the framing/error flag applies to the receive data that is "read"
     from the FIFO, and that the "Example of Flow for Serial Reception
     (2)" confirms this,
  3. SCIF on RZ/A1H says something similar as for (H)SCIF above, using
     slightly different wording, also confirmed by the "Sample Flowchart
     for Receiving Serial Data (2)".

However, the documentation for "SCIFA" on RZ/A2 (for which we use
PORT_SCIF, not PORT_SCIFA, in the driver) has conflicting information:
  1. Section 17.2.7 "Serial Status Register (FSR)" says:
       - A receive framing/parity error occurred in the "next receive
         data read" from the FIFO,
       - Indicates whether there is a framing/parity error in the data
         "read" from the FIFO.
  2. Figure 17.8 "Sample Flowchart for Receiving Serial Data in
     Asynchronous Mode (2)".
       - Whether a framing error or parity error has occurred in the
         received data that is "read" from the FIFO.

So while the change looks OK for most Renesas ARM SoCs, the situation
for RZ/A2 is unclear.
Note that the above does not take into account variants used on SuperH
SoCs.

Nevertheless, this patch will need some testing on various hardware.
Do you have a test case to verify the broken/fixed behavior?

Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  parent reply	other threads:[~2020-03-31 15:17 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-27 18:17 [PATCH] serial: sh-sci: Make sure status register SCxSR is read in correct sequence Kazuhiro Fujita
2020-03-31 13:11 ` Sasha Levin
2020-03-31 15:17 ` Geert Uytterhoeven [this message]
2020-03-31 15:58   ` Prabhakar Mahadev Lad
2020-03-31 17:38     ` Geert Uytterhoeven
2020-03-31 18:10       ` Prabhakar Mahadev Lad
2020-04-01 12:43     ` Geert Uytterhoeven
2020-04-02 11:27       ` Lad, Prabhakar
2020-04-02 15:24         ` Geert Uytterhoeven
2020-04-02 15:24           ` Geert Uytterhoeven
2020-04-15 12:36           ` Geert Uytterhoeven
2020-04-15 12:36             ` Geert Uytterhoeven
2020-04-15 23:21             ` Rob Landley
2020-04-15 23:21               ` Rob Landley
2020-08-14 15:25             ` Geert Uytterhoeven
2020-08-14 15:25               ` Geert Uytterhoeven
2020-08-16 16:22               ` Prabhakar Mahadev Lad
2020-08-16 16:22                 ` Prabhakar Mahadev Lad
2020-08-17  3:17                 ` Rob Landley
2020-08-17  3:17                   ` Rob Landley
2020-08-18 15:11                   ` SCI on R2D+ (was: Re: [PATCH] serial: sh-sci: Make sure status register SCxSR is read in correct seq Geert Uytterhoeven
2020-08-18 15:11                     ` SCI on R2D+ (was: Re: [PATCH] serial: sh-sci: Make sure status register SCxSR is read in correct sequence) Geert Uytterhoeven
2020-03-31 19:07   ` [PATCH] serial: sh-sci: Make sure status register SCxSR is read in correct sequence Chris Brandt

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='CAMuHMdW+u5r6zyxFJsVzj21BYDrKCr=Q6Ojk5VeN+mkhvXX9Jw@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=Chris.Brandt@renesas.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hao.bui.yg@renesas.com \
    --cc=jslaby@suse.com \
    --cc=kazuhiro.fujita.jg@renesas.com \
    --cc=kazumi.harada.rh@renesas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=prabhakar.csengg@gmail.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=sashal@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.