* [PATCH] ASoC: codecs: lpass-macro: release macro and dcodec clocks in runtime suspend
@ 2026-10-23 17:32 Ramón Jesús Miranda
2026-10-24 22:58 ` Val Packett
0 siblings, 1 reply; 3+ messages in thread
From: Ramón Jesús Miranda @ 2026-10-23 17:32 UTC (permalink / raw)
To: Srinivas Kandagatla, Liam Girdwood, Mark Brown
Cc: Jaroslav Kysela, Takashi Iwai, linux-sound, linux-arm-msm,
linux-kernel, Ramón Jesús Miranda
The LPASS rx, tx, wsa, and va macro codec drivers prepare and enable their
"macro" and "dcodec" clocks (which correspond to q6prm LPASS_HW_MACRO and
LPASS_HW_DCODEC clock votes to the ADSP) in probe() and only release them
in remove(). Their runtime PM callbacks only toggle mclk, npl, and fsgen.
On Qualcomm X1E80100 systems where the ADSP is booted by Linux (such as
running at EL2 on the Microsoft Surface Pro 11), keeping the LPASS_HW_MACRO
and LPASS_HW_DCODEC votes active while audio is idle prevents the ADSP from
entering low-power sleep during s2idle, which in turn blocks the SoC from
reaching CX collapse (CXSD) and AOSS sleep (AOSD) (both counters remain at
0). Also, calling clk_disable_unprepare() unconditionally in remove() on
clocks already disabled by runtime_suspend() causes clock enable count
underflows if the driver is unloaded while runtime-suspended.
Disable "dcodec" and "macro" in runtime_suspend(), re-enable them in
runtime_resume(), and guard the clock teardown in remove() with
!pm_runtime_status_suspended(). With this change, ADSP, CXSD, and AOSD
reach >99.9% residency during s2idle (~0.20 W system sleep power on a
Microsoft Surface Pro 11 OLED).
Assisted-by: Claude:claude-opus-5-5
Assisted-by: Antigravity:gemini-2.5-pro
Signed-off-by: Ramón Jesús Miranda <ramonjesusmiranda@gmail.com>
---
sound/soc/codecs/lpass-rx-macro.c | 28 +++++++++++++++++++-----
sound/soc/codecs/lpass-tx-macro.c | 28 +++++++++++++++++++-----
sound/soc/codecs/lpass-va-macro.c | 35 +++++++++++++++++++++++-------
sound/soc/codecs/lpass-wsa-macro.c | 28 +++++++++++++++++++-----
4 files changed, 93 insertions(+), 26 deletions(-)
diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index 6233aa9..9afebf6 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -3935,11 +3935,13 @@ static void rx_macro_remove(struct platform_device *pdev)
{
struct rx_macro *rx = dev_get_drvdata(&pdev->dev);
- clk_disable_unprepare(rx->mclk);
- clk_disable_unprepare(rx->npl);
- clk_disable_unprepare(rx->fsgen);
- clk_disable_unprepare(rx->macro);
- clk_disable_unprepare(rx->dcodec);
+ if (!pm_runtime_status_suspended(&pdev->dev)) {
+ clk_disable_unprepare(rx->mclk);
+ clk_disable_unprepare(rx->npl);
+ clk_disable_unprepare(rx->fsgen);
+ clk_disable_unprepare(rx->macro);
+ clk_disable_unprepare(rx->dcodec);
+ }
}
static const struct of_device_id rx_macro_dt_match[] = {
@@ -3976,6 +3978,8 @@ static int rx_macro_runtime_suspend(struct device *dev)
clk_disable_unprepare(rx->fsgen);
clk_disable_unprepare(rx->npl);
clk_disable_unprepare(rx->mclk);
+ clk_disable_unprepare(rx->dcodec);
+ clk_disable_unprepare(rx->macro);
return 0;
}
@@ -3985,10 +3989,18 @@ static int rx_macro_runtime_resume(struct device *dev)
struct rx_macro *rx = dev_get_drvdata(dev);
int ret;
+ ret = clk_prepare_enable(rx->macro);
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(rx->dcodec);
+ if (ret)
+ goto err_dcodec;
+
ret = clk_prepare_enable(rx->mclk);
if (ret) {
dev_err(dev, "unable to prepare mclk\n");
- return ret;
+ goto err_mclk;
}
ret = clk_prepare_enable(rx->npl);
@@ -4010,6 +4022,10 @@ err_fsgen:
clk_disable_unprepare(rx->npl);
err_npl:
clk_disable_unprepare(rx->mclk);
+err_mclk:
+ clk_disable_unprepare(rx->dcodec);
+err_dcodec:
+ clk_disable_unprepare(rx->macro);
return ret;
}
diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c
index 0cbf506..fc4630c 100644
--- a/sound/soc/codecs/lpass-tx-macro.c
+++ b/sound/soc/codecs/lpass-tx-macro.c
@@ -2390,11 +2390,13 @@ static void tx_macro_remove(struct platform_device *pdev)
{
struct tx_macro *tx = dev_get_drvdata(&pdev->dev);
- clk_disable_unprepare(tx->macro);
- clk_disable_unprepare(tx->dcodec);
- clk_disable_unprepare(tx->mclk);
- clk_disable_unprepare(tx->npl);
- clk_disable_unprepare(tx->fsgen);
+ if (!pm_runtime_status_suspended(&pdev->dev)) {
+ clk_disable_unprepare(tx->macro);
+ clk_disable_unprepare(tx->dcodec);
+ clk_disable_unprepare(tx->mclk);
+ clk_disable_unprepare(tx->npl);
+ clk_disable_unprepare(tx->fsgen);
+ }
lpass_macro_pds_exit(tx->pds);
}
@@ -2409,6 +2411,8 @@ static int tx_macro_runtime_suspend(struct device *dev)
clk_disable_unprepare(tx->fsgen);
clk_disable_unprepare(tx->npl);
clk_disable_unprepare(tx->mclk);
+ clk_disable_unprepare(tx->dcodec);
+ clk_disable_unprepare(tx->macro);
return 0;
}
@@ -2418,10 +2422,18 @@ static int tx_macro_runtime_resume(struct device *dev)
struct tx_macro *tx = dev_get_drvdata(dev);
int ret;
+ ret = clk_prepare_enable(tx->macro);
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(tx->dcodec);
+ if (ret)
+ goto err_dcodec;
+
ret = clk_prepare_enable(tx->mclk);
if (ret) {
dev_err(dev, "unable to prepare mclk\n");
- return ret;
+ goto err_mclk;
}
ret = clk_prepare_enable(tx->npl);
@@ -2444,6 +2456,10 @@ err_fsgen:
clk_disable_unprepare(tx->npl);
err_npl:
clk_disable_unprepare(tx->mclk);
+err_mclk:
+ clk_disable_unprepare(tx->dcodec);
+err_dcodec:
+ clk_disable_unprepare(tx->macro);
return ret;
}
diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c
index 58a5798..16f0d44 100644
--- a/sound/soc/codecs/lpass-va-macro.c
+++ b/sound/soc/codecs/lpass-va-macro.c
@@ -1703,12 +1703,14 @@ static void va_macro_remove(struct platform_device *pdev)
{
struct va_macro *va = dev_get_drvdata(&pdev->dev);
- if (va->has_npl_clk)
- clk_disable_unprepare(va->npl);
+ if (!pm_runtime_status_suspended(&pdev->dev)) {
+ if (va->has_npl_clk)
+ clk_disable_unprepare(va->npl);
- clk_disable_unprepare(va->mclk);
- clk_disable_unprepare(va->dcodec);
- clk_disable_unprepare(va->macro);
+ clk_disable_unprepare(va->mclk);
+ clk_disable_unprepare(va->dcodec);
+ clk_disable_unprepare(va->macro);
+ }
lpass_macro_pds_exit(va->pds);
}
@@ -1725,6 +1727,8 @@ static int va_macro_runtime_suspend(struct device *dev)
clk_disable_unprepare(va->mclk);
+ clk_disable_unprepare(va->dcodec);
+ clk_disable_unprepare(va->macro);
return 0;
}
@@ -1733,18 +1737,25 @@ static int va_macro_runtime_resume(struct device *dev)
struct va_macro *va = dev_get_drvdata(dev);
int ret;
+ ret = clk_prepare_enable(va->macro);
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(va->dcodec);
+ if (ret)
+ goto err_dcodec;
+
ret = clk_prepare_enable(va->mclk);
if (ret) {
dev_err(va->dev, "unable to prepare mclk\n");
- return ret;
+ goto err_mclk;
}
if (va->has_npl_clk) {
ret = clk_prepare_enable(va->npl);
if (ret) {
- clk_disable_unprepare(va->mclk);
dev_err(va->dev, "unable to prepare npl\n");
- return ret;
+ goto err_npl;
}
}
@@ -1752,6 +1763,14 @@ static int va_macro_runtime_resume(struct device *dev)
regcache_sync(va->regmap);
return 0;
+err_npl:
+ clk_disable_unprepare(va->mclk);
+err_mclk:
+ clk_disable_unprepare(va->dcodec);
+err_dcodec:
+ clk_disable_unprepare(va->macro);
+
+ return ret;
}
diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c
index af521e0..7579eab 100644
--- a/sound/soc/codecs/lpass-wsa-macro.c
+++ b/sound/soc/codecs/lpass-wsa-macro.c
@@ -2842,11 +2842,13 @@ static void wsa_macro_remove(struct platform_device *pdev)
{
struct wsa_macro *wsa = dev_get_drvdata(&pdev->dev);
- clk_disable_unprepare(wsa->macro);
- clk_disable_unprepare(wsa->dcodec);
- clk_disable_unprepare(wsa->mclk);
- clk_disable_unprepare(wsa->npl);
- clk_disable_unprepare(wsa->fsgen);
+ if (!pm_runtime_status_suspended(&pdev->dev)) {
+ clk_disable_unprepare(wsa->macro);
+ clk_disable_unprepare(wsa->dcodec);
+ clk_disable_unprepare(wsa->mclk);
+ clk_disable_unprepare(wsa->npl);
+ clk_disable_unprepare(wsa->fsgen);
+ }
}
static int wsa_macro_runtime_suspend(struct device *dev)
@@ -2860,6 +2862,8 @@ static int wsa_macro_runtime_suspend(struct device *dev)
clk_disable_unprepare(wsa->npl);
clk_disable_unprepare(wsa->mclk);
+ clk_disable_unprepare(wsa->dcodec);
+ clk_disable_unprepare(wsa->macro);
return 0;
}
@@ -2868,10 +2872,18 @@ static int wsa_macro_runtime_resume(struct device *dev)
struct wsa_macro *wsa = dev_get_drvdata(dev);
int ret;
+ ret = clk_prepare_enable(wsa->macro);
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(wsa->dcodec);
+ if (ret)
+ goto err_dcodec;
+
ret = clk_prepare_enable(wsa->mclk);
if (ret) {
dev_err(dev, "unable to prepare mclk\n");
- return ret;
+ goto err_mclk;
}
ret = clk_prepare_enable(wsa->npl);
@@ -2894,6 +2906,10 @@ err_fsgen:
clk_disable_unprepare(wsa->npl);
err_npl:
clk_disable_unprepare(wsa->mclk);
+err_mclk:
+ clk_disable_unprepare(wsa->dcodec);
+err_dcodec:
+ clk_disable_unprepare(wsa->macro);
return ret;
}
--
2.56.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ASoC: codecs: lpass-macro: release macro and dcodec clocks in runtime suspend
2026-10-23 17:32 [PATCH] ASoC: codecs: lpass-macro: release macro and dcodec clocks in runtime suspend Ramón Jesús Miranda
@ 2026-10-24 22:58 ` Val Packett
2026-10-25 12:53 ` Ramón Jesús Miranda
0 siblings, 1 reply; 3+ messages in thread
From: Val Packett @ 2026-10-24 22:58 UTC (permalink / raw)
To: Ramón Jesús Miranda, Srinivas Kandagatla,
Liam Girdwood, Mark Brown
Cc: Jaroslav Kysela, Takashi Iwai, linux-sound, linux-arm-msm, linux-kernel
On 10/23/26 2:32 PM, Ramón Jesús Miranda wrote:
> The LPASS rx, tx, wsa, and va macro codec drivers prepare and enable their
> "macro" and "dcodec" clocks (which correspond to q6prm LPASS_HW_MACRO and
> LPASS_HW_DCODEC clock votes to the ADSP) in probe() and only release them
> in remove(). Their runtime PM callbacks only toggle mclk, npl, and fsgen.
>
> On Qualcomm X1E80100 systems where the ADSP is booted by Linux (such as
> running at EL2 on the Microsoft Surface Pro 11), keeping the LPASS_HW_MACRO
> and LPASS_HW_DCODEC votes active while audio is idle prevents the ADSP from
> entering low-power sleep during s2idle, which in turn blocks the SoC from
> reaching CX collapse (CXSD) and AOSS sleep (AOSD) (both counters remain at
> 0). Also, calling clk_disable_unprepare() unconditionally in remove() on
> clocks already disabled by runtime_suspend() causes clock enable count
> underflows if the driver is unloaded while runtime-suspended.
>
> Disable "dcodec" and "macro" in runtime_suspend(), re-enable them in
> runtime_resume(), and guard the clock teardown in remove() with
> !pm_runtime_status_suspended(). With this change, ADSP, CXSD, and AOSD
> reach >99.9% residency during s2idle (~0.20 W system sleep power on a
> Microsoft Surface Pro 11 OLED).
>
> Assisted-by: Claude:claude-opus-5-5
> Assisted-by: Antigravity:gemini-2.5-pro
Advertisements for particular slop-generators are discouraged since
816d9992d9ed ("coding-assistants: simplify attribution") btw, and the
tag is no longer required since 1e035297ffda ("docs: remove Assisted-by
references").
> [..]
> --- a/sound/soc/codecs/lpass-tx-macro.c
> +++ b/sound/soc/codecs/lpass-tx-macro.c
> @@ -2390,11 +2390,13 @@ static void tx_macro_remove(struct platform_device *pdev)
> {
> struct tx_macro *tx = dev_get_drvdata(&pdev->dev);
>
> - clk_disable_unprepare(tx->macro);
> - clk_disable_unprepare(tx->dcodec);
> - clk_disable_unprepare(tx->mclk);
> - clk_disable_unprepare(tx->npl);
> - clk_disable_unprepare(tx->fsgen);
> + if (!pm_runtime_status_suspended(&pdev->dev)) {
> + clk_disable_unprepare(tx->macro);
> + clk_disable_unprepare(tx->dcodec);
> + clk_disable_unprepare(tx->mclk);
> + clk_disable_unprepare(tx->npl);
> + clk_disable_unprepare(tx->fsgen);
> + }
>
> lpass_macro_pds_exit(tx->pds);
> }
> [..]
You're working with a tree that's months out of date! This does not
apply to linux-next at all.
Commit a5ee3180a2a7 ("ASoC: codecs: lpass-{tx,rx}-macro: switch to PM
clock framework") back in July removed all of these calls, and the
clocks are now automatically managed by the framework, which has solved
the issue.
Several people in #aarch64-laptops have gotten CXSD state working
recently, and no one touched sound/soc/codecs.
~val
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ASoC: codecs: lpass-macro: release macro and dcodec clocks in runtime suspend
2026-10-24 22:58 ` Val Packett
@ 2026-10-25 12:53 ` Ramón Jesús Miranda
0 siblings, 0 replies; 3+ messages in thread
From: Ramón Jesús Miranda @ 2026-10-25 12:53 UTC (permalink / raw)
To: Val Packett, Srinivas Kandagatla, Liam Girdwood, Mark Brown
Cc: Jaroslav Kysela, Takashi Iwai, linux-sound, linux-arm-msm, linux-kernel
On 10/24/26 Val Packett wrote:
> You're working with a tree that's months out of date! This does not
> apply to linux-next at all.
>
> Commit a5ee3180a2a7 ("ASoC: codecs: lpass-{tx,rx}-macro: switch to PM
> clock framework")
Thanks, you are right: I was on a 7.2-based downstream tree. With the
PM clock framework in all four macros this patch is not needed, so
please consider it withdrawn. I will check against linux-next before
sending anything else, and I will drop the attribution tags.
Ramón
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-25 12:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-23 17:32 [PATCH] ASoC: codecs: lpass-macro: release macro and dcodec clocks in runtime suspend Ramón Jesús Miranda
2026-10-24 22:58 ` Val Packett
2026-10-25 12:53 ` Ramón Jesús Miranda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®