[alsa-devel] [PATCH] ASoC: dapm: Use less aggressive caching to ensure correctness

Tzung-Bi Shih tzungbi at google.com
Mon Nov 5 12:19:12 CET 2018


Commit 92a99ea439c4 ("ASoC: dapm: Use more aggressive caching") only
invalidates necessary caches to improve the cache hit rate.  However,
in snd_soc_dapm_add_path(), the cache is too aggressive which results
in wrong state of the audio map.

E.g. imaging the following examples during snd_soc_instantiate_card():

time 1: at the beginning

  in:-1    in:-1     in:-1
 out:-1   out:-1    out:-1
      A -----> B       Spk

time 2: after someone called snd_soc_dapm_new_widgets()
(e.g. create_fill_widget_route_map() in sound/soc/codecs/hdac_hdmi.c)

  in:0    in:0     in:0
 out:0   out:0    out:1
     A ----> B      Spk

time 3: route added to Spk

  in:0    in:0      in:0
 out:0   out:0     out:1
     A ----> B ----> Spk

time N: route added from SIGGEN

  in:1    in:0    in:0      in:0
 out:0   out:0   out:0     out:1
SIGGEN ----> A ----> B ----> Spk

In the end, the path will not power on but it should be.  At time 2, the
caches have been polluted.  At time 3, it will not get the correct state
if snd_soc_dapm_add_path() does not invalidate "out" of B and A.

time 3 (expected result):

  in:0    in:0      in:0
 out:1   out:1     out:1
     A ----> B ----> Spk

Signed-off-by: Tzung-Bi Shih <tzungbi at google.com>
---
 sound/soc/soc-dapm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index a5178845065b..2914f3adb333 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2722,7 +2722,7 @@ static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm,
 		dapm_mark_dirty(widgets[dir], "Route added");
 	}
 
-	if (dapm->card->instantiated && path->connect)
+	if (path->connect)
 		dapm_path_invalidate(path);
 
 	return 0;
-- 
2.19.1.930.g4563a0d9d0-goog



More information about the Alsa-devel mailing list