From d73af669d125b844123f5ceb1d8a1467ca5aba48 Mon Sep 17 00:00:00 2001 From: Joy Zou Date: Tue, 25 Jan 2022 20:11:37 +0800 Subject: [PATCH] LF-5353: dmaengine: imx-sdma: optimize confused runtime related code In order to call sdma_runtime_resume, the driver call pm_runtime_get_sync and pm_runtime_enable when the pm_runtime is false, it may be confused. The handler of true and false pm_runtime are mixed in sdma_remove function. This patch calls directly sdma_runtime_resume and remove pm_runtime_enable when the pm_runtime is false, and separate the handler of true and false pm_runtime. Signed-off-by: Joy Zou Reviewed-by: Dong Aisheng Acked-by: Jason Liu --- drivers/dma/imx-sdma.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 41753a4cb50e..dba5f9dde204 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -2246,7 +2246,7 @@ static void sdma_load_firmware(const struct firmware *fw, void *context) memcpy(sdma->fw_data, fw->data, fw->size); if (!sdma->drvdata->pm_runtime) - pm_runtime_get_sync(sdma->dev); + sdma_runtime_resume(sdma->dev); } err_firmware: @@ -2599,10 +2599,9 @@ static int sdma_probe(struct platform_device *pdev) pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_mark_last_busy(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); + pm_runtime_enable(&pdev->dev); } - pm_runtime_enable(&pdev->dev); - return 0; err_register: @@ -2635,9 +2634,12 @@ static int sdma_remove(struct platform_device *pdev) sdma_free_chan_resources(&sdmac->vc.chan); } - pm_runtime_disable(&pdev->dev); - pm_runtime_set_suspended(&pdev->dev); - pm_runtime_dont_use_autosuspend(&pdev->dev); + if (sdma->drvdata->pm_runtime) { + pm_runtime_disable(&pdev->dev); + pm_runtime_dont_use_autosuspend(&pdev->dev); + } else { + sdma_runtime_suspend(&pdev->dev); + } platform_set_drvdata(pdev, NULL); return 0; -- 2.17.1