ASoC: topology: unload physical dai link in remove
PATCH v2 1/1 ASoC: topology: unload physical dai link in remove
From: Bard liao <[email protected]>
soc_tplg_link_config() will find the physical dai link and call soc_tplg_dai_link_load() to load the BE dai link. Currently remove_link() is only used to remove the FE dai link which is created by the topology. The BE dai link cannot however be unloaded in snd_soc_tplg_component _remove(), which is problematic if anything needs to be released or reinitialized.
This patch aligns the definitions of dynamic types with the existing UAPI and adds a new remove_backend_link() routine to unload the the BE dai link when snd_soc_tplg_component_remove() is invoked.
---
v2: reset the dobj.type to fix module load/unload issues
include/sound/soc-topology.h | 1 + sound/soc/soc-topology.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)
include/sound/soc-topology.h +1 -0
@@ -45,6 +45,7 @@ enum snd_soc_dobj_type {SND_SOC_DOBJ_DAI_LINK ,SND_SOC_DOBJ_PCM ,SND_SOC_DOBJ_CODEC_LINK , + SND_SOC_DOBJ_BACKEND_LINK, };/* dynamic control object */
sound/soc/soc-topology.c +32 -0
@@ -562,6 +562,25 @@ static void remove_link(struct snd_soc_component *comp,kfree (link); } +/* unload dai link */ +static void remove_backend_link (struct snd_soc_component *comp, +struct snd_soc_dobj *dobj,int pass) +{ +if (pass !=SOC_TPLG_PASS_LINK ) +return ; + +if (dobj->ops && dobj->ops->link_unload) + dobj->ops->link_unload (comp, dobj); + +/* +* We don't free the link here as what remove_link() do since BE +* links are not allocated by topology. +* We however need to reset the dobj type to its initial values +*/ + dobj->type =SND_SOC_DOBJ_NONE ; +list_del (&dobj->list); +} +/* bind a kcontrol to it's IO handlers */ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr, struct snd_kcontrol_new *k,
@@ -2168,6 +2187,12 @@ static int soc_tplg_link_config(struct soc_tplg *tplg,return ret; } +/* for unloading it in snd_soc_tplg_component_remove */ + link->dobj.index = tplg->index; + link->dobj.ops = tplg->ops; + link->dobj.type =SND_SOC_DOBJ_BACKEND_LINK ; +list_add (&link->dobj.list, &tplg->comp->dobj_list); +return 0 ; }
@@ -2654,6 +2679,13 @@ int snd_soc_tplg_component_remove(struct snd_soc_component *comp, u32 index)case SND_SOC_DOBJ_DAI_LINK :remove_link (comp, dobj, pass);break ; +case SND_SOC_DOBJ_BACKEND_LINK : +/* +* call link_unload ops if extra +* deinitialization is needed. +*/ +remove_backend_link (comp, dobj, pass); +break ;default :dev_err (comp->dev,"ASoC: invalid component type %d for removal\n" , dobj->type);
Signature · 1 line
2.17.1
Mark Brown
maintainerApplied "ASoC: topology: unload physical dai link in remove" to the asoc tree
The patch
ASoC: topology: unload physical dai link in remove
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All 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
Quoted 1 line
From
adfebb51e1750c5df9e5d42f505b73c5542a879dMon Sep 17 00:00:00 2001
From: Bard liao <[email protected]>
Date: Fri, 1 Feb 2019 11:07:40 -0600
Subject: [PATCH] ASoC: topology: unload physical dai link in remove
soc_tplg_link_config() will find the physical dai link and call soc_tplg_dai_link_load() to load the BE dai link. Currently remove_link() is only used to remove the FE dai link which is created by the topology. The BE dai link cannot however be unloaded in snd_soc_tplg_component _remove(), which is problematic if anything needs to be released or reinitialized.
This patch aligns the definitions of dynamic types with the existing UAPI and adds a new remove_backend_link() routine to unload the the BE dai link when snd_soc_tplg_component_remove() is invoked.
--- include/sound/soc-topology.h | 1 + sound/soc/soc-topology.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)
include/sound/soc-topology.h +1 -0
@@ -45,6 +45,7 @@ enum snd_soc_dobj_type {SND_SOC_DOBJ_DAI_LINK ,SND_SOC_DOBJ_PCM ,SND_SOC_DOBJ_CODEC_LINK , + SND_SOC_DOBJ_BACKEND_LINK, };/* dynamic control object */
sound/soc/soc-topology.c +32 -0
@@ -557,6 +557,25 @@ static void remove_link(struct snd_soc_component *comp,kfree (link); } +/* unload dai link */ +static void remove_backend_link (struct snd_soc_component *comp, +struct snd_soc_dobj *dobj,int pass) +{ +if (pass !=SOC_TPLG_PASS_LINK ) +return ; + +if (dobj->ops && dobj->ops->link_unload) + dobj->ops->link_unload (comp, dobj); + +/* +* We don't free the link here as what remove_link() do since BE +* links are not allocated by topology. +* We however need to reset the dobj type to its initial values +*/ + dobj->type =SND_SOC_DOBJ_NONE ; +list_del (&dobj->list); +} +/* bind a kcontrol to it's IO handlers */ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr, struct snd_kcontrol_new *k,
@@ -2163,6 +2182,12 @@ static int soc_tplg_link_config(struct soc_tplg *tplg,return ret; } +/* for unloading it in snd_soc_tplg_component_remove */ + link->dobj.index = tplg->index; + link->dobj.ops = tplg->ops; + link->dobj.type =SND_SOC_DOBJ_BACKEND_LINK ; +list_add (&link->dobj.list, &tplg->comp->dobj_list); +return 0 ; }
@@ -2649,6 +2674,13 @@ int snd_soc_tplg_component_remove(struct snd_soc_component *comp, u32 index)case SND_SOC_DOBJ_DAI_LINK :remove_link (comp, dobj, pass);break ; +case SND_SOC_DOBJ_BACKEND_LINK : +/* +* call link_unload ops if extra +* deinitialization is needed. +*/ +remove_backend_link (comp, dobj, pass); +break ;default :dev_err (comp->dev,"ASoC: invalid component type %d for removal\n" , dobj->type);
Signature · 1 line
2.20.1