ASoC: qcom: lpass: Switch VA/WSA macros to PM clock framework
Subsystems (4)
v5 cover ASoC: qcom: lpass: Switch VA/WSA macros to PM clock framework
This series converts LPASS WSA and VA macro codec drivers to the PM clock framework for runtime PM clock handling.
Clock enable/disable sequencing during runtime suspend/resume is moved to pm_clk helpers, while regcache state handling remains in the driver runtime PM callbacks. This aligns these codec drivers with common LPASS runtime PM patterns and reduces idle clock voting.
Patch 3 switches WSA MCLK clock registration to devm-managed clk_hw registration.
---
v4: https://lore.kernel.org/r/[email protected]
Changes since v4:
- Added depends on PM to SND_SOC_LPASS_WSA_MACRO and SND_SOC_LPASS_VA_MACRO so PM clock helpers are available when these drivers are built
- Moved sret declaration in WSA/VA runtime_resume() from nested error-path blocks to top-level int ret, sret; declarations for kernel coding style compliance (no functional change)
- In WSA/VA probe error-unwind (err_rpm_put), check pm_runtime_put_sync_suspend() return values and emit dev_warn() on failure so runtime-PM unwind failures are visible
v3: https://lore.kernel.org/r/[email protected]
Changes since v3:
- In WSA/VA runtime_resume() regcache_sync() failure unwind, capture pm_clk_suspend() failures and emit dev_err() to make clock/cache rollback failures observable
- In WSA/VA runtime_resume(), mark regcache dirty when pm_clk_resume() fails so a later resume attempt forces a full regcache_sync() even if no prior runtime_suspend() has run
- Added depends on PM to SND_SOC_LPASS_WSA_MACRO and SND_SOC_LPASS_VA_MACRO because these drivers now require PM clock helpers and must not build with !PM_CLK stubs
- Converted runtime-PM enablement to devm_pm_runtime_enable() in both PM-clock conversion patches; probe error unwind now uses pm_runtime_put_sync_suspend(), with runtime-PM disable handled by devm
- In WSA/VA runtime_suspend callbacks, moved regcache_mark_dirty() after successful pm_clk_suspend() and restored regcache_cache_only(false) on pm_clk_suspend() failures to avoid leaving dirty/cache-only state set when clocks are not suspended
- In va fsgen_gate_enable() error unwind, replaced pm_runtime_put_noidle() with pm_runtime_put_autosuspend() and added dev_warn() logging for put failures so failed-enable paths can autosuspend and drop PM-clock votes
Ajay Kumar Nandam (3):
ASoC: codecs: lpass-wsa-macro: Switch to PM clock framework for
runtime PM
ASoC: codecs: lpass-va-macro: Switch to PM clock framework for runtime
PM
ASoC: codecs: lpass-wsa-macro: Use devm_clk_hw_register() for MCLK
output
sound/soc/codecs/Kconfig | 2 ++ sound/soc/codecs/lpass-va-macro.c | 133 +++++++++++++++++---------------- sound/soc/codecs/lpass-wsa-macro.c | 121 +++++++++++----------------- 3 files changed, 119 insertions(+), 137 deletions(-)
Signature · 1 line
2.34.1
PATCH v5 1/3 ASoC: codecs: lpass-wsa-macro: Switch to PM clock framework for runtime PM
Convert the LPASS WSA macro codec driver to use the PM clock framework for runtime power management.
The driver now relies on pm_clk helpers and runtime PM instead of manually enabling and disabling macro, dcodec, mclk, npl, and fsgen clocks. Runtime suspend and resume handling is delegated to the PM core via pm_clk_suspend() and pm_clk_resume(), while existing runtime PM callbacks continue to manage regcache state.
This ensures clocks are enabled only when the WSA macro is active, improves power efficiency on LPASS platforms supporting LPI/island modes, and aligns the driver with common ASoC runtime PM patterns used across Qualcomm LPASS codec drivers.
Keep the SWR gate runtime-PM reference from SWR clock enable until disable so autosuspend does not gate clocks while SWR is prepared.
Add a PM dependency for SND_SOC_LPASS_WSA_MACRO so PM clock helpers are available when this driver is built.
--- sound/soc/codecs/Kconfig | 1 + sound/soc/codecs/lpass-wsa-macro.c | 119 ++++++++++++------------------ 2 files changed, 47 insertions(+), 73 deletions(-)
sound/soc/codecs/Kconfig +1 -0
@@ -2861,7 +2861,8 @@ config SND_SOC_LPASS_MACRO_COMMON config SND_SOC_LPASS_WSA_MACRO depends on COMMON_CLK + depends on PM select REGMAP_MMIO select SND_SOC_LPASS_MACRO_COMMON tristate "Qualcomm WSA Macro in LPASS(Low Power Audio SubSystem)"
sound/soc/codecs/lpass-wsa-macro.c +52 -74
195 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v5 2/3 ASoC: codecs: lpass-va-macro: Switch to PM clock framework for runtime PM
In reply to Ajay Kumar NandamConvert the LPASS VA macro codec driver to use the PM clock framework for runtime power management.
The driver now relies on pm_clk helpers and runtime PM instead of manually enabling and disabling macro, dcodec, mclk, and npl clocks. All clock control during runtime suspend and resume is delegated to the PM core via pm_clk_suspend() and pm_clk_resume().
This change ensures clocks are only enabled when the VA macro is active, improves power efficiency on LPASS platforms supporting LPI/island modes, and aligns the driver with common ASoC runtime PM patterns used across Qualcomm LPASS codec drivers.
Take a runtime-PM reference in fsgen_gate_enable() for all VA variants, including non-SWR-master configurations, and release it in fsgen_gate_disable() so PM-clock-managed clocks stay active while fsgen is enabled.
Add a PM dependency for SND_SOC_LPASS_VA_MACRO so PM clock helpers are available when this driver is built.
--- sound/soc/codecs/Kconfig | 1 + sound/soc/codecs/lpass-va-macro.c | 133 +++++++++++++++++---------------- 2 files changed, 71 insertions(+), 63 deletions(-)
sound/soc/codecs/Kconfig +1 -0
@@ -2867,7 +2867,8 @@ config SND_SOC_LPASS_WSA_MACRO config SND_SOC_LPASS_VA_MACRO depends on COMMON_CLK + depends on PM select REGMAP_MMIO select SND_SOC_LPASS_MACRO_COMMON tristate "Qualcomm VA Macro in LPASS(Low Power Audio SubSystem)"
sound/soc/codecs/lpass-va-macro.c +80 -64
238 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v5 3/3 ASoC: codecs: lpass-wsa-macro: Use devm_clk_hw_register() for MCLK output
In reply to Ajay Kumar NandamThe WSA macro driver registers the MCLK output clock using clk_hw_register(), but does not explicitly unregister it in the remove path or on probe failure.
Switch to devm_clk_hw_register() to make the registration resource-managed so the clk_hw is automatically unregistered when the device is unbound or probe fails. This fixes the missing unregister cleanup in remove/probe-fail paths and simplifies error handling.
--- sound/soc/codecs/lpass-wsa-macro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/lpass-wsa-macro.c +1 -1
@@ -2658,7 +2658,7 @@ static int wsa_macro_register_mclk_output(struct wsa_macro *wsa) init.num_parents =1 ; wsa->hw.init = &init; hw = &wsa->hw; - ret =clk_hw_register (wsa->dev, hw); + ret =devm_clk_hw_register (wsa->dev, hw);if (ret)return ret;
Signature · 1 line
2.34.1
Mark Brown
maintainerRe: [PATCH v5 1/3] ASoC: codecs: lpass-wsa-macro: Switch to PM clock framework for runtime PM
In reply to Ajay Kumar Nandamsound/soc/codecs/Kconfig config SND_SOC_LPASS_MACRO_COMMON · line 2867
Quoted 12 lines · Ajay Kumar Nandam
The driver now relies on
pm_clkhelpers and runtime PM instead of manually enabling and disabling macro, dcodec, mclk, npl, and fsgen clocks. Runtime suspend and resume handling is delegated to the PM core viapm_clk_suspend()andpm_clk_resume(), while existing runtime PM callbacks continue to manage regcache state.config
SND_SOC_LPASS_WSA_MACROsound/soc/codecs/Kconfig +1
-0depends on COMMON_CLK + depends on PM select REGMAP_MMIO select SND_SOC_LPASS_MACRO_COMMON tristate "Qualcomm WSA Macro in LPASS(Low Power Audio SubSystem)"
Shouldn't this be PM_CLK? That's what the APIs are actually conditional on, currently this will work out since PM_CLK depends on PM and HAVE_CLK but the indirection leaves a window for things to break in future.
Mark Brown
maintainerQuoted 2 lines · Ajay Kumar Nandam
This series converts LPASS WSA and VA macro codec drivers to the PM clock framework for runtime PM clock handling.
This doesn't apply against current code, please check and resend.
Re: [PATCH v5 1/3] ASoC: codecs: lpass-wsa-macro: Switch to PM clock framework for runtime PM
In reply to Ajay Kumar NandamQuoted 14 lines · Ajay Kumar Nandam
Convert the LPASS WSA macro codec driver to use the PM clock framework for runtime power management.
The driver now relies on
pm_clkhelpers and runtime PM instead of manually enabling and disabling macro, dcodec, mclk, npl, and fsgen clocks. Runtime suspend and resume handling is delegated to the PM core viapm_clk_suspend()andpm_clk_resume(), while existing runtime PM callbacks continue to manage regcache state.This ensures clocks are enabled only when the WSA macro is active, improves power efficiency on LPASS platforms supporting LPI/island modes, and aligns the driver with common ASoC runtime PM patterns used across Qualcomm LPASS codec drivers.
Quoted 7 lines
Keep the SWR gate runtime-PM reference from SWR clock enable until disable so autosuspend does not gate clocks while SWR is prepared.
Add a PM dependency for
SND_SOC_LPASS_WSA_MACROso PM clock helpers are available when this driver is built.Suggested-by Mark Brown <[email protected]>
You added this tag, but was the entire content of this patch sparked by Mark's suggestion?
Konrad
Re: [PATCH v5 1/3] ASoC: codecs: lpass-wsa-macro: Switch to PM clock framework for runtime PM
In reply to Mark BrownQuoted 8 lines · Mark Brown
Quoted 5 lines · Ajay Kumar Nandam
The driver now relies on
pm_clkhelpers and runtime PM instead of manually enabling and disabling macro, dcodec, mclk, npl, and fsgen clocks. Runtime suspend and resume handling is delegated to the PM core viapm_clk_suspend()andpm_clk_resume(), while existing runtime PM callbacks continue to manage regcache state.
Quoted 10 lines
sound/soc/codecs/Kconfig config SND_SOC_LPASS_MACRO_COMMON · line 2867
Quoted 6 lines
config
SND_SOC_LPASS_WSA_MACROsound/soc/codecs/Kconfig +1
-0depends on COMMON_CLK + depends on PM select REGMAP_MMIO select SND_SOC_LPASS_MACRO_COMMON tristate "Qualcomm WSA Macro in LPASS(Low Power Audio SubSystem)"Shouldn't this be
PM_CLK? That's what the APIs are actually conditional on, currently this will work out sincePM_CLKdepends on PM andHAVE_CLKbut the indirection leaves a window for things to break in future.
Yeah, leaving it as-is sounds like a bad idea
Konrad
Re: [PATCH v5 1/3] ASoC: codecs: lpass-wsa-macro: Switch to PM clock framework for runtime PM
In reply to Mark BrownQuoted 8 lines · Mark Brown
Quoted 5 lines · Ajay Kumar Nandam
The driver now relies on
pm_clkhelpers and runtime PM instead of manually enabling and disabling macro, dcodec, mclk, npl, and fsgen clocks. Runtime suspend and resume handling is delegated to the PM core viapm_clk_suspend()andpm_clk_resume(), while existing runtime PM callbacks continue to manage regcache state.
Quoted 10 lines
sound/soc/codecs/Kconfig config SND_SOC_LPASS_MACRO_COMMON · line 2867
Quoted 6 lines
config
SND_SOC_LPASS_WSA_MACRO
depends onCOMMON_CLKsound/soc/codecs/Kconfig +1
-0+ depends on PM select REGMAP_MMIO select SND_SOC_LPASS_MACRO_COMMON tristate "Qualcomm WSA Macro in LPASS(Low Power Audio SubSystem)"Shouldn't this be
PM_CLK? That's what the APIs are actually conditional on, currently this will work out sincePM_CLKdepends on PM andHAVE_CLKbut the indirection leaves a window for things to break in future.
ACK, agreed with your statement will update in V6
Thanks
Ajay Kumar
Re: [PATCH v5 1/3] ASoC: codecs: lpass-wsa-macro: Switch to PM clock framework for runtime PM
In reply to Konrad DybcioQuoted 20 lines · Konrad Dybcio
Quoted 8 lines · Mark Brown
Quoted 5 lines · Ajay Kumar Nandam
The driver now relies on
pm_clkhelpers and runtime PM instead of manually enabling and disabling macro, dcodec, mclk, npl, and fsgen clocks. Runtime suspend and resume handling is delegated to the PM core viapm_clk_suspend()andpm_clk_resume(), while existing runtime PM callbacks continue to manage regcache state.Quoted 10 lines
sound/soc/codecs/Kconfig config SND_SOC_LPASS_MACRO_COMMON · line 2867
Quoted 6 lines
config
SND_SOC_LPASS_WSA_MACRO
depends onCOMMON_CLKsound/soc/codecs/Kconfig +1
-0+ depends on PM select REGMAP_MMIO select SND_SOC_LPASS_MACRO_COMMON tristate "Qualcomm WSA Macro in LPASS(Low Power Audio SubSystem)"Shouldn't this be
PM_CLK? That's what the APIs are actually conditional on, currently this will work out sincePM_CLKdepends on PM andHAVE_CLKbut the indirection leaves a window for things to break in future.
Quoted 1 line
Yeah, leaving it as-is sounds like a bad idea
ACK, will update in V6
Thanks
Ajay Kumar
Quoted 2 lines
Konrad
Re: [PATCH v5 1/3] ASoC: codecs: lpass-wsa-macro: Switch to PM clock framework for runtime PM
In reply to Konrad DybcioQuoted 18 lines · Konrad Dybcio
Quoted 17 lines · Ajay Kumar Nandam
Convert the LPASS WSA macro codec driver to use the PM clock framework for runtime power management.
The driver now relies on
pm_clkhelpers and runtime PM instead of manually enabling and disabling macro, dcodec, mclk, npl, and fsgen clocks. Runtime suspend and resume handling is delegated to the PM core viapm_clk_suspend()andpm_clk_resume(), while existing runtime PM callbacks continue to manage regcache state.This ensures clocks are enabled only when the WSA macro is active, improves power efficiency on LPASS platforms supporting LPI/island modes, and aligns the driver with common ASoC runtime PM patterns used across Qualcomm LPASS codec drivers.
Keep the SWR gate runtime-PM reference from SWR clock enable until disable so autosuspend does not gate clocks while SWR is prepared.
Quoted 7 lines
Quoted 4 lines
Add a PM dependency for
SND_SOC_LPASS_WSA_MACROso PM clock helpers are available when this driver is built.Suggested-by Mark Brown <[email protected]>You added this tag, but was the entire content of this patch sparked by Mark's suggestion?
Apologies for not including the Reviewed-by tag earlier — that was an oversight on my end.
Thanks
Ajay Kumar
Quoted 2 lines
Konrad
Re: [PATCH v5 1/3] ASoC: codecs: lpass-wsa-macro: Switch to PM clock framework for runtime PM
Quoted 24 lines · Ajay Kumar Nandam
Quoted 21 lines · Konrad Dybcio
Quoted 20 lines · Ajay Kumar Nandam
Convert the LPASS WSA macro codec driver to use the PM clock framework for runtime power management.
The driver now relies on
pm_clkhelpers and runtime PM instead of manually enabling and disabling macro, dcodec, mclk, npl, and fsgen clocks. Runtime suspend and resume handling is delegated to the PM core viapm_clk_suspend()andpm_clk_resume(), while existing runtime PM callbacks continue to manage regcache state.This ensures clocks are enabled only when the WSA macro is active, improves power efficiency on LPASS platforms supporting LPI/island modes, and aligns the driver with common ASoC runtime PM patterns used across Qualcomm LPASS codec drivers.
Keep the SWR gate runtime-PM reference from SWR clock enable until disable so autosuspend does not gate clocks while SWR is prepared.
Add a PM dependency for
SND_SOC_LPASS_WSA_MACROso PM clock helpers are available when this driver is built.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Suggested-by Mark Brown <[email protected]>You added this tag, but was the entire content of this patch sparked by Mark's suggestion?
Apologies for not including the Reviewed-by tag earlier — that was an oversight on my end.
I'm not sure we're on the same page. Please read:
Konrad