Commit 8bacb219018a52e6f02a3cff6a7badf102ddfc44
Committed by
Linus Torvalds
1 parent
154443c72f
Exists in
master
and in
39 other branches
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: Haavard Skinnemoen <hskinnemoen@atmel.com> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 12 additions and 8 deletions Side-by-side Diff
drivers/spi/atmel_spi.c
... | ... | @@ -198,6 +198,11 @@ |
198 | 198 | len >>= 1; |
199 | 199 | spi_writel(as, RCR, len); |
200 | 200 | spi_writel(as, TCR, len); |
201 | + | |
202 | + dev_dbg(&msg->spi->dev, | |
203 | + " start xfer %p: len %u tx %p/%08x rx %p/%08x\n", | |
204 | + xfer, xfer->len, xfer->tx_buf, xfer->tx_dma, | |
205 | + xfer->rx_buf, xfer->rx_dma); | |
201 | 206 | } else { |
202 | 207 | xfer = as->next_transfer; |
203 | 208 | remaining = as->next_remaining_bytes; |
... | ... | @@ -208,8 +213,8 @@ |
208 | 213 | |
209 | 214 | if (remaining > 0) |
210 | 215 | len = remaining; |
211 | - else if (!atmel_spi_xfer_is_last(msg, xfer) && | |
212 | - atmel_spi_xfer_can_be_chained(xfer)) { | |
216 | + else if (!atmel_spi_xfer_is_last(msg, xfer) | |
217 | + && atmel_spi_xfer_can_be_chained(xfer)) { | |
213 | 218 | xfer = list_entry(xfer->transfer_list.next, |
214 | 219 | struct spi_transfer, transfer_list); |
215 | 220 | len = xfer->len; |
... | ... | @@ -230,6 +235,11 @@ |
230 | 235 | len >>= 1; |
231 | 236 | spi_writel(as, RNCR, len); |
232 | 237 | spi_writel(as, TNCR, len); |
238 | + | |
239 | + dev_dbg(&msg->spi->dev, | |
240 | + " next xfer %p: len %u tx %p/%08x rx %p/%08x\n", | |
241 | + xfer, xfer->len, xfer->tx_buf, xfer->tx_dma, | |
242 | + xfer->rx_buf, xfer->rx_dma); | |
233 | 243 | } else { |
234 | 244 | spi_writel(as, RNCR, 0); |
235 | 245 | spi_writel(as, TNCR, 0); |
... | ... | @@ -246,12 +256,6 @@ |
246 | 256 | * It should be doable, though. Just not now... |
247 | 257 | */ |
248 | 258 | spi_writel(as, IER, SPI_BIT(ENDRX) | SPI_BIT(OVRES)); |
249 | - | |
250 | - dev_dbg(&msg->spi->dev, | |
251 | - " start xfer %p: len %u tx %p/%08x rx %p/%08x imr %03x\n", | |
252 | - xfer, xfer->len, xfer->tx_buf, xfer->tx_dma, | |
253 | - xfer->rx_buf, xfer->rx_dma, spi_readl(as, IMR)); | |
254 | - | |
255 | 259 | spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN)); |
256 | 260 | } |
257 | 261 |