[PATCH][RFC] ASoC: soc-component: count snd_soc_component_open/close()

Sridharan, Ranjani ranjani.sridharan at intel.com
Thu Feb 20 02:25:03 CET 2020


On Wed, Feb 19, 2020 at 5:01 PM Kuninori Morimoto <
kuninori.morimoto.gx at renesas.com> wrote:

> ASoC component open/close and snd_soc_component_module_get/put are
> called once for each component, but we need it for each substream.
> To solve this issue, this patch counts open / get,
> and call close / put accordingly.
>
> Fixes: dd03907bf129 ("ASoC: soc-pcm: call snd_soc_component_open/close()
> once")
> Reported-by: Kai Vehmanen <kai.vehmanen at linux.intel.com>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
> ---
> I tidyuped code.
> I hope it can solve the issue.
>
>  include/sound/soc-component.h |  5 +++--
>  sound/soc/soc-component.c     | 35 ++++++++++++++++++++++-------------
>  2 files changed, 25 insertions(+), 15 deletions(-)
>
> diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
> index 1866ecc8e94b..4e78925858c0 100644
> --- a/include/sound/soc-component.h
> +++ b/include/sound/soc-component.h
> @@ -181,10 +181,11 @@ struct snd_soc_component {
>         const char *debugfs_prefix;
>  #endif
>
> +       u8 opened;
> +       u8 module;
> +
>         /* bit field */
>         unsigned int suspended:1; /* is in suspend PM state */
> -       unsigned int opened:1;
> -       unsigned int module:1;
>  };
>
>  #define for_each_component_dais(component, dai)\
> diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
> index ee00c09df5e7..bdd36be1fb70 100644
> --- a/sound/soc/soc-component.c
> +++ b/sound/soc/soc-component.c
> @@ -297,14 +297,16 @@ EXPORT_SYMBOL_GPL(snd_soc_component_set_jack);
>  int snd_soc_component_module_get(struct snd_soc_component *component,
>                                  int upon_open)
>  {
> -       if (component->module)
> -               return 0;
> +       if (unlikely(component->module == 0xff)) {
> +               dev_warn(component->dev, "too many module get (%s)\n",
> component->name);
> +               return -EBUSY;
> +       }
>
>         if (component->driver->module_get_upon_open == !!upon_open &&
>             !try_module_get(component->dev->driver->owner))
>                 return -ENODEV;
>
> -       component->module = 1;
> +       component->module++;
>
Thanks, Morimoto-san for the alternate fix. I understand the rationale for
having a count for component->opened, but what is the rationale for the
module count? What it is intended to protect?

Thanks,
Ranjani


More information about the Alsa-devel mailing list