Skip to content

Commit 9602a84

Browse files
lategoodbyevinodkoul
authored andcommitted
dmaengine: bcm2835-dma: Prevent suspend if DMA channel is busy
bcm2835-dma provides the service to others, so it should suspend late and resume early. Suspend should be prevented in case a DMA channel is still busy. Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Link: https://lore.kernel.org/r/20241204165546.77941-1-wahrenst@gmx.net Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 68811c9 commit 9602a84

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/dma/bcm2835-dma.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,27 @@ static struct dma_chan *bcm2835_dma_xlate(struct of_phandle_args *spec,
875875
return chan;
876876
}
877877

878+
static int bcm2835_dma_suspend_late(struct device *dev)
879+
{
880+
struct bcm2835_dmadev *od = dev_get_drvdata(dev);
881+
struct bcm2835_chan *c, *next;
882+
883+
list_for_each_entry_safe(c, next, &od->ddev.channels,
884+
vc.chan.device_node) {
885+
void __iomem *chan_base = c->chan_base;
886+
887+
/* Check if DMA channel is busy */
888+
if (readl(chan_base + BCM2835_DMA_ADDR))
889+
return -EBUSY;
890+
}
891+
892+
return 0;
893+
}
894+
895+
static const struct dev_pm_ops bcm2835_dma_pm_ops = {
896+
SET_LATE_SYSTEM_SLEEP_PM_OPS(bcm2835_dma_suspend_late, NULL)
897+
};
898+
878899
static int bcm2835_dma_probe(struct platform_device *pdev)
879900
{
880901
struct bcm2835_dmadev *od;
@@ -1033,6 +1054,7 @@ static struct platform_driver bcm2835_dma_driver = {
10331054
.driver = {
10341055
.name = "bcm2835-dma",
10351056
.of_match_table = of_match_ptr(bcm2835_dma_of_match),
1057+
.pm = pm_ptr(&bcm2835_dma_pm_ops),
10361058
},
10371059
};
10381060

0 commit comments

Comments
 (0)