[PATCH 5/5] spi: spi-zynqmp-gqspi: Use IO mode if RX buffer is not cache-line aligned
From: Srikanth Boyapally
Date: Sun Nov 15 2026 - 11:58:08 EST
From: Amit Kumar Mahapatra <amit.kumar-mahapatra@xxxxxxx>
The QSPI DMA maps the receive buffer with dma_map_single(). That API
requires the mapped region to start on a CPU cache-line boundary,
otherwise the cache line can be shared with unrelated data and the
received data can be corrupted. The 4-byte alignment check does not
guarantee this.
The ZynqMP QSPI node is not marked dma-coherent. Fall back to IO mode
for the whole transfer when the receive buffer start address is not
aligned to dma_get_cache_alignment(), in the same way as the existing
short-transfer and 4-byte alignment checks.
Signed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@xxxxxxx>
Signed-off-by: Srikanth Boyapally <srikanth.boyapally@xxxxxxx>
---
drivers/spi/spi-zynqmp-gqspi.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c
index 28edc5e82c16..487e2e0b4da6 100644
--- a/drivers/spi/spi-zynqmp-gqspi.c
+++ b/drivers/spi/spi-zynqmp-gqspi.c
@@ -871,7 +871,8 @@ static int zynqmp_qspi_setuprxdma(struct zynqmp_qspi *xqspi)
u64 dma_align = (u64)(uintptr_t)xqspi->rxbuf;
if (xqspi->bytes_to_receive < 8 ||
- ((dma_align & GQSPI_DMA_UNALIGN) != 0x0)) {
+ ((dma_align & GQSPI_DMA_UNALIGN) != 0x0) ||
+ !IS_ALIGNED(dma_align, dma_get_cache_alignment())) {
/* Setting to IO mode */
zynqmp_qspi_disable_dma(xqspi);
xqspi->dma_rx_bytes = 0;
--
2.43.0