From patchwork Sat May 9 20:37:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 245403 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Sat, 9 May 2020 22:37:59 +0200 Subject: [PATCH 2/5] serial: sh: Improve FIFO empty check on RX In-Reply-To: <20200509203802.821856-1-marek.vasut+renesas@gmail.com> References: <20200509203802.821856-1-marek.vasut+renesas@gmail.com> Message-ID: <20200509203802.821856-2-marek.vasut+renesas@gmail.com> If the SCIF is receiving data quickly enough, it may happen that the SCxSR_RDxF flag is cleared in sh_serial_getc_generic(), while the FIFO still contains data. If that happens, the serial_getc_check() reports no data in the FIFO as the flag is no longer set. Add one more check, if the SCxSR_RDxF is not set, read out the FIFO level and if there are still characters in the FIFO, permit reading them out. Signed-off-by: Marek Vasut Cc: Nobuhiro Iwamatsu --- drivers/serial/serial_sh.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c index acfcc2954a..0a4dfdc377 100644 --- a/drivers/serial/serial_sh.c +++ b/drivers/serial/serial_sh.c @@ -115,7 +115,10 @@ static int serial_getc_check(struct uart_port *port) handle_error(port); if (sci_in(port, SCLSR) & SCxSR_ORER(port)) handle_error(port); - return status & (SCIF_DR | SCxSR_RDxF(port)); + status &= (SCIF_DR | SCxSR_RDxF(port)); + if (status) + return status; + return scif_rxfill(port); } static int sh_serial_getc_generic(struct uart_port *port)