LF-5353: dmaengine: imx-sdma: optimize confused runtime related code
authorJoy Zou <joy.zou@nxp.com>
Tue, 25 Jan 2022 12:11:37 +0000 (20:11 +0800)
committerJosep Orga <jorga@somdevices.com>
Tue, 27 Jun 2023 14:03:26 +0000 (16:03 +0200)
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 <joy.zou@nxp.com>
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
drivers/dma/imx-sdma.c

index 41753a4..dba5f9d 100644 (file)
@@ -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;