MLK-25473-1 dmaengine: imx-sdma: Revert "MLK-25465-6 dmaengine: imx-sdma: fix the...
authorRobin Gong <yibin.gong@nxp.com>
Thu, 29 Apr 2021 19:39:37 +0000 (03:39 +0800)
committerRobin Gong <yibin.gong@nxp.com>
Fri, 30 Apr 2021 15:09:51 +0000 (23:09 +0800)
This reverts commit ec4de359d4a2bafa24b8078dce4c9979a477de39.
pm_runtime_forbid/pm_runtime_allow may cause the next running dma channel
stopped(runtime_suspend) after the last channel terminated, because all
channel share the same pm_runtime. Revert it to use autosuspend and
increase the autosuspend delay to 8s instead.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
drivers/dma/imx-sdma.c

index 394a713..78594f2 100644 (file)
@@ -976,8 +976,12 @@ static irqreturn_t sdma_int_handler(int irq, void *dev_id)
        struct sdma_engine *sdma = dev_id;
        unsigned long stat;
 
-       clk_enable(sdma->clk_ipg);
-       clk_enable(sdma->clk_ahb);
+       if (sdma->drvdata->pm_runtime)
+               pm_runtime_get_sync(sdma->dev);
+       else {
+               clk_enable(sdma->clk_ipg);
+               clk_enable(sdma->clk_ahb);
+       }
 
        stat = readl_relaxed(sdma->regs + SDMA_H_INTR);
        writel_relaxed(stat, sdma->regs + SDMA_H_INTR);
@@ -1008,8 +1012,13 @@ static irqreturn_t sdma_int_handler(int irq, void *dev_id)
                __clear_bit(channel, &stat);
        }
 
-       clk_disable(sdma->clk_ipg);
-       clk_disable(sdma->clk_ahb);
+       if (sdma->drvdata->pm_runtime) {
+               pm_runtime_mark_last_busy(sdma->dev);
+               pm_runtime_put_autosuspend(sdma->dev);
+       } else {
+               clk_disable(sdma->clk_ipg);
+               clk_disable(sdma->clk_ahb);
+       }
 
        return IRQ_HANDLED;
 }
@@ -1252,6 +1261,9 @@ static int sdma_terminate_all(struct dma_chan *chan)
        struct sdma_channel *sdmac = to_sdma_chan(chan);
        unsigned long flags;
 
+       if (sdmac->sdma->drvdata->pm_runtime)
+               pm_runtime_get_sync(sdmac->sdma->dev);
+
        spin_lock_irqsave(&sdmac->vc.lock, flags);
 
        sdma_disable_channel(chan);
@@ -1271,8 +1283,10 @@ static int sdma_terminate_all(struct dma_chan *chan)
 
        spin_unlock_irqrestore(&sdmac->vc.lock, flags);
 
-       if (sdmac->sdma->drvdata->pm_runtime)
-               pm_runtime_allow(sdmac->sdma->dev);
+       if (sdmac->sdma->drvdata->pm_runtime) {
+               pm_runtime_mark_last_busy(sdmac->sdma->dev);
+               pm_runtime_put_autosuspend(sdmac->sdma->dev);
+       }
 
        return 0;
 }
@@ -2074,12 +2088,17 @@ static void sdma_issue_pending(struct dma_chan *chan)
        unsigned long flags;
 
        if (sdmac->sdma->drvdata->pm_runtime)
-               pm_runtime_forbid(sdmac->sdma->dev);
+               pm_runtime_get_sync(sdmac->sdma->dev);
 
        spin_lock_irqsave(&sdmac->vc.lock, flags);
        if (vchan_issue_pending(&sdmac->vc) && !sdmac->desc)
                sdma_start_desc(sdmac);
        spin_unlock_irqrestore(&sdmac->vc.lock, flags);
+
+       if (sdmac->sdma->drvdata->pm_runtime) {
+               pm_runtime_mark_last_busy(sdmac->sdma->dev);
+               pm_runtime_put_autosuspend(sdmac->sdma->dev);
+       }
 }
 
 #define SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1        34