mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Sahaj Chaudhari <sahaj123.sc@gmail.com>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] spi: omap2-mcspi: handle DMA setup failures
Date: Tue, 13 Oct 2026 16:40:22 +0100	[thread overview]
Message-ID: <4a20222b-7d60-4763-9833-bc453d26ade8@sirena.org.uk> (raw)
In-Reply-To: <20261013142004.1729849-1-sahaj123.sc@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1813 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2026-10-13 15:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 14:20 Sahaj Chaudhari
2026-10-13 15:40 ` Mark Brown [this message]
2026-10-14  4:56   ` Sahaj Chaudhari

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4a20222b-7d60-4763-9833-bc453d26ade8@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=sahaj123.sc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®