Skip to content

Commit

Permalink
ASoC: SOF: topology: cleanup dailinks on widget unload
Browse files Browse the repository at this point in the history
commit 2074461 upstream.

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/linux#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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
plbossart authored and gregkh committed Apr 27, 2022
1 parent db1002f commit 3b1ef64
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions sound/soc/sof/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,46 @@ static int sof_widget_load_buffer(struct snd_soc_component *scomp, int index,
return 0;
}

static void sof_disconnect_dai_widget(struct snd_soc_component *scomp,
struct snd_soc_dapm_widget *w)
{
struct snd_soc_card *card = scomp->card;
struct snd_soc_pcm_runtime *rtd;
struct snd_soc_dai *cpu_dai;
int i;

if (!w->sname)
return;

list_for_each_entry(rtd, &card->rtd_list, list) {
/* does stream match DAI link ? */
if (!rtd->dai_link->stream_name ||
strcmp(w->sname, rtd->dai_link->stream_name))
continue;

switch (w->id) {
case snd_soc_dapm_dai_out:
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
if (cpu_dai->capture_widget == w) {
cpu_dai->capture_widget = NULL;
break;
}
}
break;
case snd_soc_dapm_dai_in:
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
if (cpu_dai->playback_widget == w) {
cpu_dai->playback_widget = NULL;
break;
}
}
break;
default:
break;
}
}
}

/* bind PCM ID to host component ID */
static int spcm_bind(struct snd_soc_component *scomp, struct snd_sof_pcm *spcm,
int dir)
Expand Down Expand Up @@ -2449,6 +2489,9 @@ static int sof_widget_unload(struct snd_soc_component *scomp,
kfree(dai->dai_config);
list_del(&dai->list);
}

sof_disconnect_dai_widget(scomp, widget);

break;
default:
break;
Expand Down

0 comments on commit 3b1ef64

Please sign in to comment.