Commit 8bacb219 authored by Haavard Skinnemoen's avatar Haavard Skinnemoen Committed by Linus Torvalds

atmel_spi: fix dmachain oops with DEBUG enabled

In atmel_spi_next_xfer, xfer can be NULL because the next transfer may
already have been submitted to the PDC (using DMA chaining).  This can
cause an oops, since the debug message assumed it was never null.  The
fix changes how those debug messages are issued, ensuring that one is
issued each time a transfer is started instead of once per call.

Also, properly indent the "can this transfer be chained" test so it's
not hidden as if it were non-conditional code.
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 154443c7
...@@ -198,6 +198,11 @@ static void atmel_spi_next_xfer(struct spi_master *master, ...@@ -198,6 +198,11 @@ static void atmel_spi_next_xfer(struct spi_master *master,
len >>= 1; len >>= 1;
spi_writel(as, RCR, len); spi_writel(as, RCR, len);
spi_writel(as, TCR, len); spi_writel(as, TCR, len);
dev_dbg(&msg->spi->dev,
" start xfer %p: len %u tx %p/%08x rx %p/%08x\n",
xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
xfer->rx_buf, xfer->rx_dma);
} else { } else {
xfer = as->next_transfer; xfer = as->next_transfer;
remaining = as->next_remaining_bytes; remaining = as->next_remaining_bytes;
...@@ -208,8 +213,8 @@ static void atmel_spi_next_xfer(struct spi_master *master, ...@@ -208,8 +213,8 @@ static void atmel_spi_next_xfer(struct spi_master *master,
if (remaining > 0) if (remaining > 0)
len = remaining; len = remaining;
else if (!atmel_spi_xfer_is_last(msg, xfer) && else if (!atmel_spi_xfer_is_last(msg, xfer)
atmel_spi_xfer_can_be_chained(xfer)) { && atmel_spi_xfer_can_be_chained(xfer)) {
xfer = list_entry(xfer->transfer_list.next, xfer = list_entry(xfer->transfer_list.next,
struct spi_transfer, transfer_list); struct spi_transfer, transfer_list);
len = xfer->len; len = xfer->len;
...@@ -230,6 +235,11 @@ static void atmel_spi_next_xfer(struct spi_master *master, ...@@ -230,6 +235,11 @@ static void atmel_spi_next_xfer(struct spi_master *master,
len >>= 1; len >>= 1;
spi_writel(as, RNCR, len); spi_writel(as, RNCR, len);
spi_writel(as, TNCR, len); spi_writel(as, TNCR, len);
dev_dbg(&msg->spi->dev,
" next xfer %p: len %u tx %p/%08x rx %p/%08x\n",
xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
xfer->rx_buf, xfer->rx_dma);
} else { } else {
spi_writel(as, RNCR, 0); spi_writel(as, RNCR, 0);
spi_writel(as, TNCR, 0); spi_writel(as, TNCR, 0);
...@@ -246,12 +256,6 @@ static void atmel_spi_next_xfer(struct spi_master *master, ...@@ -246,12 +256,6 @@ static void atmel_spi_next_xfer(struct spi_master *master,
* It should be doable, though. Just not now... * It should be doable, though. Just not now...
*/ */
spi_writel(as, IER, SPI_BIT(ENDRX) | SPI_BIT(OVRES)); spi_writel(as, IER, SPI_BIT(ENDRX) | SPI_BIT(OVRES));
dev_dbg(&msg->spi->dev,
" start xfer %p: len %u tx %p/%08x rx %p/%08x imr %03x\n",
xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
xfer->rx_buf, xfer->rx_dma, spi_readl(as, IMR));
spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN)); spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN));
} }
......
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