[PATCH v2] ASoC: mediatek: mt6797: Fix runtime PM handling in probe
From: Zhu Jun
Date: Mon Nov 23 2026 - 02:43:41 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. On a
component registration failure, drop the probe's reference without
idling, disable runtime PM and directly suspend the AFE if it is still
active. This ensures the clocks are disabled even if userspace forces
power/control to on or a resume races with probe cleanup.
Keep failures before a successful resume on a disable-only path so
cleanup does not disable clocks that were never enabled. 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 | 21 +++++++++++++++++----
1 file changed, 17 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..cbe7c3a2eedb 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,19 @@ 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_noidle(dev);
+ pm_runtime_disable(dev);
+ if (!pm_runtime_status_suspended(dev))
+ mt6797_afe_runtime_suspend(dev);
+
+ return ret;
+
err_pm_disable:
pm_runtime_disable(dev);
--
2.51.0