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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 19, 2020 at 5:42 PM Kuninori Morimoto <
kuninori.morimoto.gx@xxxxxxxxxxx> wrote:

>
> Hi Sridharan
>
> >     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@xxxxxxxxxxxxxxx>
> >     Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>
> >     ---
> (snip)
> >     @@ -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?
>
> I think same as open ?
> It protects calling put() from not-get-component.
> Because module_put() has WARN_ON(ret < 0).
>
Can we use the module_refcount instead of adding a new field?

Thanks,
Ranjani



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux