Skip to contentSkip to conversation

Fix redundant PLLA update

PATCH Superseded Sameer Pujar 2 participants 6 messages Sep 7, 2023

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Fix redundant PLLA update

This small series fixes redundant PLLA updates that happen for each DAI link in the audio path.

Sameer Pujar (2):
ASoC: soc-utils: Export snd_soc_dai_is_dummy() symbol
ASoC: tegra: Fix redundant PLLA and PLLA_OUT0 updates

 sound/soc/soc-utils.c                    |  1 +
 sound/soc/tegra/tegra_audio_graph_card.c | 30 ++++++++++++++----------
 2 files changed, 18 insertions(+), 13 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 ASoC: soc-utils: Export snd_soc_dai_is_dummy() symbol

Export symbol snd_soc_dai_is_dummy() for usage outside core driver modules. This is required by Tegra ASoC machine driver.

---
 sound/soc/soc-utils.c | 1 +
 1 file changed, 1 insertion(+)
sound/soc/soc-utils.c +1 -0
index 11607c5f5d5a..9c746e4edef7 100644
@@ -217,6 +217,7 @@ int snd_soc_dai_is_dummy(struct snd_soc_dai *dai)
 		return 1;
 	return 0;
 }
+EXPORT_SYMBOL_GPL(snd_soc_dai_is_dummy);
 
 int snd_soc_component_is_dummy(struct snd_soc_component *component)
 {
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 ASoC: tegra: Fix redundant PLLA and PLLA_OUT0 updates

In reply to Sameer Pujar

Tegra audio graph card has many DAI links which connects internal AHUB modules and external audio codecs. Since these are DPCM links, hw_params() call in the machine driver happens for each connected BE link and PLLA is updated every time. This is not really needed for all links as only I/O link DAIs derive respective clocks from PLLA_OUT0 and thus from PLLA. Hence add checks to limit the clock updates to DAIs over I/O links.

Fixes 202e2f774543 ("ASoC: tegra: Add audio graph based card driver")
---
 sound/soc/tegra/tegra_audio_graph_card.c | 30 ++++++++++++++----------
 1 file changed, 17 insertions(+), 13 deletions(-)
sound/soc/tegra/tegra_audio_graph_card.c +17 -13
index 1f2c5018bf5a..4737e776d383 100644
@@ -10,6 +10,7 @@
 #include <linux/platform_device.h>
 #include <sound/graph_card.h>
 #include <sound/pcm_params.h>
+#include <sound/soc-dai.h>
 
 #define MAX_PLLA_OUT0_DIV 128
 
@@ -44,6 +45,21 @@ struct tegra_audio_cdata {
 	unsigned int plla_out0_rates[NUM_RATE_TYPE];
 };
 
+static bool need_clk_update(struct snd_soc_dai *dai)
+{
+	if (snd_soc_dai_is_dummy(dai) ||
+	    !dai->driver->ops ||
+	    !dai->driver->name)
+		return false;
+
+	if (strstr(dai->driver->name, "I2S") ||
+	    strstr(dai->driver->name, "DMIC") ||
+	    strstr(dai->driver->name, "DSPK"))
+		return true;
+
+	return false;
+}
+
 /* Setup PLL clock as per the given sample rate */
 static int tegra_audio_graph_update_pll(struct snd_pcm_substream *substream,
 					struct snd_pcm_hw_params *params)
@@ -140,19 +156,7 @@ static int tegra_audio_graph_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
 	int err;
 
-	/*
-	 * This gets called for each DAI link (FE or BE) when DPCM is used.
-	 * We may not want to update PLLA rate for each call. So PLLA update
-	 * must be restricted to external I/O links (I2S, DMIC or DSPK) since
-	 * they actually depend on it. I/O modules update their clocks in
-	 * hw_param() of their respective component driver and PLLA rate
-	 * update here helps them to derive appropriate rates.
-	 *
-	 * TODO: When more HW accelerators get added (like sample rate
-	 * converter, volume gain controller etc., which don't really
-	 * depend on PLLA) we need a better way to filter here.
-	 */
-	if (cpu_dai->driver->ops && rtd->dai_link->no_pcm) {
+	if (need_clk_update(cpu_dai)) {
 		err = tegra_audio_graph_update_pll(substream, params);
 		if (err)
 			return err;
Signature · 1 line
2.17.1
maintainer
#3 lore raw

Re: [PATCH 2/2] ASoC: tegra: Fix redundant PLLA and PLLA_OUT0 updates

Quoted 2 lines · Sameer Pujar
Fixes 202e2f774543 ("ASoC: tegra: Add audio graph based card driver")

This is just a performance improvement rather than a correctness fix as far as I can tell?

#4 lore raw

Re: [PATCH 2/2] ASoC: tegra: Fix redundant PLLA and PLLA_OUT0 updates

Quoted 6 lines · Mark Brown
Quoted 2 lines · Sameer Pujar
Fixes 202e2f774543 ("ASoC: tegra: Add audio graph based card driver")

This is just a performance improvement rather than a correctness fix as far as I can tell?

This was supposed to be a performance improvement. However this is found to be resolving a DMIC clock discrepancy and suspect is it happens because of back to back quick PLLA updates. Thought it would be safer to have this fix in stable releases. May be I should mention these points to justify the 'Fixes' and 'stable' tag?

maintainer
#5 lore raw

Re: [PATCH 2/2] ASoC: tegra: Fix redundant PLLA and PLLA_OUT0 updates

Quoted 6 lines · Sameer Pujar
Quoted 4 lines · Mark Brown
Quoted 2 lines · Sameer Pujar
Fixes 202e2f774543 ("ASoC: tegra: Add audio graph based card driver")
Quoted 8 lines
Quoted 2 lines

This is just a performance improvement rather than a correctness fix as far as I can tell?

This was supposed to be a performance improvement. However this is found to be resolving a DMIC clock discrepancy and suspect is it happens because of back to back quick PLLA updates. Thought it would be safer to have this fix in stable releases. May be I should mention these points to justify the 'Fixes' and 'stable' tag?

Yes, please - that does make sense as a fix.