Skip to content

Commit 2f3a187

Browse files
committed
ASoC: SOF: rework FW ABI version handling on kernel side
The definitions in sof/abi.h have been a verbatim copy of the firmware header definition. The header also defines a version and this has caused issues: - kernel declares one version but as the interface supports backwards-compatible minor version updates, many firmware versions can be supported by any one kernel - a single firmware MINOR version bump can cover multiple changes to the interface and this can cause complex dependencies to kernel patch backporting as kernel will have multiple commits to support extensions identified by a single MAJOR.MINOR version of firwmare To improve the situation, move all version information out from the shared header and define version as part of the implementation. Add local definitions to ipc.c, topology.c and loader.c. These versions will be updated when the implementation is updated. E.g. when a new token type is added to topology parser, the version is updated in topology.c to reflect this. BugLink: thesofproject/sof#4986 Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 7658378 commit 2f3a187

4 files changed

Lines changed: 23 additions & 36 deletions

File tree

include/uapi/sound/sof/abi.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,9 @@
66
* Copyright(c) 2018 Intel Corporation. All rights reserved.
77
*/
88

9-
/**
10-
* SOF ABI versioning is based on Semantic Versioning where we have a given
11-
* MAJOR.MINOR.PATCH version number. See https://semver.org/
12-
*
13-
* Rules for incrementing or changing version :-
14-
*
15-
* 1) Increment MAJOR version if you make incompatible API changes. MINOR and
16-
* PATCH should be reset to 0.
17-
*
18-
* 2) Increment MINOR version if you add backwards compatible features or
19-
* changes. PATCH should be reset to 0.
20-
*
21-
* 3) Increment PATCH version if you add backwards compatible bug fixes.
22-
*/
23-
249
#ifndef __INCLUDE_UAPI_SOUND_SOF_ABI_H__
2510
#define __INCLUDE_UAPI_SOUND_SOF_ABI_H__
2611

27-
/* SOF ABI version major, minor and patch numbers */
28-
#define SOF_ABI_MAJOR 3
29-
#define SOF_ABI_MINOR 18
30-
#define SOF_ABI_PATCH 0
31-
3212
/* SOF ABI version number. Format within 32bit word is MMmmmppp */
3313
#define SOF_ABI_MAJOR_SHIFT 24
3414
#define SOF_ABI_MAJOR_MASK 0xff
@@ -54,8 +34,6 @@
5434
SOF_ABI_VERSION_MAJOR((client_ver)) \
5535
)
5636

57-
#define SOF_ABI_VERSION SOF_ABI_VER(SOF_ABI_MAJOR, SOF_ABI_MINOR, SOF_ABI_PATCH)
58-
5937
/* SOF ABI magic number "SOF\0". */
6038
#define SOF_ABI_MAGIC 0x00464F53
6139

sound/soc/sof/control.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#include "sof-priv.h"
1616
#include "sof-audio.h"
1717

18+
/* IPC interface version implemented for control */
19+
#define SOF_ABI_VERSION SOF_ABI_VER(3, 18, 0)
20+
1821
static void update_mute_led(struct snd_sof_control *scontrol,
1922
struct snd_kcontrol *kcontrol,
2023
struct snd_ctl_elem_value *ucontrol)

sound/soc/sof/ipc.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ struct sof_ipc_ctrl_data_params {
3737
u8 *dst;
3838
};
3939

40+
/* IPC interface version implemented */
41+
#define SOF_ABI_MAJOR 3
42+
#define SOF_ABI_MINOR 18
43+
#define SOF_ABI_PATCH 0
44+
#define SOF_ABI_VERSION SOF_ABI_VER(SOF_ABI_MAJOR, SOF_ABI_MINOR, SOF_ABI_PATCH)
45+
4046
#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_VERBOSE_IPC)
4147
static void ipc_log_header(struct device *dev, u8 *text, u32 cmd)
4248
{
@@ -958,13 +964,10 @@ int snd_sof_ipc_valid(struct snd_sof_dev *sdev)
958964
return -EINVAL;
959965
}
960966

961-
if (SOF_ABI_VERSION_MINOR(v->abi_version) > SOF_ABI_MINOR) {
962-
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_STRICT_ABI_CHECKS)) {
963-
dev_warn(sdev->dev, "warn: FW ABI is more recent than kernel\n");
964-
} else {
965-
dev_err(sdev->dev, "error: FW ABI is more recent than kernel\n");
966-
return -EINVAL;
967-
}
967+
if (IS_ENABLED(CONFIG_SND_SOC_SOF_STRICT_ABI_CHECKS) &&
968+
SOF_ABI_VERSION_MINOR(v->abi_version) > SOF_ABI_MINOR) {
969+
dev_err(sdev->dev, "error: FW ABI is more recent than kernel\n");
970+
return -EINVAL;
968971
}
969972

970973
if (ready->flags & SOF_IPC_INFO_BUILD) {

sound/soc/sof/topology.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
/* size of tplg abi in byte */
4848
#define SOF_TPLG_ABI_SIZE 3
4949

50+
/* IPC interface version implemented for topology parsing */
51+
#define SOF_ABI_MAJOR 3
52+
#define SOF_ABI_MINOR 18
53+
#define SOF_ABI_PATCH 0
54+
#define SOF_ABI_VERSION SOF_ABI_VER(SOF_ABI_MAJOR, SOF_ABI_MINOR, SOF_ABI_PATCH)
55+
5056
struct sof_widget_data {
5157
int ctrl_type;
5258
int ipc_cmd;
@@ -3595,13 +3601,10 @@ static int sof_manifest(struct snd_soc_component *scomp, int index,
35953601
return -EINVAL;
35963602
}
35973603

3598-
if (SOF_ABI_VERSION_MINOR(abi_version) > SOF_ABI_MINOR) {
3599-
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_STRICT_ABI_CHECKS)) {
3600-
dev_warn(scomp->dev, "warn: topology ABI is more recent than kernel\n");
3601-
} else {
3602-
dev_err(scomp->dev, "error: topology ABI is more recent than kernel\n");
3603-
return -EINVAL;
3604-
}
3604+
if (IS_ENABLED(CONFIG_SND_SOC_SOF_STRICT_ABI_CHECKS) &&
3605+
SOF_ABI_VERSION_MINOR(abi_version) > SOF_ABI_MINOR) {
3606+
dev_err(scomp->dev, "topology ABI is more recent than kernel\n");
3607+
return -EINVAL;
36053608
}
36063609

36073610
return 0;

0 commit comments

Comments
 (0)