Re: [PATCH v3 1/3] spi: tegra210-quad: Convert to hard IRQ with high-priority workqueue

From: Mark Brown

Date: Mon Jun 01 2026 - 10:02:05 EST


On Wed, May 20, 2026 at 07:24:03PM +0000, Vishwaroop A wrote:
> Threaded IRQ handlers suffer from scheduler latency on heavily loaded
> systems, causing false transfer timeouts. Convert to hard IRQ handler
> that schedules work on a high-priority unbound workqueue.

> +static void tegra_qspi_work_handler(struct work_struct *work)
> {
> - struct tegra_qspi *tqspi = context_data;
> + struct tegra_qspi *tqspi = container_of(work, struct tegra_qspi, irq_work);
> unsigned long flags;
> - u32 status;

> - spin_lock_irqsave(&tqspi->lock, flags);
> if (!tqspi->curr_xfer) {
> spin_unlock_irqrestore(&tqspi->lock, flags);
> - /* Spurious interrupt - transfer not ready */
> - if (!(status & QSPI_RDY))
> - return IRQ_NONE;
> - /* Real interrupt, already handled by timeout path */
> - return IRQ_HANDLED;
> + tegra_qspi_unmask_irq(tqspi);
> + return;
> }

What ensures that we have a runtime PM reference when this work runs?
It's also a bit odd that we unmask after dropping the lock, that feels
like it opens up races.

> +static irqreturn_t tegra_qspi_isr(int irq, void *context_data)
> +{
> + struct tegra_qspi *tqspi = context_data;
> + u32 status;
> +
> + status = tegra_qspi_readl(tqspi, QSPI_TRANS_STATUS);
> + if (!(status & QSPI_RDY))
> + return IRQ_NONE;

Since we now have IRQF_SHARED we need to take a runtime PM reference
here, the interrupt handler could be called due to something else
sharing the interrupt lin.e

> + ret = devm_request_irq(&pdev->dev, tqspi->irq, tegra_qspi_isr,
> + IRQF_SHARED, dev_name(&pdev->dev), tqspi);

> -exit_free_irq:
> - free_irq(qspi_irq, tqspi);
> exit_pm_disable:
> pm_runtime_dont_use_autosuspend(&pdev->dev);
> pm_runtime_force_suspend(&pdev->dev);

The use of devm for the interrupt with non-devm for other things seems
likely to be racy....

> spi_unregister_controller(host);
> - free_irq(tqspi->irq, tqspi);
> + cancel_work_sync(&tqspi->irq_work);

...especially here.

Attachment: signature.asc
Description: PGP signature