Re: [PATCH v4 5/5] spi: dw: use threaded interrupt and optimize the threaded ISR
From: Mark Brown
Date: Tue Sep 29 2026 - 10:20:53 EST
On Tue, Sep 29, 2026 at 08:18:17PM +0800, Jisheng Zhang wrote:
> To avoid blocking for an excessive amount of time, eventually impacting
> on system responsiveness, hard interrupt handlers should finish
> executing in as little time as possible.
> static irqreturn_t dw_spi_transfer_handler(struct dw_spi *dws)
> {
> u16 irq_status = dw_readl(dws, DW_SPI_ISR);
> @@ -245,7 +296,13 @@ static irqreturn_t dw_spi_transfer_handler(struct dw_spi *dws)
> dw_spi_mask_intr(dws, DW_SPI_INT_TXEI);
> }
>
> - return IRQ_HANDLED;
> + if (spi_controller_is_target(dws->ctlr) || !dws->rx_len || !dws->tx_len ||
> + !spi_get_csgpiod(dws->ctlr->cur_msg->spi, 0)) {
> + return IRQ_HANDLED;
> + } else {
> + dw_spi_mask_intr(dws, 0xff);
> + return IRQ_WAKE_THREAD;
> + }
> }
If we're handing a short transfer in the first interrupt then we will
already have completed the transfer at the point we check have which
would allow another CPU to start another transfer first. If things go
very badly this might mean that the length checks look at the values
from a new transfer and wake the thread. We should probably set a local
flag before we complete the transfer and use that to decide if we wake
the thread.
Attachment:
signature.asc
Description: PGP signature