Commit 5a9a62bb authored by Haavard Skinnemoen's avatar Haavard Skinnemoen Committed by Linus Torvalds

atmel_spi dma address bugfix

When either rx_buf or tx_buf is not being used, i.e.  for plain read- or
write operations, the atmel_spi uses a fixed-size DMA buffer instead.  If
the transfer is longer than the size of this buffer, it is split into
multiple DMA transfers.

When the transfer is split like this, the atmel_spi driver ends up using
the same DMA address again and again even for the buffer that came from the
user, which is of course wrong.  Fix this by adding the number of bytes
already transferred to the DMA address so that the data ends up in the
right place.

Thanks to Wu Xuan for discovering this bug.
Signed-off-by: default avatarHaavard Skinnemoen <hskinnemoen@atmel.com>
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e88b34ba
......@@ -113,16 +113,16 @@ static void atmel_spi_next_xfer(struct spi_master *master,
len = as->remaining_bytes;
tx_dma = xfer->tx_dma;
rx_dma = xfer->rx_dma;
tx_dma = xfer->tx_dma + xfer->len - len;
rx_dma = xfer->rx_dma + xfer->len - len;
/* use scratch buffer only when rx or tx data is unspecified */
if (rx_dma == INVALID_DMA_ADDRESS) {
if (!xfer->rx_buf) {
rx_dma = as->buffer_dma;
if (len > BUFFER_SIZE)
len = BUFFER_SIZE;
}
if (tx_dma == INVALID_DMA_ADDRESS) {
if (!xfer->tx_buf) {
tx_dma = as->buffer_dma;
if (len > BUFFER_SIZE)
len = BUFFER_SIZE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment