* [PATCH V2] ASoC: fsl_audmix: rework runtime PM handling in probe
@ 2026-06-18 2:38 shengjiu.wang
2026-06-30 11:26 ` Mark Brown
2026-06-30 12:34 ` Shengjiu Wang
0 siblings, 2 replies; 3+ messages in thread
From: shengjiu.wang @ 2026-06-18 2:38 UTC (permalink / raw)
To: shengjiu.wang, Xiubo.Lee, festevam, nicoleotsuka, lgirdwood,
broonie, perex, tiwai, linux-sound, linuxppc-dev, linux-kernel
From: Shengjiu Wang <shengjiu.wang@nxp.com>
After pm_runtime_enable() the AUDMIX block is powered off and stays
suspended until the first runtime resume. Register writes issued between
probe() and the first resume (e.g. from DAPM or ALSA control paths)
target unpowered hardware and cause a system hang.
Fix this by calling pm_runtime_resume_and_get() immediately after
pm_runtime_enable() to power the hardware up and enable its clocks.
Release the reference afterwards with pm_runtime_put() to allow the
runtime PM framework to suspend the device and switch the regmap to
cache-only mode when idle.
When CONFIG_PM is disabled or runtime PM is not enabled, pm_runtime_*
calls are stubs that do not power up the hardware. Handle this case
explicitly by calling fsl_audmix_runtime_resume() directly so the
hardware is always initialised and its clocks are enabled, ensuring
register accesses succeed regardless of PM configuration.
Fixes: be1df61cf06ef ("ASoC: fsl: Add Audio Mixer CPU DAI driver")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
Changes in v2:
- remove the call of regcache_cache_only in probe, rework the runtime
handling in probe, call the pm_runtime_put() to enable the cache only.
- refine the commit message
sound/soc/fsl/fsl_audmix.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/sound/soc/fsl/fsl_audmix.c b/sound/soc/fsl/fsl_audmix.c
index f819f33ec46b..2885cc10b02d 100644
--- a/sound/soc/fsl/fsl_audmix.c
+++ b/sound/soc/fsl/fsl_audmix.c
@@ -457,6 +457,9 @@ static const struct of_device_id fsl_audmix_ids[] = {
};
MODULE_DEVICE_TABLE(of, fsl_audmix_ids);
+static int fsl_audmix_runtime_resume(struct device *dev);
+static int fsl_audmix_runtime_suspend(struct device *dev);
+
static int fsl_audmix_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -488,13 +491,25 @@ static int fsl_audmix_probe(struct platform_device *pdev)
spin_lock_init(&priv->lock);
platform_set_drvdata(pdev, priv);
pm_runtime_enable(dev);
+ if (!pm_runtime_enabled(dev)) {
+ ret = fsl_audmix_runtime_resume(dev);
+ if (ret)
+ goto err_disable_pm;
+ }
+
+ ret = pm_runtime_resume_and_get(dev);
+ if (ret < 0)
+ goto err_pm_get_sync;
+
+ /* To enable regmap cache only when runtime PM enabled */
+ pm_runtime_put(dev);
ret = devm_snd_soc_register_component(dev, &fsl_audmix_component,
fsl_audmix_dai,
ARRAY_SIZE(fsl_audmix_dai));
if (ret) {
dev_err(dev, "failed to register ASoC DAI\n");
- goto err_disable_pm;
+ goto err_pm_get_sync;
}
/*
@@ -506,12 +521,15 @@ static int fsl_audmix_probe(struct platform_device *pdev)
if (IS_ERR(priv->pdev)) {
ret = PTR_ERR(priv->pdev);
dev_err(dev, "failed to register platform: %d\n", ret);
- goto err_disable_pm;
+ goto err_pm_get_sync;
}
}
return 0;
+err_pm_get_sync:
+ if (!pm_runtime_status_suspended(dev))
+ fsl_audmix_runtime_suspend(dev);
err_disable_pm:
pm_runtime_disable(dev);
return ret;
@@ -522,6 +540,8 @@ static void fsl_audmix_remove(struct platform_device *pdev)
struct fsl_audmix *priv = dev_get_drvdata(&pdev->dev);
pm_runtime_disable(&pdev->dev);
+ if (!pm_runtime_status_suspended(&pdev->dev))
+ fsl_audmix_runtime_suspend(&pdev->dev);
if (priv->pdev)
platform_device_unregister(priv->pdev);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH V2] ASoC: fsl_audmix: rework runtime PM handling in probe
2026-06-18 2:38 [PATCH V2] ASoC: fsl_audmix: rework runtime PM handling in probe shengjiu.wang
@ 2026-06-30 11:26 ` Mark Brown
2026-06-30 12:34 ` Shengjiu Wang
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-06-30 11:26 UTC (permalink / raw)
To: shengjiu.wang, Xiubo.Lee, festevam, nicoleotsuka, lgirdwood,
perex, tiwai, linux-sound, linuxppc-dev, linux-kernel,
shengjiu.wang
On Thu, 18 Jun 2026 10:38:18 +0800, shengjiu.wang@oss.nxp.com wrote:
> ASoC: fsl_audmix: rework runtime PM handling in probe
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3
Thanks!
[1/1] ASoC: fsl_audmix: rework runtime PM handling in probe
https://git.kernel.org/broonie/sound/c/3359ba93d01a
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH V2] ASoC: fsl_audmix: rework runtime PM handling in probe
2026-06-18 2:38 [PATCH V2] ASoC: fsl_audmix: rework runtime PM handling in probe shengjiu.wang
2026-06-30 11:26 ` Mark Brown
@ 2026-06-30 12:34 ` Shengjiu Wang
1 sibling, 0 replies; 3+ messages in thread
From: Shengjiu Wang @ 2026-06-30 12:34 UTC (permalink / raw)
To: shengjiu.wang
Cc: Xiubo.Lee, festevam, nicoleotsuka, lgirdwood, broonie, perex,
tiwai, linux-sound, linuxppc-dev, linux-kernel
On Thu, Jun 18, 2026 at 10:33 AM <shengjiu.wang@oss.nxp.com> wrote:
>
> From: Shengjiu Wang <shengjiu.wang@nxp.com>
>
> After pm_runtime_enable() the AUDMIX block is powered off and stays
> suspended until the first runtime resume. Register writes issued between
> probe() and the first resume (e.g. from DAPM or ALSA control paths)
> target unpowered hardware and cause a system hang.
>
> Fix this by calling pm_runtime_resume_and_get() immediately after
> pm_runtime_enable() to power the hardware up and enable its clocks.
> Release the reference afterwards with pm_runtime_put() to allow the
> runtime PM framework to suspend the device and switch the regmap to
> cache-only mode when idle.
>
> When CONFIG_PM is disabled or runtime PM is not enabled, pm_runtime_*
> calls are stubs that do not power up the hardware. Handle this case
> explicitly by calling fsl_audmix_runtime_resume() directly so the
> hardware is always initialised and its clocks are enabled, ensuring
> register accesses succeed regardless of PM configuration.
>
> Fixes: be1df61cf06ef ("ASoC: fsl: Add Audio Mixer CPU DAI driver")
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> ---
> Changes in v2:
> - remove the call of regcache_cache_only in probe, rework the runtime
> handling in probe, call the pm_runtime_put() to enable the cache only.
> - refine the commit message
>
> sound/soc/fsl/fsl_audmix.c | 24 ++++++++++++++++++++++--
> 1 file changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/fsl/fsl_audmix.c b/sound/soc/fsl/fsl_audmix.c
> index f819f33ec46b..2885cc10b02d 100644
> --- a/sound/soc/fsl/fsl_audmix.c
> +++ b/sound/soc/fsl/fsl_audmix.c
> @@ -457,6 +457,9 @@ static const struct of_device_id fsl_audmix_ids[] = {
> };
> MODULE_DEVICE_TABLE(of, fsl_audmix_ids);
>
> +static int fsl_audmix_runtime_resume(struct device *dev);
> +static int fsl_audmix_runtime_suspend(struct device *dev);
> +
> static int fsl_audmix_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -488,13 +491,25 @@ static int fsl_audmix_probe(struct platform_device *pdev)
> spin_lock_init(&priv->lock);
> platform_set_drvdata(pdev, priv);
> pm_runtime_enable(dev);
> + if (!pm_runtime_enabled(dev)) {
> + ret = fsl_audmix_runtime_resume(dev);
> + if (ret)
> + goto err_disable_pm;
> + }
> +
> + ret = pm_runtime_resume_and_get(dev);
> + if (ret < 0)
> + goto err_pm_get_sync;
> +
> + /* To enable regmap cache only when runtime PM enabled */
> + pm_runtime_put(dev);
Check the comments from Sashiko. Needs to use pm_runtime_put_sync to
avoid the race
of asynchronous.
Will send the next version.
Best regards
Shengjiu Wang
>
> ret = devm_snd_soc_register_component(dev, &fsl_audmix_component,
> fsl_audmix_dai,
> ARRAY_SIZE(fsl_audmix_dai));
> if (ret) {
> dev_err(dev, "failed to register ASoC DAI\n");
> - goto err_disable_pm;
> + goto err_pm_get_sync;
> }
>
> /*
> @@ -506,12 +521,15 @@ static int fsl_audmix_probe(struct platform_device *pdev)
> if (IS_ERR(priv->pdev)) {
> ret = PTR_ERR(priv->pdev);
> dev_err(dev, "failed to register platform: %d\n", ret);
> - goto err_disable_pm;
> + goto err_pm_get_sync;
> }
> }
>
> return 0;
>
> +err_pm_get_sync:
> + if (!pm_runtime_status_suspended(dev))
> + fsl_audmix_runtime_suspend(dev);
> err_disable_pm:
> pm_runtime_disable(dev);
> return ret;
> @@ -522,6 +540,8 @@ static void fsl_audmix_remove(struct platform_device *pdev)
> struct fsl_audmix *priv = dev_get_drvdata(&pdev->dev);
>
> pm_runtime_disable(&pdev->dev);
> + if (!pm_runtime_status_suspended(&pdev->dev))
> + fsl_audmix_runtime_suspend(&pdev->dev);
>
> if (priv->pdev)
> platform_device_unregister(priv->pdev);
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-30 15:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-18 2:38 [PATCH V2] ASoC: fsl_audmix: rework runtime PM handling in probe shengjiu.wang
2026-06-30 11:26 ` Mark Brown
2026-06-30 12:34 ` Shengjiu Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox