From: Robin Gong Date: Thu, 29 Apr 2021 19:39:37 +0000 (+0800) Subject: MLK-25473-1 dmaengine: imx-sdma: Revert "MLK-25465-6 dmaengine: imx-sdma: fix the... X-Git-Tag: rel_imx_5.10.35_2.0.0-somdevices.0~127 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=e1e42b10bb84a960bd2640d8435f8611995aba90;p=linux.git MLK-25473-1 dmaengine: imx-sdma: Revert "MLK-25465-6 dmaengine: imx-sdma: fix the long dma transfer timing grater than 2s" 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 Reviewed-by: Shengjiu Wang --- diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 394a7136c42b..78594f20d3bf 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -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