drivers/spi/spi-spacemit-k1.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
From: Surendra Singh Chouhan <kr494167@gmail.com>
k1_spi_dma_one() currently submits the TX DMA descriptor to the DMA engine
before preparing the RX DMA descriptor. If preparing the RX descriptor
subsequently fails, the function jumps to the fallback error path without
canceling or aborting the already submitted TX DMA descriptor.
Fix this by preparing both the TX and RX descriptors before submitting
either of them to the DMA engine.
Fixes: efcd8b9d1111 ("spi: spacemit: introduce SpacemiT K1 SPI controller driver")
Reviewed-by: Alex Elder <elder@riscstar.com>
Signed-off-by: Surendra Singh Chouhan <kr494167@gmail.com>
---
drivers/spi/spi-spacemit-k1.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/spi/spi-spacemit-k1.c b/drivers/spi/spi-spacemit-k1.c
index 215fe66d27b4..96b41b67fcbf 100644
--- a/drivers/spi/spi-spacemit-k1.c
+++ b/drivers/spi/spi-spacemit-k1.c
@@ -278,25 +278,25 @@ static int k1_spi_dma_one(struct spi_controller *host, struct spi_device *spi,
struct spi_transfer *transfer)
{
struct k1_spi_driver_data *drv_data = spi_controller_get_devdata(host);
- struct dma_async_tx_descriptor *desc;
+ struct dma_async_tx_descriptor *txdesc, *rxdesc;
u32 val;
- /* Prepare the TX descriptor and submit it */
- desc = k1_spi_dma_prep(drv_data, transfer, true);
- if (!desc)
+ /* Prepare the TX descriptor */
+ txdesc = k1_spi_dma_prep(drv_data, transfer, true);
+ if (!txdesc)
goto fallback;
- dmaengine_submit(desc);
- /* Prepare the RX descriptor and submit it */
- desc = k1_spi_dma_prep(drv_data, transfer, false);
- if (!desc)
+ /* Prepare the RX descriptor */
+ rxdesc = k1_spi_dma_prep(drv_data, transfer, false);
+ if (!rxdesc)
goto fallback;
/* When RX is complete we also know TX has completed */
- desc->callback = k1_spi_dma_callback;
- desc->callback_param = drv_data;
+ rxdesc->callback = k1_spi_dma_callback;
+ rxdesc->callback_param = drv_data;
- dmaengine_submit(desc);
+ dmaengine_submit(txdesc);
+ dmaengine_submit(rxdesc);
val = readl(drv_data->base + SSP_TOP_CTRL);
val |= TOP_TRAIL; /* Trailing bytes handled by DMA */
--
2.55.0
On Wed, 22 Jul 2026 21:54:44 +0530, kr494167@gmail.com wrote:
> spi: spacemit: prepare both DMA descriptors before submitting
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.2
Thanks!
[1/1] spi: spacemit: prepare both DMA descriptors before submitting
https://git.kernel.org/broonie/spi/c/d3c87e71539c
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
© 2016 - 2026 Red Hat, Inc.