Re: [PATCH 5/5] spi: spi-zynqmp-gqspi: Use IO mode if RX buffer is not cache-line aligned

From: Mark Brown

Date: Mon Nov 23 2026 - 14:04:37 EST


> 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.

> +++ 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())) {

Note that we have the same requirement for the end of the buffer.

--
Mark Brown <broonie@xxxxxxxxxx>