Re: [PATCH v4 04/12] dmaengine: switchtec-dma: halt channel on alloc_chan_resources error

Frank Li <[email protected]>
Newsgroups org.kernel.vger.linux-pci,org.kernel.vger.dmaengine,org.kernel.vger.linux-kernel
Message-ID <an9xtp8SHJeaBmNF@lizhi-Precision-Tower-5810>
On Tue, Jul 28, 2026 at 11:15:15AM -0600, Logan Gunthorpe wrote:
> The error-unwind path called disable_channel() before freeing the
> descriptor rings, but that only clears the enable bit with an
> unflushed write -- it doesn't halt the channel or clear its DMA base
> address registers. If unhalt_channel() timed out, the channel's actual
> state is unknown at that point, so nothing guarantees the hardware
> isn't still touching the rings when they're freed.
>
> Call switchtec_dma_chan_stop() first, matching what
> switchtec_dma_free_chan_resources() already does before freeing
> descriptors on the normal teardown path: it synchronously halts the
> channel and zeroes the DMA base registers. If the halt itself can't be
> confirmed, skip freeing the descriptor rings (leaking them instead).
>
> Fixes: 30eba9df76ad ("dmaengine: switchtec-dma: Implement hardware initialization and cleanup")
> Reported-by: Sashiko <[email protected]>
> Link: https://lore.kernel.org/dmaengine/[email protected]
> Link: https://lore.kernel.org/dmaengine/[email protected]
> Signed-off-by: Logan Gunthorpe <[email protected]>
> ---

Like patch4, leave it as it now utile we found go method.

You'd better post new patches, which just include my review-by tags, so
vnod can handle easily.

Then continue work on two sashiko report unlikely happen problem.

Frank

>  drivers/dma/switchtec_dma.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/dma/switchtec_dma.c b/drivers/dma/switchtec_dma.c
> index cbbc9ad08247..25b988e9b4af 100644
> --- a/drivers/dma/switchtec_dma.c
> +++ b/drivers/dma/switchtec_dma.c
> @@ -1047,6 +1047,10 @@ static int switchtec_dma_alloc_chan_resources(struct dma_chan *chan)
>  	swdma_chan->comp_ring_active = false;
>  	spin_unlock_bh(&swdma_chan->complete_lock);
>  err_disable_channel:
> +	if (switchtec_dma_chan_stop(swdma_chan)) {
> +		disable_channel(swdma_chan);
> +		return rc;
> +	}
>  	disable_channel(swdma_chan);
>  err_free_desc:
>  	switchtec_dma_free_desc(swdma_chan);
> --
> 2.47.3
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.