From: "Baek Kyu, Kim" <pocj8ur4in@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: "Baek Kyu, Kim" <pocj8ur4in@gmail.com>,
Carlos Song <carlos.song@nxp.com>, Frank Li <Frank.Li@nxp.com>,
linux-spi@vger.kernel.org, imx@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: [PATCH] spi: imx: Avoid PIO replay after a completed DMA package
Date: Sat, 31 Oct 2026 15:03:44 +0900 [thread overview]
Message-ID: <20261031060344.94687-1-pocj8ur4in@gmail.com> (raw)
A transfer can span two DMA packages. If the first package completes but
preparing the second one fails, the helper sets SPI_TRANS_FAIL_NO_START
for the second package. The driver treats that flag as applying to the
whole transfer and retries all of it through PIO, sending the completed
prefix twice and reporting success.
Clear NO_START after a failed later package has been unmapped. The driver
then returns the original error without replaying the transfer. A failure
in the first package still takes the existing PIO fallback path.
Fixes: faa8e404ad8e ("spi: imx: support dynamic burst length for ECSPI DMA mode")
Signed-off-by: Baek Kyu, Kim <pocj8ur4in@gmail.com>
---
In an arm64 QEMU/KVM kernel, the SPI core and spi-imx driver ran with
modeled MMIO/FIFO and DMA provider callbacks. A 513-byte transfer
completed its first 512-byte package; failing RX descriptor preparation
for the second package made the original driver replay all 513 bytes
through PIO and report success (1025 bytes in the modeled record). With
this change it returned -EINVAL after the first 512 bytes and sent no
PIO bytes. First-package fallback still completed through PIO. No
physical ECSPI/SDMA device or external slave was tested.
drivers/spi/spi-imx.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 79a6c1a60b0a0..eed1936388aa8 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -1968,6 +1968,9 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
spi_imx_dma_unmap(spi_imx, &spi_imx->dma_data[i]);
if (ret < 0) {
+ /* Earlier packages have already been transferred. */
+ if (i)
+ transfer->error &= ~SPI_TRANS_FAIL_NO_START;
dev_dbg(spi_imx->dev, "DMA %d transfer not really finish\n", i);
break;
}
--
2.55.0
reply other threads:[~2026-10-31 6:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261031060344.94687-1-pocj8ur4in@gmail.com \
--to=pocj8ur4in@gmail.com \
--cc=Frank.Li@nxp.com \
--cc=broonie@kernel.org \
--cc=carlos.song@nxp.com \
--cc=imx@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
/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®