Skip to content

Commit e1777c4

Browse files
leitaogregkh
authored andcommitted
spi: tegra210-quad: Return IRQ_HANDLED when timeout already processed transfer
[ Upstream commit aabd8ea ] 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 <leitao@debian.org> Signed-off-by: Usama Arif <usamaarif642@gmail.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Acked-by: Jon Hunter <jonathanh@nvidia.com> Acked-by: Thierry Reding <treding@nvidia.com> Link: https://patch.msgid.link/20260126-tegra_xfer-v2-1-6d2115e4f387@debian.org Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b767cf2 commit e1777c4

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
@@ -1488,15 +1488,30 @@ static irqreturn_t handle_dma_based_xfer(struct tegra_qspi *tqspi)
14881488
static irqreturn_t tegra_qspi_isr_thread(int irq, void *context_data)
14891489
{
14901490
struct tegra_qspi *tqspi = context_data;
1491+
u32 status;
1492+
1493+
/*
1494+
* Read transfer status to check if interrupt was triggered by transfer
1495+
* completion
1496+
*/
1497+
status = tegra_qspi_readl(tqspi, QSPI_TRANS_STATUS);
14911498

14921499
/*
14931500
* Occasionally the IRQ thread takes a long time to wake up (usually
14941501
* when the CPU that it's running on is excessively busy) and we have
14951502
* already reached the timeout before and cleaned up the timed out
14961503
* transfer. Avoid any processing in that case and bail out early.
1504+
*
1505+
* If no transfer is in progress, check if this was a real interrupt
1506+
* that the timeout handler already processed, or a spurious one.
14971507
*/
1498-
if (!tqspi->curr_xfer)
1499-
return IRQ_NONE;
1508+
if (!tqspi->curr_xfer) {
1509+
/* Spurious interrupt - transfer not ready */
1510+
if (!(status & QSPI_RDY))
1511+
return IRQ_NONE;
1512+
/* Real interrupt, already handled by timeout path */
1513+
return IRQ_HANDLED;
1514+
}
15001515

15011516
tqspi->status_reg = tegra_qspi_readl(tqspi, QSPI_FIFO_STATUS);
15021517

0 commit comments

Comments
 (0)