[PATCH 4/5] spi: spi-zynqmp-gqspi: Drain RX FIFO on RXNEMPTY in IO mode
From: Srikanth Boyapally
Date: Sun Nov 15 2026 - 11:57:10 EST
From: Mohammad Zeeshan <zeeshan.mohammad2@xxxxxxx>
In IO mode the IRQ handler drains the RX FIFO only when GENFIFOEMPTY
is set. IO mode is used for a read shorter than 8 bytes, and for any
read whose buffer is not 4-byte aligned. The unaligned case uses IO
mode for the whole transfer, so the length can exceed the RX FIFO.
Once the FIFO is full the controller stops clocking, pending GENFIFO
commands do not complete, GENFIFOEMPTY never arrives, and the transfer
times out with "Chip select timed out".
RXNEMPTY is already enabled for those transfers and signals that RX
data is ready. Drain the FIFO on that interrupt as well, so the
controller keeps clocking and the transfer can finish.
Fixes: dfe11a11d523 ("spi: Add support for Zynq Ultrascale+ MPSoC GQSPI controller")
Signed-off-by: Mohammad Zeeshan <zeeshan.mohammad2@xxxxxxx>
Signed-off-by: Srikanth Boyapally <srikanth.boyapally@xxxxxxx>
---
drivers/spi/spi-zynqmp-gqspi.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c
index 39f90fc3f453..28edc5e82c16 100644
--- a/drivers/spi/spi-zynqmp-gqspi.c
+++ b/drivers/spi/spi-zynqmp-gqspi.c
@@ -810,9 +810,10 @@ static void zynqmp_process_dma_irq(struct zynqmp_qspi *xqspi)
* @irq: IRQ number
* @dev_id: Pointer to the xqspi structure
*
- * This function handles TX empty only.
+ * This function handles TX empty, and RXNEMPTY in IO mode.
* On TX empty interrupt this function reads the received data from RX FIFO
* and fills the TX FIFO if there is any data remaining to be transferred.
+ * On RXNEMPTY in IO mode, read up to GQSPI_RX_FIFO_FILL bytes from the RX FIFO.
*
* Return: IRQ_HANDLED when interrupt is handled
* IRQ_NONE otherwise.
@@ -840,11 +841,14 @@ static irqreturn_t zynqmp_qspi_irq(int irq, void *dev_id)
if (mask & GQSPI_ISR_TXNOT_FULL_MASK)
zynqmp_qspi_filltxfifo(xqspi, GQSPI_TX_FIFO_FILL);
- if (dma_status & GQSPI_QSPIDMA_DST_I_STS_DONE_MASK)
+ if (dma_status & GQSPI_QSPIDMA_DST_I_STS_DONE_MASK) {
zynqmp_process_dma_irq(xqspi);
- else if (!(mask & GQSPI_IER_RXEMPTY_MASK) &&
- (mask & GQSPI_IER_GENFIFOEMPTY_MASK))
+ } else if ((mask & GQSPI_IER_RXNEMPTY_MASK) ||
+ (!(mask & GQSPI_IER_RXEMPTY_MASK) &&
+ (mask & GQSPI_IER_GENFIFOEMPTY_MASK))) {
+ /* Drain on RXNEMPTY for IO-mode transfers > GQSPI_RX_FIFO_FILL. */
zynqmp_qspi_readrxfifo(xqspi, GQSPI_RX_FIFO_FILL);
+ }
if (xqspi->bytes_to_receive == 0 && xqspi->bytes_to_transfer == 0 &&
((status & GQSPI_IRQ_MASK) == GQSPI_IRQ_MASK)) {
--
2.43.0