From: "Alvin Šipraga" <alvin.sipraga@analog.com>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Mark Brown <broonie@kernel.org>, linux-sound@vger.kernel.org
Subject: Re: [PATCH v2 08/27] ASoC: soc-generic-dmaengine-pcm: use snd_soc_component_unregister()
Date: Thu, 12 Nov 2026 14:53:23 +0100 [thread overview]
Message-ID: <avW_0Tnvts3ArV8-@analog.com> (raw)
In-Reply-To: <87o6bu28ko.wl-kuninori.morimoto.gx@renesas.com>
Hi Kuninori,
On Thu, Nov 12, 2026 at 12:32:23AM +0000, Kuninori Morimoto wrote:
> Current snd_dmaengine_pcm_unregister() (X) is using
> snd_soc_unregister_component_by_driver() (Y) to unregister component.
>
> (X) void snd_dmaengine_pcm_unregister(...)
> {
> (Z) component = snd_soc_lookup_component(...);
> ...
Sorry - I was a bit too quick to review this. I think there is another
issue.
(Z) expanded is:
component = snd_soc_lookup_component(dev, SND_DMAENGINE_PCM_DRV_NAME);
which will walk the global component_list until it finds a component
matching the dev and SND_DMAENGINE_PCM_DRV_NAME.
If there's more than one snd_dmaengine_pcm component registered on the
same dev, how do we know that this lookup will pick the correct one?
It looks like the code was written with the assumption that there can
only be one snd_dmaengine_pcm component per dev. But I didn't look at
the history.
Does such a case exist? If not, maybe the easier solution (for now) is
to check if one has already been registered before registering another
one:
int snd_dmaengine_pcm_register(dev, config, flags)
{
component = snd_soc_lookup_component(dev, SND_DMAENGINE_PCM_DRV_NAME);
if (component)
return -EBUSY;
...
}
Then you don't have to worry about the 2x unregister problem sashiko
pointed out.
In general there are not many users of this lookup feature. Besides
snd_dmaengine_pcm there's just mtk-soundcard-driver.c and
fsl_asrc_dma.c. Both look a bit weird too. So maybe there's a way to get
rid of it altogether...
Kind regards,
Alvin
> (p) pcm = snd_soc_component_to_priv(component);
>
> (Y) snd_soc_unregister_component_by_driver(...);
> (p) dmaengine_pcm_release_chan(pcm);
> (p) kfree(pcm);
> }
>
> But it try to unregister all components from dev (a).
>
> (Y) void snd_soc_unregister_component(...)
> {
> ...
> while (1) {
> (Z) component = snd_soc_lookup_component_nolocked(...);
> ...
> (a) snd_soc_component_unregister(component);
> }
> }
>
> snd_dmaengine_pcm_unregister() (X) need to care/free pcm which is connected
> to component (= p). Both (X) and (Y) are using lookup_component (Z).
> So (X) can handle first component/pcm (p), but can't handle 2nd or more
> component/pcm eventhough (X) was called multiple times, because (Y)
> unregister all components. Let's call snd_soc_component_unregister() (a)
> instead of snd_soc_unregister_component_by_driver() (Y) in (X), and
> unregister target component only, not all.
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://lore.kernel.org/r/sashiko-outbox-206296@kernel.org
> ---
> sound/soc/soc-generic-dmaengine-pcm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
> index 1ecf3feb2bed0..62f86d97668ef 100644
> --- a/sound/soc/soc-generic-dmaengine-pcm.c
> +++ b/sound/soc/soc-generic-dmaengine-pcm.c
> @@ -514,7 +514,7 @@ void snd_dmaengine_pcm_unregister(struct device *dev)
>
> pcm = snd_soc_component_to_priv(component);
>
> - snd_soc_unregister_component_by_driver(dev, component->driver);
> + snd_soc_component_unregister(component);
> dmaengine_pcm_release_chan(pcm);
> kfree(pcm);
> }
> --
> 2.53.0
>
next prev parent reply other threads:[~2026-11-12 13:53 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 0:30 [PATCH v2 00/27] ASoC: add new Component functions Kuninori Morimoto
2026-11-12 0:30 ` [PATCH v2 01/27] ASoC: soc-generic-dmaengine-pcm: move devm_snd_dmaengine_pcm_register() Kuninori Morimoto
2026-11-12 0:30 ` [PATCH v2 02/27] ASoC: soc-component: rename snd_soc_component_{init/exit}_regmap() to snd_soc_component_regmap_{init/exit}() Kuninori Morimoto
2026-11-12 12:57 ` Alvin Šipraga
2026-11-12 0:31 ` [PATCH v2 03/27] ASoC: soc-component: rename snd_soc_component_regmap_val_bytes() Kuninori Morimoto
2026-11-12 12:57 ` Alvin Šipraga
2026-11-12 0:31 ` [PATCH v2 04/27] ASoC: soc-component: rename snd_soc_component_regmap_cache_sync() Kuninori Morimoto
2026-11-12 12:58 ` Alvin Šipraga
2026-11-12 0:31 ` [PATCH v2 05/27] ASoC: soc-component: align snd_soc_component_{regmap/regcache}_xxx() functions Kuninori Morimoto
2026-11-12 12:58 ` Alvin Šipraga
2026-11-12 0:31 ` [PATCH v2 06/27] ASoC: soc-core: move snd_soc_del_component_unlocked() Kuninori Morimoto
2026-11-12 12:58 ` Alvin Šipraga
2026-11-12 0:32 ` [PATCH v2 07/27] ASoC: soc-core: add missing snd_soc_component_unregister() Kuninori Morimoto
2026-11-12 12:59 ` Alvin Šipraga
2026-11-12 0:32 ` [PATCH v2 08/27] ASoC: soc-generic-dmaengine-pcm: use snd_soc_component_unregister() Kuninori Morimoto
2026-11-12 12:59 ` Alvin Šipraga
2026-11-12 13:53 ` Alvin Šipraga [this message]
2026-11-12 0:32 ` [PATCH v2 09/27] ASoC: soc-devres: use snd_soc_component_unregister() for devm_snd_soc_register_component() Kuninori Morimoto
2026-11-12 1:45 ` sashiko-bot
2026-11-12 3:20 ` Kuninori Morimoto
2026-11-12 0:32 ` [PATCH v2 10/27] ASoC: soc-core: remove snd_soc_unregister_component_by_driver() Kuninori Morimoto
2026-11-12 0:32 ` [PATCH v2 11/27] ASoC: soc-component: move snd_soc_register_[un]component() to soc-component.c Kuninori Morimoto
2026-11-12 0:32 ` [PATCH v2 12/27] ASoC: soc-component: move devm_snd_soc_component_register() Kuninori Morimoto
2026-11-12 0:32 ` [PATCH v2 13/27] ASoC: soc-component: move snd_soc_of_xlate_dai_name() to soc-component.c Kuninori Morimoto
2026-11-12 0:32 ` [PATCH v2 14/27] ASoC: soc-component: add snd_soc_component_name_prefix() Kuninori Morimoto
2026-11-12 0:33 ` [PATCH v2 15/27] ASoC: soc-component: add snd_soc_component_to_dev() Kuninori Morimoto
2026-11-12 0:33 ` [PATCH v2 16/27] ASoC: soc-component: add snd_soc_component_to_driver() Kuninori Morimoto
2026-11-12 0:33 ` [PATCH v2 17/27] ASoC: soc-component: add snd_soc_component_to_card() Kuninori Morimoto
2026-11-12 0:33 ` [PATCH v2 18/27] ASoC: soc-component: add snd_soc_component_to_debugfs_root() Kuninori Morimoto
2026-11-12 0:33 ` [PATCH v2 19/27] ASoC: soc-component: add snd_soc_component_to_regmap() Kuninori Morimoto
2026-11-12 0:33 ` [PATCH v2 20/27] ASoC: soc-component: add snd_soc_component_regcache_mark_dirty() Kuninori Morimoto
2026-11-12 0:33 ` [PATCH v2 21/27] ASoC: soc-component: add snd_soc_component_regcache_cache_only() Kuninori Morimoto
2026-11-12 0:33 ` [PATCH v2 22/27] ASoC: soc-component: add snd_soc_component_regcache_cache_bypass() Kuninori Morimoto
2026-11-12 0:33 ` [PATCH v2 23/27] ASoC: soc-component: add snd_soc_component_regmap_multi_reg_write_bypassed() Kuninori Morimoto
2026-11-12 0:33 ` [PATCH v2 24/27] ASoC: soc-component: add snd_soc_component_num_dai() Kuninori Morimoto
2026-11-12 0:33 ` [PATCH v2 25/27] ASoC: soc-component: add snd_soc_component_connect_dai() Kuninori Morimoto
2026-11-12 0:33 ` [PATCH v2 26/27] ASoC: soc-component: add snd_soc_component_active_update() Kuninori Morimoto
2026-11-12 0:33 ` [PATCH v2 27/27] ASoC: soc-component: add snd_soc_component_device_link_{add/del}() Kuninori Morimoto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=avW_0Tnvts3ArV8-@analog.com \
--to=alvin.sipraga@analog.com \
--cc=broonie@kernel.org \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=linux-sound@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox