Skip to content

Commit d57e92d

Browse files
thierryredingbroonie
authored andcommitted
spi: tegra210-qspi: Remove cache operations
The DMA memory for this driver is allocated using dma_alloc_coherent(), which ends up mapping the allocated memory as uncached. Performing the various dma_sync_*() operations on this memory causes issues during SPI flashing: [ 7.818017] pc : dcache_inval_poc+0x40/0x58 [ 7.822128] lr : arch_sync_dma_for_cpu+0x2c/0x4c [ 7.826854] sp : ffff80008193bcf0 [ 7.830267] x29: ffff80008193bcf0 x28: ffffa3fe5ff1e908 x27: ffffa3fe627bb130 [ 7.837528] x26: ffff000086952180 x25: ffff00008015c8ac x24: ffff000086c9b480 [ 7.844878] x23: ffff00008015c800 x22: 0000000000000002 x21: 0000000000010000 [ 7.852229] x20: 0000000106dae000 x19: ffff000080112410 x18: 0000000000000001 [ 7.859580] x17: ffff000080159400 x16: ffffa3fe607a9bd8 x15: ffff0000eac1b180 [ 7.866753] x14: 000000000000000c x13: 0000000000000001 x12: 000000000000025a [ 7.874104] x11: 0000000000000000 x10: 7f73e96357f6a07f x9 : db1fc8072a7f5e3a [ 7.881365] x8 : ffff000086c9c588 x7 : ffffa3fe607a9bd8 x6 : ffff80008193bc28 [ 7.888630] x5 : 000000000000ffff x4 : 0000000000000009 x3 : 000000000000003f [ 7.895892] x2 : 0000000000000040 x1 : ffff000086dbe000 x0 : ffff000086db0000 [ 7.903155] Call trace: [ 7.905606] dcache_inval_poc+0x40/0x58 (P) [ 7.909804] iommu_dma_sync_single_for_cpu+0xb4/0xb8 [ 7.914617] __dma_sync_single_for_cpu+0x158/0x194 [ 7.919428] __this_module+0x5b020/0x5baf8 [spi_tegra210_quad] [ 7.925291] irq_thread_fn+0x2c/0xc0 [ 7.928966] irq_thread+0x16c/0x318 [ 7.932467] kthread+0x12c/0x214 Fix this by removing all calls to the dma_sync_*() functions. This isn't ideal because DMA is used only for relatively large (> 64 words or 256 bytes) and using uncached memory for this might be slow. Reworking this to use cached memory for faster access and reintroducing the cache maintenance calls is probably worth a follow-up patch. Reported-by: Brad Griffis <[email protected]> Fixes: 017f1b0 ("spi: tegra210-quad: Add support for internal DMA") Signed-off-by: Thierry Reding <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 9f0ad43 commit d57e92d

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

drivers/spi/spi-tegra210-quad.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,6 @@ tegra_qspi_read_rx_fifo_to_client_rxbuf(struct tegra_qspi *tqspi, struct spi_tra
407407
static void
408408
tegra_qspi_copy_client_txbuf_to_qspi_txbuf(struct tegra_qspi *tqspi, struct spi_transfer *t)
409409
{
410-
dma_sync_single_for_cpu(tqspi->dev, tqspi->tx_dma_phys,
411-
tqspi->dma_buf_size, DMA_TO_DEVICE);
412-
413410
/*
414411
* In packed mode, each word in FIFO may contain multiple packets
415412
* based on bits per word. So all bytes in each FIFO word are valid.
@@ -442,17 +439,11 @@ tegra_qspi_copy_client_txbuf_to_qspi_txbuf(struct tegra_qspi *tqspi, struct spi_
442439

443440
tqspi->cur_tx_pos += write_bytes;
444441
}
445-
446-
dma_sync_single_for_device(tqspi->dev, tqspi->tx_dma_phys,
447-
tqspi->dma_buf_size, DMA_TO_DEVICE);
448442
}
449443

450444
static void
451445
tegra_qspi_copy_qspi_rxbuf_to_client_rxbuf(struct tegra_qspi *tqspi, struct spi_transfer *t)
452446
{
453-
dma_sync_single_for_cpu(tqspi->dev, tqspi->rx_dma_phys,
454-
tqspi->dma_buf_size, DMA_FROM_DEVICE);
455-
456447
if (tqspi->is_packed) {
457448
tqspi->cur_rx_pos += tqspi->curr_dma_words * tqspi->bytes_per_word;
458449
} else {
@@ -478,9 +469,6 @@ tegra_qspi_copy_qspi_rxbuf_to_client_rxbuf(struct tegra_qspi *tqspi, struct spi_
478469

479470
tqspi->cur_rx_pos += read_bytes;
480471
}
481-
482-
dma_sync_single_for_device(tqspi->dev, tqspi->rx_dma_phys,
483-
tqspi->dma_buf_size, DMA_FROM_DEVICE);
484472
}
485473

486474
static void tegra_qspi_dma_complete(void *args)
@@ -701,8 +689,6 @@ static int tegra_qspi_start_dma_based_transfer(struct tegra_qspi *tqspi, struct
701689
return ret;
702690
}
703691

704-
dma_sync_single_for_device(tqspi->dev, tqspi->rx_dma_phys,
705-
tqspi->dma_buf_size, DMA_FROM_DEVICE);
706692
ret = tegra_qspi_start_rx_dma(tqspi, t, len);
707693
if (ret < 0) {
708694
dev_err(tqspi->dev, "failed to start RX DMA: %d\n", ret);

0 commit comments

Comments
 (0)