Skip to content

Commit 633cd6f

Browse files
Amit Kumar Mahapatrabroonie
authored andcommitted
spi: spi-cadence: Reverse the order of interleaved write and read operations
In the existing implementation, when executing interleaved write and read operations in the ISR for a transfer length greater than the FIFO size, the TXFIFO write precedes the RXFIFO read. Consequently, the initially received data in the RXFIFO is pushed out and lost, leading to a failure in data integrity. To address this issue, reverse the order of interleaved operations and conduct the RXFIFO read followed by the TXFIFO write. Fixes: 6afe2ae ("spi: spi-cadence: Interleave write of TX and read of RX FIFO") Signed-off-by: Amit Kumar Mahapatra <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent e267a5b commit 633cd6f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/spi/spi-cadence.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,15 @@ static void cdns_spi_process_fifo(struct cdns_spi *xspi, int ntx, int nrx)
317317
xspi->rx_bytes -= nrx;
318318

319319
while (ntx || nrx) {
320+
if (nrx) {
321+
u8 data = cdns_spi_read(xspi, CDNS_SPI_RXD);
322+
323+
if (xspi->rxbuf)
324+
*xspi->rxbuf++ = data;
325+
326+
nrx--;
327+
}
328+
320329
if (ntx) {
321330
if (xspi->txbuf)
322331
cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi->txbuf++);
@@ -326,14 +335,6 @@ static void cdns_spi_process_fifo(struct cdns_spi *xspi, int ntx, int nrx)
326335
ntx--;
327336
}
328337

329-
if (nrx) {
330-
u8 data = cdns_spi_read(xspi, CDNS_SPI_RXD);
331-
332-
if (xspi->rxbuf)
333-
*xspi->rxbuf++ = data;
334-
335-
nrx--;
336-
}
337338
}
338339
}
339340

0 commit comments

Comments
 (0)