Skip to content

Commit 2074461

Browse files
plbossartbroonie
authored andcommitted
ASoC: SOF: topology: cleanup dailinks on widget unload
We set the cpu_dai capture_ or playback_widget on widget_ready but never clear them, which leads to failures when unloading/reloading a topology in modprobe/rmmod tests BugLink: thesofproject#3535 Fixes: 311ce4f ("ASoC: SOF: Add support for loading topologies") Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220406191606.254576-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 770f3d9 commit 2074461

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

sound/soc/sof/topology.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,46 @@ static int sof_connect_dai_widget(struct snd_soc_component *scomp,
10701070
return 0;
10711071
}
10721072

1073+
static void sof_disconnect_dai_widget(struct snd_soc_component *scomp,
1074+
struct snd_soc_dapm_widget *w)
1075+
{
1076+
struct snd_soc_card *card = scomp->card;
1077+
struct snd_soc_pcm_runtime *rtd;
1078+
struct snd_soc_dai *cpu_dai;
1079+
int i;
1080+
1081+
if (!w->sname)
1082+
return;
1083+
1084+
list_for_each_entry(rtd, &card->rtd_list, list) {
1085+
/* does stream match DAI link ? */
1086+
if (!rtd->dai_link->stream_name ||
1087+
strcmp(w->sname, rtd->dai_link->stream_name))
1088+
continue;
1089+
1090+
switch (w->id) {
1091+
case snd_soc_dapm_dai_out:
1092+
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
1093+
if (cpu_dai->capture_widget == w) {
1094+
cpu_dai->capture_widget = NULL;
1095+
break;
1096+
}
1097+
}
1098+
break;
1099+
case snd_soc_dapm_dai_in:
1100+
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
1101+
if (cpu_dai->playback_widget == w) {
1102+
cpu_dai->playback_widget = NULL;
1103+
break;
1104+
}
1105+
}
1106+
break;
1107+
default:
1108+
break;
1109+
}
1110+
}
1111+
}
1112+
10731113
/* bind PCM ID to host component ID */
10741114
static int spcm_bind(struct snd_soc_component *scomp, struct snd_sof_pcm *spcm,
10751115
int dir)
@@ -1355,6 +1395,9 @@ static int sof_widget_unload(struct snd_soc_component *scomp,
13551395

13561396
if (dai)
13571397
list_del(&dai->list);
1398+
1399+
sof_disconnect_dai_widget(scomp, widget);
1400+
13581401
break;
13591402
default:
13601403
break;

0 commit comments

Comments
 (0)