Re: [PATCH 2/2] spi: tegra210-quad: Unmap DMA buffers on transfer timeout

From: Mark Brown

Date: Fri Oct 23 2026 - 13:59:51 EST


> tegra_qspi_start_dma_based_transfer() maps the client TX/RX buffers with
> dma_map_single() via tegra_qspi_dma_map_xfer(). The matching unmap only
> happens in handle_dma_based_xfer(), which runs from the interrupt bottom
> half.

> index 4a5933d8112cf..b77ad6990e7c0 100644
> --- a/drivers/spi/spi-tegra210-quad.c
> +++ b/drivers/spi/spi-tegra210-quad.c
> @@ -1488,10 +1488,12 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi,
> dev_err(tqspi->dev, "transfer timeout\n");
>
> /* Abort transfer by resetting pio/dma bit */
> - if (tqspi->is_curr_dma_xfer)
> + if (tqspi->is_curr_dma_xfer) {
> tegra_qspi_dma_stop(tqspi);
> - else
> + tegra_qspi_dma_unmap_xfer(tqspi, xfer);

For a multi-chunk transfer if handle_dma_based_xfer() was run on one
chunk then the next fails to start we'll end up here with a DMA transfer
flagged but nothing mapped. In that case we'll get confused, there's no
active transfer to stop and nothing to map. The transfer needs to be
failed on a start error, or the cleanup here needs to handle things not
being mapped.

--
Mark Brown <broonie@xxxxxxxxxx>