OSDN Git Service

spi: spi-cadence: Only overlap FIFO transactions in slave mode
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Tue, 9 May 2023 16:41:53 +0000 (17:41 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 15 May 2023 01:21:40 +0000 (10:21 +0900)
commita0eb7be22c0f934d1fe7e1131f174ef5bc59d3f9
treecae434af9cab8476a33d3533c189c7e3492ea598
parenta84c11e16dc2cc1faad2e688f8c12beeb369d80c
spi: spi-cadence: Only overlap FIFO transactions in slave mode

Commit b1b90514eaa3 ("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 49530e641178 ("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: b1b90514eaa3 ("spi: spi-cadence: Add support for Slave mode")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com
Link: https://lore.kernel.org/r/20230509164153.3907694-2-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org
drivers/spi/spi-cadence.c