[PATCH 10/10] spi: cadence-xspi: Skip tail read for qword-aligned Marvell b0 receives

From: Lee Jones

Date: Thu Nov 19 2026 - 04:19:44 EST


In cdns_xspi_transfer_one_message_b0() the receive path reads len / 8
full qwords and then always calls cdns_xspi_finish_read() to collect
the remaining bytes. cdns_xspi_finish_read() unconditionally advances
current_xfer_qword, even when there are no remaining bytes to read.

The TX-only path only accounts for an extra qword when the length is
not a multiple of 8, so for qword-aligned receives the read index runs
one qword ahead and later chunks and transfers in the same message read
the wrong READ_DATA registers.

Only call cdns_xspi_finish_read() when there is a partial qword left to
read, matching the accounting used by the TX-only path.

Fixes: 931e389ded0f ("spi: cadence: Add Marvell xfer operation support")
Closes: https://sashiko.dev/#/bug/linux-13cf6f1e-c300-4fa1-9cd4-08a48ec4f4b9
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/spi/spi-cadence-xspi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
index 4c9af6146a5d..bd0fdbbd4060 100644
--- a/drivers/spi/spi-cadence-xspi.c
+++ b/drivers/spi/spi-cadence-xspi.c
@@ -1309,7 +1309,9 @@ static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,

for (j = 0; j < current_transfer_len / 8; j++)
marvell_xspi_read_single_qword(cdns_xspi, &rxd);
- cdns_xspi_finish_read(cdns_xspi, &rxd, current_transfer_len);
+ if (current_transfer_len % MRVL_XFER_QWORD_BYTECOUNT)
+ cdns_xspi_finish_read(cdns_xspi, &rxd,
+ current_transfer_len);
} else {
cdns_xspi->current_xfer_qword += current_transfer_len /
MRVL_XFER_QWORD_BYTECOUNT;
--
2.56.1.708.g77570a6a1d-goog