]> www.infradead.org Git - linux.git/commitdiff
dmaengine: altera-msgdma: cleanup after completing all descriptors
authorOlivier Dautricourt <olivierdautricourt@gmail.com>
Sat, 8 Jun 2024 21:31:47 +0000 (23:31 +0200)
committerVinod Koul <vkoul@kernel.org>
Tue, 11 Jun 2024 16:20:55 +0000 (21:50 +0530)
msgdma_chan_desc_cleanup iterates the done list for each completed
descriptor while we need to do it once after all descriptors are
completed.

This fixes a Sparse warning because we first take the lock in
msgdma_tasklet.
- Move locking to msgdma_chan_desc_cleanup.
- Move call to msgdma_chan_desc_cleanup outside of the critical section of
msgdma_tasklet.

Inspired by: commit 16ed0ef3e931 ("dmaengine: zynqmp_dma: cleanup after
                                   completing all descriptors")

Signed-off-by: Olivier Dautricourt <olivierdautricourt@gmail.com>
Tested-by: Olivier Dautricourt <olivierdautricourt@gmail.com>
Suggested-by: Eric Schwarz <eas@sw-optimization.com>
Link: https://lore.kernel.org/r/20240608213216.25087-2-olivierdautricourt@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/altera-msgdma.c

index 160a465b06dd8f1e45c4c0f0b06fe28726415c2e..f32453c97dac15304ebaabb23e75136ca8b8242f 100644 (file)
@@ -585,6 +585,8 @@ static void msgdma_chan_desc_cleanup(struct msgdma_device *mdev)
        struct msgdma_sw_desc *desc, *next;
        unsigned long irqflags;
 
+       spin_lock_irqsave(&mdev->lock, irqflags);
+
        list_for_each_entry_safe(desc, next, &mdev->done_list, node) {
                struct dmaengine_desc_callback cb;
 
@@ -600,6 +602,8 @@ static void msgdma_chan_desc_cleanup(struct msgdma_device *mdev)
                /* Run any dependencies, then free the descriptor */
                msgdma_free_descriptor(mdev, desc);
        }
+
+       spin_unlock_irqrestore(&mdev->lock, irqflags);
 }
 
 /**
@@ -714,10 +718,11 @@ static void msgdma_tasklet(struct tasklet_struct *t)
                }
 
                msgdma_complete_descriptor(mdev);
-               msgdma_chan_desc_cleanup(mdev);
        }
 
        spin_unlock_irqrestore(&mdev->lock, flags);
+
+       msgdma_chan_desc_cleanup(mdev);
 }
 
 /**