Skip to content

Commit c0e7969

Browse files
ranj063broonie
authored andcommitted
ASoC: SOF: topology: Add kernel parameter for topology verification
Add a kernel debug flag to enable a one-shot topology verification for all pipelines including the dynamic ones. If the debug flag is set, all the topology component loading will be verified during the complete callback. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://lore.kernel.org/r/20210927120517.20505-13-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 5fcdbb2 commit c0e7969

File tree

5 files changed

+46
-17
lines changed

5 files changed

+46
-17
lines changed

sound/soc/sof/pm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static int sof_resume(struct device *dev, bool runtime_resume)
157157
}
158158

159159
/* restore pipelines */
160-
ret = sof_set_up_pipelines(sdev->dev);
160+
ret = sof_set_up_pipelines(sdev->dev, false);
161161
if (ret < 0) {
162162
dev_err(sdev->dev,
163163
"error: failed to restore pipeline after resume %d\n",
@@ -208,7 +208,7 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
208208
if (target_state == SOF_DSP_PM_D0)
209209
goto suspend;
210210

211-
sof_tear_down_pipelines(dev);
211+
sof_tear_down_pipelines(dev, false);
212212

213213
/* release trace */
214214
snd_sof_release_trace(sdev);

sound/soc/sof/sof-audio.c

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ const struct sof_ipc_pipe_new *snd_sof_pipeline_find(struct snd_sof_dev *sdev,
589589
return NULL;
590590
}
591591

592-
int sof_set_up_pipelines(struct device *dev)
592+
int sof_set_up_pipelines(struct device *dev, bool verify)
593593
{
594594
struct snd_sof_dev *sdev = dev_get_drvdata(dev);
595595
struct snd_sof_widget *swidget;
@@ -599,7 +599,7 @@ int sof_set_up_pipelines(struct device *dev)
599599
/* restore pipeline components */
600600
list_for_each_entry_reverse(swidget, &sdev->widget_list, list) {
601601
/* only set up the widgets belonging to static pipelines */
602-
if (swidget->dynamic_pipeline_widget)
602+
if (!verify && swidget->dynamic_pipeline_widget)
603603
continue;
604604

605605
/* update DAI config. The IPC will be sent in sof_widget_setup() */
@@ -630,8 +630,8 @@ int sof_set_up_pipelines(struct device *dev)
630630
list_for_each_entry(sroute, &sdev->route_list, list) {
631631

632632
/* only set up routes belonging to static pipelines */
633-
if (sroute->src_widget->dynamic_pipeline_widget ||
634-
sroute->sink_widget->dynamic_pipeline_widget)
633+
if (!verify && (sroute->src_widget->dynamic_pipeline_widget ||
634+
sroute->sink_widget->dynamic_pipeline_widget))
635635
continue;
636636

637637
ret = sof_route_setup_ipc(sdev, sroute);
@@ -646,7 +646,7 @@ int sof_set_up_pipelines(struct device *dev)
646646
switch (swidget->id) {
647647
case snd_soc_dapm_scheduler:
648648
/* only complete static pipelines */
649-
if (swidget->dynamic_pipeline_widget)
649+
if (!verify && swidget->dynamic_pipeline_widget)
650650
continue;
651651

652652
swidget->complete =
@@ -661,24 +661,37 @@ int sof_set_up_pipelines(struct device *dev)
661661
}
662662

663663
/*
664-
* This function doesn't free widgets. It only resets the set up status for all routes and
665-
* use_count for all widgets.
664+
* This function doesn't free widgets during suspend. It only resets the set up status for all
665+
* routes and use_count for all widgets.
666666
*/
667-
void sof_tear_down_pipelines(struct device *dev)
667+
int sof_tear_down_pipelines(struct device *dev, bool verify)
668668
{
669669
struct snd_sof_dev *sdev = dev_get_drvdata(dev);
670670
struct snd_sof_widget *swidget;
671671
struct snd_sof_route *sroute;
672+
int ret;
672673

673674
/*
674-
* No need to protect swidget->use_count and sroute->setup as this function is called only
675-
* during the suspend callback and all streams should be suspended by then
675+
* This function is called during suspend and for one-time topology verification during
676+
* first boot. In both cases, there is no need to protect swidget->use_count and
677+
* sroute->setup because during suspend all streams are suspended and during topology
678+
* loading the sound card unavailable to open PCMs.
676679
*/
677-
list_for_each_entry(swidget, &sdev->widget_list, list)
678-
swidget->use_count = 0;
680+
list_for_each_entry_reverse(swidget, &sdev->widget_list, list) {
681+
if (!verify) {
682+
swidget->use_count = 0;
683+
continue;
684+
}
685+
686+
ret = sof_widget_free(sdev, swidget);
687+
if (ret < 0)
688+
return ret;
689+
}
679690

680691
list_for_each_entry(sroute, &sdev->route_list, list)
681692
sroute->setup = false;
693+
694+
return 0;
682695
}
683696

684697
/*

sound/soc/sof/sof-audio.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol,
246246
int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params);
247247

248248
/* PM */
249-
int sof_set_up_pipelines(struct device *dev);
250-
void sof_tear_down_pipelines(struct device *dev);
249+
int sof_set_up_pipelines(struct device *dev, bool verify);
250+
int sof_tear_down_pipelines(struct device *dev, bool verify);
251251
int sof_set_hw_params_upon_resume(struct device *dev);
252252
bool snd_sof_stream_suspend_ignored(struct snd_sof_dev *sdev);
253253
bool snd_sof_dsp_only_d0i3_compatible_stream_active(struct snd_sof_dev *sdev);

sound/soc/sof/sof-priv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
/* debug flags */
2424
#define SOF_DBG_ENABLE_TRACE BIT(0)
2525
#define SOF_DBG_RETAIN_CTX BIT(1) /* prevent DSP D3 on FW exception */
26+
#define SOF_DBG_VERIFY_TPLG BIT(2) /* verify topology during load */
2627

2728
#define SOF_DBG_DUMP_REGS BIT(0)
2829
#define SOF_DBG_DUMP_MBOX BIT(1)

sound/soc/sof/topology.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3452,8 +3452,23 @@ static int sof_complete(struct snd_soc_component *scomp)
34523452
}
34533453
}
34543454

3455+
/* verify topology components loading including dynamic pipelines */
3456+
if (sof_core_debug & SOF_DBG_VERIFY_TPLG) {
3457+
ret = sof_set_up_pipelines(scomp->dev, true);
3458+
if (ret < 0) {
3459+
dev_err(sdev->dev, "error: topology verification failed %d\n", ret);
3460+
return ret;
3461+
}
3462+
3463+
ret = sof_tear_down_pipelines(scomp->dev, true);
3464+
if (ret < 0) {
3465+
dev_err(sdev->dev, "error: topology tear down pipelines failed %d\n", ret);
3466+
return ret;
3467+
}
3468+
}
3469+
34553470
/* set up static pipelines */
3456-
return sof_set_up_pipelines(scomp->dev);
3471+
return sof_set_up_pipelines(scomp->dev, false);
34573472
}
34583473

34593474
/* manifest - optional to inform component of manifest */

0 commit comments

Comments
 (0)