History

dmaengine: qcom: bam_dma: fix runtime PM underflow

Commit dbad41e7bb5f ("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.

Caleb Connolly committed 4 years ago

Commit 0ac9c3d1 parent a7cd3cf1 file · +11 −28Browse files

Unified · Split

drivers/dma/qcom/bam_dma.c+11−28
@@ -558,14 +558,6 @@ static int bam_alloc_chan(struct dma_chan *chan) · 557 unmodified lines
558 return 0;558 return 0;
559}559}
560 560
561static int bam_pm_runtime_get_sync(struct device *dev)
562{
563 if (pm_runtime_enabled(dev))
564 return pm_runtime_get_sync(dev);
565
566 return 0;
567}
568
569/**561/**
570 * bam_free_chan - Frees dma resources associated with specific channel562 * bam_free_chan - Frees dma resources associated with specific channel
571 * @chan: specified channel563 * @chan: specified channel
@@ -581,7 +573,7 @@ static void bam_free_chan(struct dma_chan *chan) · 9 unmodified lines
581 unsigned long flags;573 unsigned long flags;
582 int ret;574 int ret;
583 575
584 ret = bam_pm_runtime_get_sync(bdev->dev);576 ret = pm_runtime_get_sync(bdev->dev);
585 if (ret < 0)577 if (ret < 0)
586 return;578 return;
587 579
@@ -784,7 +776,7 @@ static int bam_pause(struct dma_chan *chan) · 196 unmodified lines
784 unsigned long flag;776 unsigned long flag;
785 int ret;777 int ret;
786 778
787 ret = bam_pm_runtime_get_sync(bdev->dev);779 ret = pm_runtime_get_sync(bdev->dev);
788 if (ret < 0)780 if (ret < 0)
789 return ret;781 return ret;
790 782
@@ -810,7 +802,7 @@ static int bam_resume(struct dma_chan *chan) · 19 unmodified lines
810 unsigned long flag;802 unsigned long flag;
811 int ret;803 int ret;
812 804
813 ret = bam_pm_runtime_get_sync(bdev->dev);805 ret = pm_runtime_get_sync(bdev->dev);
814 if (ret < 0)806 if (ret < 0)
815 return ret;807 return ret;
816 808
@@ -919,7 +911,7 @@ static irqreturn_t bam_dma_irq(int irq, void *data) · 102 unmodified lines
919 if (srcs & P_IRQ)911 if (srcs & P_IRQ)
920 tasklet_schedule(&bdev->task);912 tasklet_schedule(&bdev->task);
921 913
922 ret = bam_pm_runtime_get_sync(bdev->dev);914 ret = pm_runtime_get_sync(bdev->dev);
923 if (ret < 0)915 if (ret < 0)
924 return IRQ_NONE;916 return IRQ_NONE;
925 917
@@ -1037,7 +1029,7 @@ static void bam_start_dma(struct bam_chan *bchan) · 111 unmodified lines
1037 if (!vd)1029 if (!vd)
1038 return;1030 return;
1039 1031
1040 ret = bam_pm_runtime_get_sync(bdev->dev);1032 ret = pm_runtime_get_sync(bdev->dev);
1041 if (ret < 0)1033 if (ret < 0)
1042 return;1034 return;
1043 1035
@@ -1374,11 +1366,6 @@ static int bam_dma_probe(struct platform_device *pdev) · 330 unmodified lines
1374 if (ret)1366 if (ret)
1375 goto err_unregister_dma;1367 goto err_unregister_dma;
1376 1368
1377 if (!bdev->bamclk) {
1378 pm_runtime_disable(&pdev->dev);
1379 return 0;
1380 }
1381
1382 pm_runtime_irq_safe(&pdev->dev);1369 pm_runtime_irq_safe(&pdev->dev);
1383 pm_runtime_set_autosuspend_delay(&pdev->dev, BAM_DMA_AUTOSUSPEND_DELAY);1370 pm_runtime_set_autosuspend_delay(&pdev->dev, BAM_DMA_AUTOSUSPEND_DELAY);
1384 pm_runtime_use_autosuspend(&pdev->dev);1371 pm_runtime_use_autosuspend(&pdev->dev);
@@ -1462,10 +1449,8 @@ static int __maybe_unused bam_dma_suspend(struct device *dev) · 77 unmodified lines
1462{1449{
1463 struct bam_device *bdev = dev_get_drvdata(dev);1450 struct bam_device *bdev = dev_get_drvdata(dev);
1464 1451
1465 if (bdev->bamclk) {1452 pm_runtime_force_suspend(dev);
1466 pm_runtime_force_suspend(dev);1453 clk_unprepare(bdev->bamclk);
1467 clk_unprepare(bdev->bamclk);
1468 }
1469 1454
1470 return 0;1455 return 0;
1471}1456}
@@ -1475,13 +1460,11 @@ static int __maybe_unused bam_dma_resume(struct device *dev) · 3 unmodified lines
1475 struct bam_device *bdev = dev_get_drvdata(dev);1460 struct bam_device *bdev = dev_get_drvdata(dev);
1476 int ret;1461 int ret;
1477 1462
1478 if (bdev->bamclk) {1463 ret = clk_prepare(bdev->bamclk);
1479 ret = clk_prepare(bdev->bamclk);1464 if (ret)
1480 if (ret)1465 return ret;
1481 return ret;
1482 1466
1483 pm_runtime_force_resume(dev);1467 pm_runtime_force_resume(dev);
1484 }
1485 1468
1486 return 0;1469 return 0;
1487}1470}