Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/sound/soc-topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum snd_soc_dobj_type {
SND_SOC_DOBJ_DAI_LINK,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix commit message
"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.
"

SND_SOC_DOBJ_PCM,
SND_SOC_DOBJ_CODEC_LINK,
SND_SOC_DOBJ_BACKEND_LINK,
};

/* dynamic control object */
Expand Down
34 changes: 34 additions & 0 deletions sound/soc/soc-topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,24 @@ 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;
Comment thread
plbossart marked this conversation as resolved.
Resolved

if (dobj->ops && dobj->ops->link_unload)
dobj->ops->link_unload(comp, dobj);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment here on why this is different from remove_link().

/*
* We don't free the link here as what remove_link() do since BE
* links are not allocated by topology.
*/

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,
Expand Down Expand Up @@ -1651,6 +1669,9 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg,
if (ret < 0)
goto ready_err;

kfree(template.sname);
kfree(template.name);

return 0;

ready_err:
Expand Down Expand Up @@ -2161,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;
}

Expand Down Expand Up @@ -2647,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;
Comment thread
plbossart marked this conversation as resolved.
Resolved
default:
dev_err(comp->dev, "ASoC: invalid component type %d for removal\n",
dobj->type);
Expand Down
4 changes: 4 additions & 0 deletions sound/soc/sof/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -2446,6 +2446,10 @@ static int sof_link_unload(struct snd_soc_component *scomp,
struct snd_sof_dai *sof_dai = NULL;
int ret = 0;

/* only BE link is loaded by sof */
if (!link->no_pcm)
return 0;

list_for_each_entry(sof_dai, &sdev->dai_list, list) {
if (!sof_dai->name)
continue;
Expand Down