tty: serial: fsl_lpuart: clear receive flag on FIFO flush
authorStefan Agner <stefan@agner.ch>
Fri, 13 Mar 2015 13:51:51 +0000 (14:51 +0100)
committerSasha Levin <sasha.levin@oracle.com>
Fri, 24 Apr 2015 21:14:00 +0000 (17:14 -0400)
commit465dd8c0516a59cefe851ee4c57d53d54f7ef79a
tree30169c60f1753f2db579389f017d290c800de81a
parenteed8dd7be5887f2715f22461dd3847dbe66843cb
tty: serial: fsl_lpuart: clear receive flag on FIFO flush

[ Upstream commit 8e4934c6d6c659e22b1b746af4196683e77ce6ca ]

When the receiver was enabled during startup, a character could
have been in the FIFO when the UART get initially used. The
driver configures the (receive) watermark level, and flushes the
FIFO. However, the receive flag (RDRF) could still be set at that
stage (as mentioned in the register description of UARTx_RWFIFO).
This leads to an interrupt which won't be handled properly in
interrupt mode: The receive interrupt function lpuart_rxint checks
the FIFO count, which is 0 at that point (due to the flush
during initialization). The problem does not manifest when using
DMA to receive characters.

Fix this situation by explicitly read the status register, which
leads to clearing of the RDRF flag. Due to the flush just after
the status flag read, a explicit data read is not to required.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
drivers/tty/serial/fsl_lpuart.c