Skip to contentSkip to conversation

ASoC: qcom: lpass: Switch VA/WSA macros to PM clock framework

PATCH Superseded Ajay Kumar Nandam 3 participants 12 messages May 22 – May 25

Subsystems (4)

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 6f587e39223b..4e17119f2f9e 100644
@@ -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
#9 lore raw

PATCH v5 2/3 ASoC: codecs: lpass-va-macro: Switch to PM clock framework for runtime PM

In reply to Ajay Kumar Nandam

Convert 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
index 4e17119f2f9e..e73667b87fd8 100644
@@ -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
#10 lore raw

PATCH v5 3/3 ASoC: codecs: lpass-wsa-macro: Use devm_clk_hw_register() for MCLK output

In reply to Ajay Kumar Nandam

The 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
index 598292fe3219..3081c115d584 100644
@@ -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
maintainer
#2 lore raw

Re: [PATCH v5 1/3] ASoC: codecs: lpass-wsa-macro: Switch to PM clock framework for runtime PM

In reply to Ajay Kumar Nandam

sound/soc/codecs/Kconfig config SND_SOC_LPASS_MACRO_COMMON · line 2867

Quoted 12 lines · Ajay Kumar Nandam

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.

config SND_SOC_LPASS_WSA_MACRO

sound/soc/codecs/Kconfig +1 -0
 	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)"

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.

maintainer
#11 lore raw
In reply to Ajay Kumar Nandam
Quoted 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.

#6 lore raw

Re: [PATCH v5 1/3] ASoC: codecs: lpass-wsa-macro: Switch to PM clock framework for runtime PM

In reply to Ajay Kumar Nandam
Quoted 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_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.

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_MACRO so PM clock helpers are available when this driver is built.

You added this tag, but was the entire content of this patch sparked by Mark's suggestion?

Konrad

#3 lore raw

Re: [PATCH v5 1/3] ASoC: codecs: lpass-wsa-macro: Switch to PM clock framework for runtime PM

In reply to Mark Brown
Quoted 8 lines · Mark Brown
Quoted 5 lines · Ajay Kumar Nandam

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.

Quoted 10 lines

sound/soc/codecs/Kconfig config SND_SOC_LPASS_MACRO_COMMON · line 2867

Quoted 6 lines

config SND_SOC_LPASS_WSA_MACRO

sound/soc/codecs/Kconfig +1 -0
 	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)"

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.

Yeah, leaving it as-is sounds like a bad idea

Konrad

#5 lore raw

Re: [PATCH v5 1/3] ASoC: codecs: lpass-wsa-macro: Switch to PM clock framework for runtime PM

In reply to Mark Brown
Quoted 8 lines · Mark Brown
Quoted 5 lines · Ajay Kumar Nandam

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.

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 on COMMON_CLK

sound/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 since PM_CLK depends on PM and HAVE_CLK but the indirection leaves a window for things to break in future.

ACK, agreed with your statement will update in V6

Thanks
Ajay Kumar

#4 lore raw

Re: [PATCH v5 1/3] ASoC: codecs: lpass-wsa-macro: Switch to PM clock framework for runtime PM

In reply to Konrad Dybcio
Quoted 20 lines · Konrad Dybcio
Quoted 8 lines · Mark Brown
Quoted 5 lines · Ajay Kumar Nandam

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.

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 on COMMON_CLK

sound/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 since PM_CLK depends on PM and HAVE_CLK but 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

#7 lore raw

Re: [PATCH v5 1/3] ASoC: codecs: lpass-wsa-macro: Switch to PM clock framework for runtime PM

In reply to Konrad Dybcio
Quoted 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_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.

Quoted 7 lines
Quoted 4 lines

Add a PM dependency for SND_SOC_LPASS_WSA_MACRO so PM clock helpers are available when this driver is built.

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

#8 lore raw

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_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.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

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:

https://docs.kernel.org/process/submitting-patches.html#using-reported-by-tested-by-reviewed-by-suggested-by-and-fixes

Konrad