[PATCH 1/2] spi: spacemit: fix dangling TX DMA descriptor on RX prep failure

From: Pei Xiao

Date: Mon Jul 20 2026 - 02:09:38 EST


In k1_spi_dma_one(), the TX DMA descriptor is submitted via
dmaengine_submit() before the RX descriptor is prepared. If
k1_spi_dma_prep() fails for RX, the function jumps to the fallback
path without terminating the already-submitted TX descriptor.

So terminate the TX channel with dmaengine_terminate_sync() when RX
descriptor preparation fails.

Fixes: efcd8b9d1111 ("spi: spacemit: introduce SpacemiT K1 SPI controller driver")
Signed-off-by: Pei Xiao <xiaopei01@xxxxxxxxxx>
---
drivers/spi/spi-spacemit-k1.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-spacemit-k1.c b/drivers/spi/spi-spacemit-k1.c
index 215fe66d27b4..cd2955949c5c 100644
--- a/drivers/spi/spi-spacemit-k1.c
+++ b/drivers/spi/spi-spacemit-k1.c
@@ -289,8 +289,10 @@ static int k1_spi_dma_one(struct spi_controller *host, struct spi_device *spi,

/* Prepare the RX descriptor and submit it */
desc = k1_spi_dma_prep(drv_data, transfer, false);
- if (!desc)
+ if (!desc) {
+ dmaengine_terminate_sync(host->dma_tx);
goto fallback;
+ }

/* When RX is complete we also know TX has completed */
desc->callback = k1_spi_dma_callback;
--
2.25.1