serial: samsung: fix DMA for FIFO smaller than cache line size
authorRobert Baldyga <r.baldyga@samsung.com>
Fri, 31 Jul 2015 08:58:28 +0000 (10:58 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Aug 2015 05:07:24 +0000 (22:07 -0700)
commit736cd79f483fd7a1e0b71e6eaddf01d8d87fbbbb
tree035da7625ec0f5022a53d9346ee968cf9ff33541
parent81ccb2a69f76b88295a1da9fc9484df715fe3bfa
serial: samsung: fix DMA for FIFO smaller than cache line size

So far DMA mode were activated when only number of bytes to send was
equal or greater than min_dma_size. Due to requirement that DMA transaction
buffer should be aligned to cache line size, the excessive bytes were
written to FIFO before starting DMA transaction. The problem occurred
when FIFO size were smaller than cache alignment, because writing all
excessive bytes to FIFO would fail. It happened in DMA mode when PIO
interrupts disabled, which caused driver hung.

The solution is to test if buffer is alligned to cache line size before
activating DMA mode, and if it's not, running PIO mode to align buffer
and then starting DMA transaction. In PIO mode, when interrupts are
enabled, lack of space in FIFO isn't the problem, so buffer aligning
will always finish with success.

Cc: <stable@vger.kernel.org> # v3.18+
Reported-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/samsung.c