spi: spacemit: prepare both DMA descriptors before submitting
Subsystems (3)
PATCH v2 1/1 spi: spacemit: prepare both DMA descriptors before submitting
From: Surendra Singh Chouhan <[email protected]>
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.
--- drivers/spi/spi-spacemit-k1.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/spi/spi-spacemit-k1.c +11 -11
@@ -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 */
Signature · 1 line
2.55.0
Mark Brown
maintainerQuoted 1 line · On Wed, 22 Jul 2026 21:54:44 +0530, [email protected] 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