Re: [PATCH] spi: omap2-mcspi: handle DMA setup failures

From: Mark Brown

Date: Tue Oct 13 2026 - 12:52:00 EST


On Tue, Oct 13, 2026 at 07:50:04PM +0530, Sahaj Chaudhari wrote:
> The DMA paths ignore failures from dmaengine_slave_config(), descriptor
> preparation and dmaengine_submit(), and carry FIXME comments about
> falling back to PIO. A failed setup can leave a half-started transfer
> or wait for a completion that never arrives.

> @@ -1227,10 +1300,27 @@ static int omap2_mcspi_transfer_one(struct spi_controller *ctlr,
> + OMAP2_MCSPI_TX0);
>
> if ((mcspi_dma->dma_rx && mcspi_dma->dma_tx) &&
> - spi_xfer_is_dma_mapped(ctlr, spi, t))
> - count = omap2_mcspi_txrx_dma(spi, t);
> - else
> + spi_xfer_is_dma_mapped(ctlr, spi, t)) {
> + ret = omap2_mcspi_txrx_dma(spi, t, &count,
> + &pio_fallback);
> + if (ret) {
> + bool is_target = spi_controller_is_target(ctlr);
> + bool fallback;
> +
> + fallback = omap2_mcspi_can_pio_fallback(pio_fallback, t,
> + is_target);
> + if (!fallback) {
> + status = ret;
> + goto out;
> + }
> +
> + dev_warn(&spi->dev,
> + "DMA setup failed, falling back to PIO\n");
> + count = omap2_mcspi_txrx_pio(spi, t);

Do we need to turn off the FIFO here before doing PIO?

> + }
> + } else {
> count = omap2_mcspi_txrx_pio(spi, t);
> + }
>
> if (count != t->len) {
> status = -EIO;
> @@ -1246,8 +1336,12 @@ static int omap2_mcspi_transfer_one(struct spi_controller *ctlr,
> out:
> /* Restore defaults if they were overriden */
> if (par_override) {
> + int restore_status;
> +
> par_override = 0;
> - status = omap2_mcspi_setup_transfer(spi, NULL);
> + restore_status = omap2_mcspi_setup_transfer(spi, NULL);
> + if (!status)
> + status = restore_status;
> }
>
> omap2_mcspi_set_enable(spi, 0);
> --
> 2.43.0
>

Attachment: signature.asc
Description: PGP signature