ASoC: compress: Support module_get on stream open
Subsystems (3)
cover ASoC: compress: Support module_get on stream open
Hi,
SOF is marking all componet drivers with module_get_upon_open = 1 which works fine with normal PCM streams, however on compressed side the module get upon open is not supported. The module_get works when module_get_upon_open is not set becasue the snd_soc_component_module_get_when_probe() will pass NULL for the substream parameter of snd_soc_component_module_get().
In order to re-use the existing infrastructure for module_get, the proposal is to convert the mark_module to void pointer (like the pm mark) and implement matching code for the compressed open/free to pcm open/close.
Regards,
Peter
---
Peter Ujfalusi (2):
ASoC: soc-component: Convert the mark_module to void*
ASoC: compress/component: Use module_get_when_open/put_when_close for
cstream
include/sound/soc-component.h | 14 ++++---- sound/soc/soc-component.c | 61 +++++++++++++++-------------------- sound/soc/soc-compress.c | 43 +++++++++++++++++++++--- 3 files changed, 71 insertions(+), 47 deletions(-)
Signature · 1 line
2.33.0
PATCH 1/2 ASoC: soc-component: Convert the mark_module to void*
The mark_module of the snd_soc_component is strict snd_pcm_substream type which prevents it to be used by compressed streams.
Change the type to void* along with the snd_soc_component_module_get() and snd_soc_component_module_put() to allow the same mark to be used by compressed when it's module_get_upon_open is set to 1.
--- include/sound/soc-component.h | 8 +++----- sound/soc/soc-component.c | 16 +++++++--------- 2 files changed, 10 insertions(+), 14 deletions(-)
include/sound/soc-component.h +3 -5
@@ -220,7 +220,7 @@ struct snd_soc_component {int (*init)(struct snd_soc_component *component);/* function mark */ -struct snd_pcm_substream *mark_module; +void *mark_module;struct snd_pcm_substream *mark_open;struct snd_pcm_substream *mark_hw_params;struct snd_pcm_substream *mark_trigger;
@@ -391,15 +391,13 @@ void snd_soc_component_exit_regmap(struct snd_soc_component *component);#define snd_soc_component_module_get_when_open (component, substream) \ snd_soc_component_module_get(component, substream, 1)int snd_soc_component_module_get (struct snd_soc_component *component, -struct snd_pcm_substream *substream, -int upon_open); +void *mark,int upon_open);#define snd_soc_component_module_put_when_remove (component) \ snd_soc_component_module_put(component, NULL, 0, 0)#define snd_soc_component_module_put_when_close (component, substream, rollback) \ snd_soc_component_module_put(component, substream, 1, rollback)void snd_soc_component_module_put (struct snd_soc_component *component, -struct snd_pcm_substream *substream, -int upon_open,int rollback); +void *mark,int upon_open,int rollback);static inline void snd_soc_component_set_drvdata (struct snd_soc_component *c,void *data)
sound/soc/soc-component.c +7 -9
@@ -251,8 +251,7 @@ int snd_soc_component_set_jack(struct snd_soc_component *component,EXPORT_SYMBOL_GPL (snd_soc_component_set_jack);int snd_soc_component_module_get (struct snd_soc_component *component, -struct snd_pcm_substream *substream, -int upon_open) +void *mark,int upon_open) {int ret =0 ;
@@ -260,25 +259,24 @@ int snd_soc_component_module_get(struct snd_soc_component *component, !try_module_get(component->dev->driver->owner)) ret = -ENODEV ; -/* mark substream if succeeded */ +/* mark module if succeeded */ if (ret ==0 ) -soc_component_mark_push (component, substream, module); +soc_component_mark_push (component, mark, module);return soc_component_ret (component, ret); }void snd_soc_component_module_put (struct snd_soc_component *component, -struct snd_pcm_substream *substream, -int upon_open,int rollback) +void *mark,int upon_open,int rollback) { -if (rollback && !soc_component_mark_match (component, substream, module)) +if (rollback && !soc_component_mark_match (component, mark, module))return ;if (component->driver->module_get_upon_open == !!upon_open)module_put (component->dev->driver->owner); -/* remove marked substream */ -soc_component_mark_pop (component, substream, module); +/* remove the mark from module */ +soc_component_mark_pop (component, mark, module); } int snd_soc_component_open(struct snd_soc_component *component,
Signature · 1 line
2.33.0
PATCH 2/2 ASoC: compress/component: Use module_get_when_open/put_when_close for cstream
In reply to Peter UjfalusiCurrently 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.
--- include/sound/soc-component.h | 6 +++-- sound/soc/soc-component.c | 45 +++++++++++++++-------------------- sound/soc/soc-compress.c | 43 +++++++++++++++++++++++++++++---- 3 files changed, 61 insertions(+), 33 deletions(-)
include/sound/soc-component.h +4 -2
@@ -453,8 +453,10 @@ int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,int snd_soc_component_of_xlate_dai_name (struct snd_soc_component *component,const struct of_phandle_args *args,const char **dai_name); -int snd_soc_component_compr_open (struct snd_compr_stream *cstream); -void snd_soc_component_compr_free (struct snd_compr_stream *cstream, +int snd_soc_component_compr_open (struct snd_soc_component *component, +struct snd_compr_stream *cstream); +void snd_soc_component_compr_free (struct snd_soc_component *component, +struct snd_compr_stream *cstream,int rollback);int snd_soc_component_compr_trigger (struct snd_compr_stream *cstream,int cmd); int snd_soc_component_compr_set_params(struct snd_compr_stream *cstream,
sound/soc/soc-component.c +19 -26
62 lines not on this page · raw message
sound/soc/soc-compress.c +38 -5
79 lines not on this page · raw message
Signature · 1 line
2.33.0
Mark Brown
maintainerQuoted 11 lines · Peter Ujfalusi
SOF is marking all componet drivers with
module_get_upon_open= 1 which works fine with normal PCM streams, however on compressed side the module get upon open is not supported. Themodule_getworks whenmodule_get_upon_openis not set becasue thesnd_soc_component_module_get_when_probe()will pass NULL for the substream parameter ofsnd_soc_component_module_get().In order to re-use the existing infrastructure for
module_get, the proposal is to convert themark_moduleto void pointer (like the pm mark) and implement matching code for the compressed open/free to pcm open/close.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/2] ASoC: soc-component: Convert the mark_module to void*
commit: a739fdc26211952edb34bf1ac9ed7afe220a5d54
[2/2] ASoC: compress/component: Use module_get_when_open/put_when_close for cstream
commit: cd46f3824480740879d2c15d65c6e6b038f96021All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark