tty: serial: qcom_geni_serial: Fix wrap around of TX buffer
authorMatthias Kaehlcke <mka@chromium.org>
Wed, 19 Dec 2018 18:17:47 +0000 (10:17 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Dec 2018 15:26:28 +0000 (16:26 +0100)
commit3c66eb4ba18dd1cab0d1bde651cde6d8bdb47696
tree4229a0a4a35c0296bb9ef7e722680f179f174a99
parenta8da3c7873ea57acb8f9cea58c0af477522965aa
tty: serial: qcom_geni_serial: Fix wrap around of TX buffer

Before commit a1fee899e5bed ("tty: serial: qcom_geni_serial: Fix
softlock") the size of TX transfers was limited to the TX FIFO size,
and wrap arounds of the UART circular buffer were split into two
transfers. With the commit wrap around are allowed within a transfer.
The TX FIFO of the geni serial port uses a word size of 4 bytes. In
case of a circular buffer wrap within a transfer the driver currently
may write an incomplete word to the FIFO, with some bytes containing
data from the circular buffer and others being zero. Since the
transfer isn't completed yet the zero bytes are sent as if they were
actual data.

Handle wrap arounds of the TX buffer properly and ensure that words
written to the TX FIFO always contain valid data (unless the transfer
is completed).

Fixes: a1fee899e5bed ("tty: serial: qcom_geni_serial: Fix softlock")
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Evan Green <evgreen@chromium.org>
Tested-by: Ryan Case <ryandcase@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/qcom_geni_serial.c