Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix topology free #261

Merged
merged 2 commits into from
Nov 30, 2018
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
6 changes: 5 additions & 1 deletion sound/soc/sof/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,6 @@ static void sof_pcm_free(struct snd_pcm *pcm)
if (spcm->pcm.capture)
snd_dma_free_pages(&spcm->stream[SNDRV_PCM_STREAM_CAPTURE].page_table);

snd_sof_free_topology(sdev);
}

/* fixup the BE DAI link to match any values from topology */
Expand Down Expand Up @@ -716,7 +715,12 @@ static int sof_pcm_probe(struct snd_soc_component *component)

static void sof_pcm_remove(struct snd_soc_component *component)
{
struct snd_sof_dev *sdev =
snd_soc_component_get_drvdata(component);

pm_runtime_disable(component->dev);
snd_sof_free_topology(sdev);

}

void snd_sof_new_platform_drv(struct snd_sof_dev *sdev)
Expand Down
1 change: 1 addition & 0 deletions sound/soc/sof/sof-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ struct snd_sof_dev {
struct list_head dai_list;
struct list_head route_list;
struct snd_soc_component *component;
int tplg_loaded; /* keep track of topology load success */

/* FW configuration */
struct sof_ipc_dma_buffer_data *info_buffer;
Expand Down
13 changes: 13 additions & 0 deletions sound/soc/sof/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -2603,6 +2603,11 @@ int snd_sof_load_topology(struct snd_sof_dev *sdev, const char *file)
struct snd_soc_tplg_hdr *hdr;
int ret;

if (sdev->tplg_loaded) {
dev_err(sdev->dev, "topology already loaded ?\n");
return -EINVAL;
}

dev_dbg(sdev->dev, "loading topology:%s\n", file);

ret = request_firmware(&fw, file, sdev->dev);
Expand All @@ -2622,6 +2627,8 @@ int snd_sof_load_topology(struct snd_sof_dev *sdev, const char *file)
ret = -EINVAL;
}

sdev->tplg_loaded = true;

release_firmware(fw);
return ret;
}
Expand All @@ -2635,6 +2642,10 @@ void snd_sof_free_topology(struct snd_sof_dev *sdev)
int ret;

dev_dbg(sdev->dev, "free topology...\n");
if (!sdev->tplg_loaded) {
dev_dbg(sdev->dev, "No topology loaded, nothing to free ...\n");
return;
}

/* remove routes */
list_for_each_entry_safe(sroute, temp, &sdev->route_list, list) {
Expand All @@ -2654,5 +2665,7 @@ void snd_sof_free_topology(struct snd_sof_dev *sdev)
if (ret < 0)
dev_err(sdev->dev,
"error: tplg component free failed %d\n", ret);

sdev->tplg_loaded = false;
}
EXPORT_SYMBOL(snd_sof_free_topology);