[PATCH v3 03/11] dmaengine: switchtec-dma: halt channel on alloc_chan_resources error
Logan Gunthorpe <[email protected]> Mon, 27 Jul 2026 12:15:18 -0600
| Newsgroups | org.kernel.vger.dmaengine,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci |
|---|---|
| Message-ID | <[email protected]> |
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.
Fixes: 30eba9df76ad ("dmaengine: switchtec-dma: Implement hardware initialization and cleanup")
Reported-by: Sashiko <[email protected]>
Link: https://lore.kernel.org/dmaengine/[email protected]
Signed-off-by: Logan Gunthorpe <[email protected]>
---
drivers/dma/switchtec_dma.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/dma/switchtec_dma.c b/drivers/dma/switchtec_dma.c
index f77da31aeb65..107769cca772 100644
--- a/drivers/dma/switchtec_dma.c
+++ b/drivers/dma/switchtec_dma.c
@@ -1040,6 +1040,7 @@ 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:
+ switchtec_dma_chan_stop(swdma_chan);
disable_channel(swdma_chan);
err_free_desc:
switchtec_dma_free_desc(swdma_chan);
--
2.47.3