Skip to content

Commit a0eb7be

Browse files
charleskeepaxbroonie
authored andcommitted
spi: spi-cadence: Only overlap FIFO transactions in slave mode
Commit b1b9051 ("spi: spi-cadence: Add support for Slave mode") updated the code to trigger the IRQ when the FIFO was half empty, overlapping filling more data into the FIFO and sending what is left. This appears to cause regressions on the Zynq 7000, for transactions longer than the FIFO size, below that no overlapping occurs. It would appear from my testing that any attempt to put new data into the FIFO whilst data is still transmitting causes data corruption on both send and receive. If I am reading the commit message right on commit 49530e6 ("spi: cadence: Add usleep_range() for cdns_spi_fill_tx_fifo()"), that would also seem to imply this is the case. On the assumption that this isn't an issue on the platform the original slave mode support was added for, update the cdns_transfer_one to only set the watermark to 50% of the FIFO size when in slave mode. There by retaining the new behaviour for slave mode but reverting to the older behaviour when the SPI is used a master. Fixes: b1b9051 ("spi: spi-cadence: Add support for Slave mode") Signed-off-by: Charles Keepax <[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]
1 parent a84c11e commit a0eb7be

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

drivers/spi/spi-cadence.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -438,14 +438,15 @@ static int cdns_transfer_one(struct spi_controller *ctlr,
438438
xspi->tx_bytes = transfer->len;
439439
xspi->rx_bytes = transfer->len;
440440

441-
if (!spi_controller_is_slave(ctlr))
441+
if (!spi_controller_is_slave(ctlr)) {
442442
cdns_spi_setup_transfer(spi, transfer);
443-
444-
/* Set TX empty threshold to half of FIFO depth
445-
* only if TX bytes are more than half FIFO depth.
446-
*/
447-
if (xspi->tx_bytes > xspi->tx_fifo_depth)
448-
cdns_spi_write(xspi, CDNS_SPI_THLD, xspi->tx_fifo_depth >> 1);
443+
} else {
444+
/* Set TX empty threshold to half of FIFO depth
445+
* only if TX bytes are more than half FIFO depth.
446+
*/
447+
if (xspi->tx_bytes > xspi->tx_fifo_depth)
448+
cdns_spi_write(xspi, CDNS_SPI_THLD, xspi->tx_fifo_depth >> 1);
449+
}
449450

450451
cdns_spi_fill_tx_fifo(xspi, xspi->tx_fifo_depth);
451452
spi_transfer_delay_exec(transfer);

0 commit comments

Comments
 (0)