summaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-compress.c
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>2021-09-01 11:52:55 +0200
committerMark Brown <broonie@kernel.org>2021-09-20 14:30:18 +0200
commitcd46f3824480740879d2c15d65c6e6b038f96021 (patch)
tree71ffe74fd1d72ebb6ddce68483f42bea335e46e2 /sound/soc/soc-compress.c
parentASoC: soc-component: Convert the mark_module to void* (diff)
downloadlinux-cd46f3824480740879d2c15d65c6e6b038f96021.tar.xz
linux-cd46f3824480740879d2c15d65c6e6b038f96021.zip
ASoC: compress/component: Use module_get_when_open/put_when_close for cstream
Currently the try_module_get() and module_put() is not possible for compressed streams if the module_get_upon_open is set to 1 which means that\ the components are not protected in a same way as components when normal audio is used. SOF is setting module_get_upon_open to 1 for component drivers which works correctly for audio stream but when compressed stream is used then the module is not protected. Convert the compress open and free operation to mimic the steps of it's pcm counterpart to fix this issue. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://lore.kernel.org/r/20210901095255.3617-3-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-compress.c')
-rw-r--r--sound/soc/soc-compress.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 36060800e9bd..8e2494a9f3a7 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -22,6 +22,39 @@
#include <sound/soc-link.h>
#include <linux/pm_runtime.h>
+static int snd_soc_compr_components_open(struct snd_compr_stream *cstream)
+{
+ struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+ struct snd_soc_component *component;
+ int ret = 0;
+ int i;
+
+ for_each_rtd_components(rtd, i, component) {
+ ret = snd_soc_component_module_get_when_open(component, cstream);
+ if (ret < 0)
+ break;
+
+ ret = snd_soc_component_compr_open(component, cstream);
+ if (ret < 0)
+ break;
+ }
+
+ return ret;
+}
+
+static void snd_soc_compr_components_free(struct snd_compr_stream *cstream,
+ int rollback)
+{
+ struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+ struct snd_soc_component *component;
+ int i;
+
+ for_each_rtd_components(rtd, i, component) {
+ snd_soc_component_compr_free(component, cstream, rollback);
+ snd_soc_component_module_put_when_close(component, cstream, rollback);
+ }
+}
+
static int soc_compr_clean(struct snd_compr_stream *cstream, int rollback)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
@@ -44,7 +77,7 @@ static int soc_compr_clean(struct snd_compr_stream *cstream, int rollback)
snd_soc_link_compr_shutdown(cstream, rollback);
- snd_soc_component_compr_free(cstream, rollback);
+ snd_soc_compr_components_free(cstream, rollback);
snd_soc_dai_compr_shutdown(cpu_dai, cstream, rollback);
@@ -80,7 +113,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
if (ret < 0)
goto err;
- ret = snd_soc_component_compr_open(cstream);
+ ret = snd_soc_compr_components_open(cstream);
if (ret < 0)
goto err;
@@ -137,7 +170,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
if (ret < 0)
goto out;
- ret = snd_soc_component_compr_open(cstream);
+ ret = snd_soc_compr_components_open(cstream);
if (ret < 0)
goto open_err;
@@ -160,7 +193,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
return 0;
machine_err:
- snd_soc_component_compr_free(cstream, 1);
+ snd_soc_compr_components_free(cstream, 1);
open_err:
snd_soc_dai_compr_shutdown(cpu_dai, cstream, 1);
out:
@@ -205,7 +238,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
snd_soc_link_compr_shutdown(cstream, 0);
- snd_soc_component_compr_free(cstream, 0);
+ snd_soc_compr_components_free(cstream, 0);
snd_soc_dai_compr_shutdown(cpu_dai, cstream, 0);