Skip to content

Commit aabd8ea

Browse files
leitaobroonie
authored andcommitted
spi: tegra210-quad: Return IRQ_HANDLED when timeout already processed transfer
When the ISR thread wakes up late and finds that the timeout handler has already processed the transfer (curr_xfer is NULL), return IRQ_HANDLED instead of IRQ_NONE. Use a similar approach to tegra_qspi_handle_timeout() by reading QSPI_TRANS_STATUS and checking the QSPI_RDY bit to determine if the hardware actually completed the transfer. If QSPI_RDY is set, the interrupt was legitimate and triggered by real hardware activity. The fact that the timeout path handled it first doesn't make it spurious. Returning IRQ_NONE incorrectly suggests the interrupt wasn't for this device, which can cause issues with shared interrupt lines and interrupt accounting. Fixes: b4e002d ("spi: tegra210-quad: Fix timeout handling") Signed-off-by: Breno Leitao <[email protected]> Signed-off-by: Usama Arif <[email protected]> Tested-by: Jon Hunter <[email protected]> Acked-by: Jon Hunter <[email protected]> Acked-by: Thierry Reding <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 63804fe commit aabd8ea

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

drivers/spi/spi-tegra210-quad.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,15 +1552,30 @@ static irqreturn_t handle_dma_based_xfer(struct tegra_qspi *tqspi)
15521552
static irqreturn_t tegra_qspi_isr_thread(int irq, void *context_data)
15531553
{
15541554
struct tegra_qspi *tqspi = context_data;
1555+
u32 status;
1556+
1557+
/*
1558+
* Read transfer status to check if interrupt was triggered by transfer
1559+
* completion
1560+
*/
1561+
status = tegra_qspi_readl(tqspi, QSPI_TRANS_STATUS);
15551562

15561563
/*
15571564
* Occasionally the IRQ thread takes a long time to wake up (usually
15581565
* when the CPU that it's running on is excessively busy) and we have
15591566
* already reached the timeout before and cleaned up the timed out
15601567
* transfer. Avoid any processing in that case and bail out early.
1568+
*
1569+
* If no transfer is in progress, check if this was a real interrupt
1570+
* that the timeout handler already processed, or a spurious one.
15611571
*/
1562-
if (!tqspi->curr_xfer)
1563-
return IRQ_NONE;
1572+
if (!tqspi->curr_xfer) {
1573+
/* Spurious interrupt - transfer not ready */
1574+
if (!(status & QSPI_RDY))
1575+
return IRQ_NONE;
1576+
/* Real interrupt, already handled by timeout path */
1577+
return IRQ_HANDLED;
1578+
}
15641579

15651580
tqspi->status_reg = tegra_qspi_readl(tqspi, QSPI_FIFO_STATUS);
15661581

0 commit comments

Comments
 (0)