Skip to contentSkip to conversation

ASoC: Add flag to ignore 0Hz sysclk requests

PATCH In review Sheetal 3 participants 8 messages Mar 17 – Mar 25

Subsystems (4)
lore
Share & tools
lore

Sheetal

author
#0 lore raw

cover ASoC: Add flag to ignore 0Hz sysclk requests

Commit 2458adb8f92a ("SoC: simple-card-utils: set 0Hz to sysclk when shutdown") introduced 0Hz sysclk requests during stream shutdown. On Tegra platforms, clocks such as AUD_MCLK have a minimum allowed frequency, so passing 0Hz results in Boot and Power Management Processor (BPMP) clock controller errors.

This series adds an ignore_zero_sysclk flag to simple-card-utils so that platform drivers can opt out of these 0Hz requests, and enables it for the Tegra audio graph card.

Sheetal (2):
ASoC: simple-card-utils: add ignore_zero_sysclk flag
ASoC: tegra: enable ignore_zero_sysclk for Tegra

 include/sound/simple_card_utils.h        | 1 +
 sound/soc/generic/simple-card-utils.c    | 6 ++++--
 sound/soc/tegra/tegra_audio_graph_card.c | 1 +
 3 files changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/2 ASoC: simple-card-utils: add ignore_zero_sysclk flag

Commit 2458adb8f92a ("SoC: simple-card-utils: set 0Hz to sysclk when shutdown") updated the simple-card-util driver to send 0Hz frequency requests during stream shutdown, which can request frequencies lower than a platform may support.

Add ignore_zero_sysclk flag to struct simple_util_priv to allow drivers to ignore these 0Hz sysclk requests when they would result in a clock frequency below the hardware's minimum allowed rate.

---
 include/sound/simple_card_utils.h     | 1 +
 sound/soc/generic/simple-card-utils.c | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)
include/sound/simple_card_utils.h +1 -0
index 915e6ae5f68d..02ede92e8269 100644
@@ -81,6 +81,7 @@ struct simple_util_priv {
 	const struct snd_soc_ops *ops;
 	unsigned int dpcm_selectable:1;
 	unsigned int force_dpcm:1;
+	unsigned int ignore_zero_sysclk:1;
 };
 #define simple_priv_to_card(priv)	(&(priv)->snd_card)
 #define simple_priv_to_props(priv, i)	((priv)->dai_props + (i))
sound/soc/generic/simple-card-utils.c +4 -2
index 3115e1f37c0c..04ae242a51d0 100644
@@ -383,7 +383,8 @@ void simple_util_shutdown(struct snd_pcm_substream *substream)
 	for_each_prop_dai_cpu(props, i, dai) {
 		struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, i);
 
-		if (props->mclk_fs && !dai->clk_fixed && !snd_soc_dai_active(cpu_dai))
+		if (!priv->ignore_zero_sysclk && props->mclk_fs &&
+		    !dai->clk_fixed && !snd_soc_dai_active(cpu_dai))
 			snd_soc_dai_set_sysclk(cpu_dai, 0, 0, dai->clk_direction);
 
 		simple_clk_disable(dai);
@@ -391,7 +392,8 @@ void simple_util_shutdown(struct snd_pcm_substream *substream)
 	for_each_prop_dai_codec(props, i, dai) {
 		struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, i);
 
-		if (props->mclk_fs && !dai->clk_fixed && !snd_soc_dai_active(codec_dai))
+		if (!priv->ignore_zero_sysclk && props->mclk_fs &&
+		    !dai->clk_fixed && !snd_soc_dai_active(codec_dai))
 			snd_soc_dai_set_sysclk(codec_dai, 0, 0, dai->clk_direction);
 
 		simple_clk_disable(dai);
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH 1/2] ASoC: simple-card-utils: add ignore_zero_sysclk flag

Quoted 8 lines · Sheetal

Commit 2458adb8f92a ("SoC: simple-card-utils: set 0Hz to sysclk when shutdown") updated the simple-card-util driver to send 0Hz frequency requests during stream shutdown, which can request frequencies lower than a platform may support.

Add ignore_zero_sysclk flag to struct simple_util_priv to allow drivers to ignore these 0Hz sysclk requests when they would result in a clock frequency below the hardware's minimum allowed rate.

If the driver simply can't tolerate disabling the sysclk it seems like it would be easier to just have the driver directly ignore attempts to do so rather than adding this flag which the driver has to set only to get it passed in?

#3 lore raw

Re: [PATCH 1/2] ASoC: simple-card-utils: add ignore_zero_sysclk flag

Hi

Quoted 5 lines
Quoted 4 lines

Commit 2458adb8f92a ("SoC: simple-card-utils: set 0Hz to sysclk when shutdown") updated the simple-card-util driver to send 0Hz frequency requests during stream shutdown, which can request frequencies lower than a platform may support.

Quoted 8 lines
Quoted 3 lines

Add ignore_zero_sysclk flag to struct simple_util_priv to allow drivers to ignore these 0Hz sysclk requests when they would result in a clock frequency below the hardware's minimum allowed rate.

If the driver simply can't tolerate disabling the sysclk it seems like it would be easier to just have the driver directly ignore attempts to do so rather than adding this flag which the driver has to set only to get it passed in?

Agree.
I think this commit can help you ?

	1e1a2ef95b571825ca9c0113f6bef51e9cec98b0
	("ASoC: da7213: Avoid setting PLL when closing audio stream")

Thank you for your help !!

Best regards
---
Kuninori Morimoto

author
#4 lore raw

Re: [PATCH 1/2] ASoC: simple-card-utils: add ignore_zero_sysclk flag

Quoted 19 lines · Kuninori Morimoto

External email: Use caution opening links or attachments

Hi

Quoted 5 lines
Quoted 4 lines

Commit 2458adb8f92a ("SoC: simple-card-utils: set 0Hz to sysclk when shutdown") updated the simple-card-util driver to send 0Hz frequency requests during stream shutdown, which can request frequencies lower than a platform may support.

Quoted 8 lines
Quoted 3 lines

Add ignore_zero_sysclk flag to struct simple_util_priv to allow drivers to ignore these 0Hz sysclk requests when they would result in a clock frequency below the hardware's minimum allowed rate.

If the driver simply can't tolerate disabling the sysclk it seems like it would be easier to just have the driver directly ignore attempts to do so rather than adding this flag which the driver has to set only to get it passed in?

Quoted 7 lines

Agree.
I think this commit can help you ?

1e1a2ef95b571825ca9c0113f6bef51e9cec98b0
("ASoC: da7213: Avoid setting PLL when closing audio stream")

Thank you for your help !!

Thank you for the feedback and the da7213 reference.

The concern with the per-codec approach is that this affects any codec with a set_dai_sysclk that forwards the frequency to clk_set_rate(). Since any codec can be connected to Tegra platforms, and MCLK is provided by the SoC to external codecs, when clk_set_rate(..., 0) reaches the BPMP firmware, it raises a fault for rates below the hardware minimum. Fixing this per-codec would require individual patches for each.

Quoted 4 lines

Best regards
---
Kuninori Morimoto

maintainer
#5 lore raw

Re: [PATCH 1/2] ASoC: simple-card-utils: add ignore_zero_sysclk flag

Quoted 13 lines · Sheetal .
Quoted 10 lines · Kuninori Morimoto
Quoted 4 lines

If the driver simply can't tolerate disabling the sysclk it seems like it would be easier to just have the driver directly ignore attempts to do so rather than adding this flag which the driver has to set only to get it passed in?

Agree.
I think this commit can help you ?

1e1a2ef95b571825ca9c0113f6bef51e9cec98b0
("ASoC: da7213: Avoid setting PLL when closing audio stream")

Quoted 8 lines

Thank you for the feedback and the da7213 reference.

The concern with the per-codec approach is that this affects any codec with a set_dai_sysclk that forwards the frequency to clk_set_rate(). Since any codec can be connected to Tegra platforms, and MCLK is provided by the SoC to external codecs, when clk_set_rate(..., 0) reaches the BPMP firmware, it raises a fault for rates below the hardware minimum. Fixing this per-codec would require individual patches for each.

Since in the clock API clk_get_rate() maps onto clk_disable() those drivers ought to be fixed anyway - perhaps we need some helpers for this since it does look like we have some issues here. Either the driver should ignore the disable (possibly due to already refcounting the use of the clock and disabling/enabling without machine driver help) or it should translate a rate of 0 to a disable.

author
#6 lore raw

Re: [PATCH 1/2] ASoC: simple-card-utils: add ignore_zero_sysclk flag

Quoted 23 lines · Mark Brown
Quoted 13 lines · Sheetal .
Quoted 10 lines · Kuninori Morimoto
Quoted 4 lines

If the driver simply can't tolerate disabling the sysclk it seems like it would be easier to just have the driver directly ignore attempts to do so rather than adding this flag which the driver has to set only to get it passed in?

Agree.
I think this commit can help you ?

1e1a2ef95b571825ca9c0113f6bef51e9cec98b0
("ASoC: da7213: Avoid setting PLL when closing audio stream")

Quoted 8 lines

Thank you for the feedback and the da7213 reference.

The concern with the per-codec approach is that this affects any codec with a set_dai_sysclk that forwards the frequency to clk_set_rate(). Since any codec can be connected to Tegra platforms, and MCLK is provided by the SoC to external codecs, when clk_set_rate(..., 0) reaches the BPMP firmware, it raises a fault for rates below the hardware minimum. Fixing this per-codec would require individual patches for each.

Quoted 6 lines

Since in the clock API clk_get_rate() maps onto clk_disable() those drivers ought to be fixed anyway - perhaps we need some helpers for this since it does look like we have some issues here. Either the driver should ignore the disable (possibly due to already refcounting the use of the clock and disabling/enabling without machine driver help) or it should translate a rate of 0 to a disable.

Since this needs to be handled in the codec driver, I will start with separate patch to fix in RT5640 codec. Adding Realtek codec maintainer for visibility.

author
#7 lore raw

PATCH 2/2 ASoC: tegra: enable ignore_zero_sysclk for Tegra

In reply to Sheetal

Tegra AUD_MCLK has a minimum allowed clock frequency of 1.5MHz, but 0Hz requests cause the system to set a lower rate than this minimum, resulting in the following errors from the Tegra Boot and Power Management Processor (BPMP) that configures the clocks:

verify_rate_range: FMON_AUD_MCLK: rate 383999 below min 1500000
fmon_update_config: FMON_AUD_MCLK: detected fault 0x80

Enable the ignore_zero_sysclk flag for Tegra audio graph card to ignore these 0Hz sysclk requests during stream shutdown.

---
 sound/soc/tegra/tegra_audio_graph_card.c | 1 +
 1 file changed, 1 insertion(+)
sound/soc/tegra/tegra_audio_graph_card.c +1 -0
index ea10e6e8a9fe..3c88c43e1273 100644
@@ -209,6 +209,7 @@ static int tegra_audio_graph_probe(struct platform_device *pdev)
 	card->component_chaining = 1;
 	priv->simple.ops = &tegra_audio_graph_ops;
 	priv->simple.force_dpcm = 1;
+	priv->simple.ignore_zero_sysclk = 1;
 
 	return audio_graph_parse_of(&priv->simple, dev);
 }
Signature · 1 line
2.17.1