Skip to content

Commit 003b786

Browse files
kv2019ibroonie
authored andcommitted
ASoC: SOF: ipc3-topology: use old pipeline teardown flow with SOF2.1 and older
Originally in commit b2ebcf4 ("ASoC: SOF: free widgets in sof_tear_down_pipelines() for static pipelines"), freeing of pipeline components at suspend was only done with recent FW as there were known limitations in older firmware versions. Tests show that if static pipelines are used, i.e. all pipelines are setup whenever firmware is powered up, the reverse action of freeing all components at power down, leads to firmware failures with also SOF2.0 and SOF2.1 based firmware. The problems can be specific to certain topologies with e.g. components not prepared to be freed at suspend (as this did not happen with older SOF kernels). To avoid hitting these problems when kernel is upgraded and used with an older firmware, bump the firmware requirement to SOF2.2 or newer. If an older firmware is used, and pipeline is a static one, do not free the components at suspend. This ensures the suspend flow remains backwards compatible with older firmware versions. This limitation does not apply if the product configuration is updated to dynamic pipelines. The limitation is not linked to firmware ABI, as the interface to free pipeline components has been available already before ABI3.19. The problem is in the implementation, so firmware version should be used to decide whether it is safe to use the newer flow or not. This patch adds a new SOF_FW_VER() macro to compare SOF firmware release versions. Link: thesofproject/sof#6475 Signed-off-by: Kai Vehmanen <[email protected]> Reviewed-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Ranjani Sridharan <[email protected]> Reviewed-by: Péter Ujfalusi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 5d73263 commit 003b786

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

include/sound/sof/info.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ enum sof_ipc_ext_data {
3636
SOF_IPC_EXT_USER_ABI_INFO = 4,
3737
};
3838

39+
/* Build u32 number in format MMmmmppp */
40+
#define SOF_FW_VER(MAJOR, MINOR, PATCH) ((uint32_t)( \
41+
((MAJOR) << 24) | ((MINOR) << 12) | (PATCH)))
42+
3943
/* FW version - SOF_IPC_GLB_VERSION */
4044
struct sof_ipc_fw_version {
4145
struct sof_ipc_hdr hdr;

sound/soc/sof/ipc3-topology.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,6 +2275,7 @@ static int sof_ipc3_tear_down_all_pipelines(struct snd_sof_dev *sdev, bool verif
22752275
struct sof_ipc_fw_version *v = &sdev->fw_ready.version;
22762276
struct snd_sof_widget *swidget;
22772277
struct snd_sof_route *sroute;
2278+
bool dyn_widgets = false;
22782279
int ret;
22792280

22802281
/*
@@ -2284,12 +2285,14 @@ static int sof_ipc3_tear_down_all_pipelines(struct snd_sof_dev *sdev, bool verif
22842285
* topology loading the sound card unavailable to open PCMs.
22852286
*/
22862287
list_for_each_entry(swidget, &sdev->widget_list, list) {
2287-
if (swidget->dynamic_pipeline_widget)
2288+
if (swidget->dynamic_pipeline_widget) {
2289+
dyn_widgets = true;
22882290
continue;
2291+
}
22892292

2290-
/* Do not free widgets for static pipelines with FW ABI older than 3.19 */
2293+
/* Do not free widgets for static pipelines with FW older than SOF2.2 */
22912294
if (!verify && !swidget->dynamic_pipeline_widget &&
2292-
v->abi_version < SOF_ABI_VER(3, 19, 0)) {
2295+
SOF_FW_VER(v->major, v->minor, v->micro) < SOF_FW_VER(2, 2, 0)) {
22932296
swidget->use_count = 0;
22942297
swidget->complete = 0;
22952298
continue;
@@ -2303,9 +2306,11 @@ static int sof_ipc3_tear_down_all_pipelines(struct snd_sof_dev *sdev, bool verif
23032306
/*
23042307
* Tear down all pipelines associated with PCMs that did not get suspended
23052308
* and unset the prepare flag so that they can be set up again during resume.
2306-
* Skip this step for older firmware.
2309+
* Skip this step for older firmware unless topology has any
2310+
* dynamic pipeline (in which case the step is mandatory).
23072311
*/
2308-
if (!verify && v->abi_version >= SOF_ABI_VER(3, 19, 0)) {
2312+
if (!verify && (dyn_widgets || SOF_FW_VER(v->major, v->minor, v->micro) >=
2313+
SOF_FW_VER(2, 2, 0))) {
23092314
ret = sof_tear_down_left_over_pipelines(sdev);
23102315
if (ret < 0) {
23112316
dev_err(sdev->dev, "failed to tear down paused pipelines\n");

0 commit comments

Comments
 (0)