linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kazuhiro Fujita <kazuhiro.fujita.jg@renesas.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>
Cc: linux-serial@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Prabhakar <prabhakar.csengg@gmail.com>,
	linux-kernel@vger.kernel.org,
	Kazuhiro Fujita <kazuhiro.fujita.jg@renesas.com>,
	stable@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>
Subject: [PATCH] serial: sh-sci: Make sure status register SCxSR is read in correct sequence
Date: Fri, 27 Mar 2020 18:17:28 +0000	[thread overview]
Message-ID: <1585333048-31828-1-git-send-email-kazuhiro.fujita.jg@renesas.com> (raw)

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>
---
 drivers/tty/serial/sh-sci.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 0641a72..d646bc4 100644
--- 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;
-- 
2.7.4


             reply	other threads:[~2020-03-27 18:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-27 18:17 Kazuhiro Fujita [this message]
2020-03-31 15:17 ` [PATCH] serial: sh-sci: Make sure status register SCxSR is read in correct sequence Geert Uytterhoeven
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-15 12:36           ` Geert Uytterhoeven
2020-04-15 23:21             ` Rob Landley
2020-08-14 15:25             ` Geert Uytterhoeven
2020-08-16 16:22               ` Prabhakar Mahadev Lad
2020-08-17  3:17                 ` Rob Landley
2020-03-31 19:07   ` 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=1585333048-31828-1-git-send-email-kazuhiro.fujita.jg@renesas.com \
    --to=kazuhiro.fujita.jg@renesas.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hao.bui.yg@renesas.com \
    --cc=jslaby@suse.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=stable@vger.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 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).