[PATCH] ASoC: mediatek: mt6797: Fix runtime PM handling in probe

From: Zhu Jun

Date: Thu Nov 19 2026 - 02:59:29 EST


The MT6797 AFE probe registers its components even when the runtime
resume fails to enable the clocks. If component registration fails
after a successful resume, the probe disables runtime PM while still
holding its usage reference. The runtime PM disabled path also
returns the previous successful result without registering components.

Use pm_runtime_resume_and_get() and stop on a resume error. Drop the
reference and suspend the AFE on either registration failure before
disabling runtime PM. Return an error when runtime PM is unavailable.

Fixes: 3901b9fc0f0d ("ASoC: mt6797: add mt6797 platform driver")
Signed-off-by: Zhu Jun <zhujun2@xxxxxxxxxxxxxxxxxxxx>
---
sound/soc/mediatek/mt6797/mt6797-afe-pcm.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c b/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c
index 2069c340ca39..406a86035785 100644
--- a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c
+++ b/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c
@@ -828,16 +828,21 @@ static int mt6797_afe_pcm_dev_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, afe);

pm_runtime_enable(dev);
- if (!pm_runtime_enabled(dev))
+ if (!pm_runtime_enabled(dev)) {
+ ret = -EOPNOTSUPP;
+ goto err_pm_disable;
+ }
+
+ ret = pm_runtime_resume_and_get(dev);
+ if (ret)
goto err_pm_disable;
- pm_runtime_get_sync(&pdev->dev);

/* register component */
ret = devm_snd_soc_register_component(dev, &mtk_afe_pcm_platform,
NULL, 0);
if (ret) {
dev_warn(dev, "err_platform\n");
- goto err_pm_disable;
+ goto err_pm_put;
}

ret = devm_snd_soc_register_component(afe->dev,
@@ -846,11 +851,13 @@ static int mt6797_afe_pcm_dev_probe(struct platform_device *pdev)
afe->num_dai_drivers);
if (ret) {
dev_warn(dev, "err_dai_component\n");
- goto err_pm_disable;
+ goto err_pm_put;
}

return 0;

+err_pm_put:
+ pm_runtime_put_sync_suspend(dev);
err_pm_disable:
pm_runtime_disable(dev);