Commit 0ac9c3dd authored by Caleb Connolly's avatar Caleb Connolly Committed by Vinod Koul

dmaengine: qcom: bam_dma: fix runtime PM underflow

Commit dbad41e7 ("dmaengine: qcom: bam_dma: check if the runtime pm enabled")
caused unbalanced pm_runtime_get/put() calls when the bam is
controlled remotely. This commit reverts it and just enables pm_runtime
in all cases, the clk_* functions already just nop when the clock is NULL.

Also clean up a bit by removing unnecessary bamclk null checks.
Suggested-by: default avatarStephan Gerhold <stephan@gerhold.net>
Fixes: dbad41e7 ("dmaengine: qcom: bam_dma: check if the runtime pm enabled")
Signed-off-by: default avatarCaleb Connolly <caleb.connolly@linaro.org>
Link: https://lore.kernel.org/r/20220629140559.118537-1-caleb.connolly@linaro.orgSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent a7cd3cf0
...@@ -558,14 +558,6 @@ static int bam_alloc_chan(struct dma_chan *chan) ...@@ -558,14 +558,6 @@ static int bam_alloc_chan(struct dma_chan *chan)
return 0; return 0;
} }
static int bam_pm_runtime_get_sync(struct device *dev)
{
if (pm_runtime_enabled(dev))
return pm_runtime_get_sync(dev);
return 0;
}
/** /**
* bam_free_chan - Frees dma resources associated with specific channel * bam_free_chan - Frees dma resources associated with specific channel
* @chan: specified channel * @chan: specified channel
...@@ -581,7 +573,7 @@ static void bam_free_chan(struct dma_chan *chan) ...@@ -581,7 +573,7 @@ static void bam_free_chan(struct dma_chan *chan)
unsigned long flags; unsigned long flags;
int ret; int ret;
ret = bam_pm_runtime_get_sync(bdev->dev); ret = pm_runtime_get_sync(bdev->dev);
if (ret < 0) if (ret < 0)
return; return;
...@@ -784,7 +776,7 @@ static int bam_pause(struct dma_chan *chan) ...@@ -784,7 +776,7 @@ static int bam_pause(struct dma_chan *chan)
unsigned long flag; unsigned long flag;
int ret; int ret;
ret = bam_pm_runtime_get_sync(bdev->dev); ret = pm_runtime_get_sync(bdev->dev);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -810,7 +802,7 @@ static int bam_resume(struct dma_chan *chan) ...@@ -810,7 +802,7 @@ static int bam_resume(struct dma_chan *chan)
unsigned long flag; unsigned long flag;
int ret; int ret;
ret = bam_pm_runtime_get_sync(bdev->dev); ret = pm_runtime_get_sync(bdev->dev);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -919,7 +911,7 @@ static irqreturn_t bam_dma_irq(int irq, void *data) ...@@ -919,7 +911,7 @@ static irqreturn_t bam_dma_irq(int irq, void *data)
if (srcs & P_IRQ) if (srcs & P_IRQ)
tasklet_schedule(&bdev->task); tasklet_schedule(&bdev->task);
ret = bam_pm_runtime_get_sync(bdev->dev); ret = pm_runtime_get_sync(bdev->dev);
if (ret < 0) if (ret < 0)
return IRQ_NONE; return IRQ_NONE;
...@@ -1037,7 +1029,7 @@ static void bam_start_dma(struct bam_chan *bchan) ...@@ -1037,7 +1029,7 @@ static void bam_start_dma(struct bam_chan *bchan)
if (!vd) if (!vd)
return; return;
ret = bam_pm_runtime_get_sync(bdev->dev); ret = pm_runtime_get_sync(bdev->dev);
if (ret < 0) if (ret < 0)
return; return;
...@@ -1374,11 +1366,6 @@ static int bam_dma_probe(struct platform_device *pdev) ...@@ -1374,11 +1366,6 @@ static int bam_dma_probe(struct platform_device *pdev)
if (ret) if (ret)
goto err_unregister_dma; goto err_unregister_dma;
if (!bdev->bamclk) {
pm_runtime_disable(&pdev->dev);
return 0;
}
pm_runtime_irq_safe(&pdev->dev); pm_runtime_irq_safe(&pdev->dev);
pm_runtime_set_autosuspend_delay(&pdev->dev, BAM_DMA_AUTOSUSPEND_DELAY); pm_runtime_set_autosuspend_delay(&pdev->dev, BAM_DMA_AUTOSUSPEND_DELAY);
pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_use_autosuspend(&pdev->dev);
...@@ -1462,10 +1449,8 @@ static int __maybe_unused bam_dma_suspend(struct device *dev) ...@@ -1462,10 +1449,8 @@ static int __maybe_unused bam_dma_suspend(struct device *dev)
{ {
struct bam_device *bdev = dev_get_drvdata(dev); struct bam_device *bdev = dev_get_drvdata(dev);
if (bdev->bamclk) { pm_runtime_force_suspend(dev);
pm_runtime_force_suspend(dev); clk_unprepare(bdev->bamclk);
clk_unprepare(bdev->bamclk);
}
return 0; return 0;
} }
...@@ -1475,13 +1460,11 @@ static int __maybe_unused bam_dma_resume(struct device *dev) ...@@ -1475,13 +1460,11 @@ static int __maybe_unused bam_dma_resume(struct device *dev)
struct bam_device *bdev = dev_get_drvdata(dev); struct bam_device *bdev = dev_get_drvdata(dev);
int ret; int ret;
if (bdev->bamclk) { ret = clk_prepare(bdev->bamclk);
ret = clk_prepare(bdev->bamclk); if (ret)
if (ret) return ret;
return ret;
pm_runtime_force_resume(dev); pm_runtime_force_resume(dev);
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment