Re: [PATCH v2 3/3] spi: dw: Add DMA support for enhanced memory operations

From: Mark Brown

Date: Wed Sep 30 2026 - 13:35:48 EST


On Wed, Sep 30, 2026 at 12:15:35AM -0700, Changhuang Liang wrote:

> Implement DMA support for enhanced SPI memory operations. These
> operations are half-duplex, so they work with either one or two DMA
> channels.

> +static void dw_spi_enh_mem_dma_stop(struct dw_spi *dws)
> +{
> + if (dws->tx_dir) {
> + if (test_bit(DW_SPI_TX_BUSY, &dws->dma_chan_busy)) {
> + dmaengine_terminate_sync(dws->txchan);
> + clear_bit(DW_SPI_TX_BUSY, &dws->dma_chan_busy);
> + }
> + } else {
> + if (test_bit(DW_SPI_RX_BUSY, &dws->dma_chan_busy)) {
> + dmaengine_terminate_sync(dws->rxchan);
> + clear_bit(DW_SPI_RX_BUSY, &dws->dma_chan_busy);
> + }
> + }
> +}

It would probably be safer to unconditionally stop the DMA and clear the
busy bit, we're only doing this in error cases so we shouldn't rely on
everything being in a joined up state. Equally, I see the same pattern
in the existing code so if we're going to fix it we could fix both at
once.

Attachment: signature.asc
Description: PGP signature