[alsa-devel] [PATCH 1/2] ASoC: core: call snd_soc_unregister_card() when component cleanup
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Mon Feb 9 02:06:13 CET 2015
Hi Mark
Thank you for your feedback
> > ASoC devices are organized as [CPU]-[CARD]-[CODEC]. Then, [CPU]/[CODEC]
> > are based on [component] structure. Now, each [CARD] device knows that
> > it has organized from which [component]. But current [component] doesn't
> > inform to [CARD] that it was removed when user called rmmod or unbind it.
> > Thus, [CARD] which lost some [components] still exist in system.
> > And then, ALSA sound card will have some problem if user used this [CARD]
> > in such timing. This patch unregister [CARD] when [component] was removed.
> > If you want to use this [CARD] again,
> > you need to re-insmod or re-bind removed [component] and [CARD] again.
>
> So, there's a problem here but...
>
> > @@ -2695,6 +2695,7 @@ static void snd_soc_component_add(struct snd_soc_component *component)
> > static void snd_soc_component_cleanup(struct snd_soc_component *component)
> > {
> > snd_soc_unregister_dais(component);
> > + snd_soc_unregister_card(component->card);
> > kfree(component->name);
> > }
>
> ...this doesn't look like the right fix. If we just plain unregister
> the card then if the component that was removed is loaded again then the
> card won't be reinstantiated since the core has forgotten about the
> card. Further, if the card driver is removed then we'll get a duplicate
> attempt to unregister it which doesn't seem clever.
>
> What we need to do here is undo all the work that was done to
> instantiate the card but not actually unregister it, returning
> everything to the state it was in before the card was instantiated.
> That's obviously a much more substantial change than this but it's
> what's needed (and is the main reason this is broken at the minute).
Hmm..
Main big problem is that the cpu/codec information in card is written in card->rtd[num],
and it has deeply relationship to many functions/datas.
Indeed it needs more substantial change if we solve this issue.
But, I thought register/unregister card is very easy hack, and it is easy to check.
I think this duplicate unregister card is no problem, because snd_soc_unregister_card()
is checking card->instantiated. 2nd unregister do nothing.
My hack (= on snd_soc_component_cleanup) is caring both cpu/codec,
bacause soc_unregister_codec() doesn't have relationship to snd_soc_unregister_component()
It needs more and more change if we solve this issue without above hack,
then, it is very difficult to check all consistency for all features, all situation.
I'm afraid that it can be next bug.
So, how about this ? if un-loaded component unregister card, and if re-loaded component
re-register un-loaded card automatically, it is easy, and safety ?
Best regards
---
Kuninori Morimoto
More information about the Alsa-devel
mailing list