Commit c2b10acb authored by Amadeusz Sławiński's avatar Amadeusz Sławiński Committed by Mark Brown

ASoC: Intel: avs: Add assert_static to guarantee ABI sizes

In order to make sure that IPC interface is stable use assert_static to
check union and struct sizes that describe communication interface.
Signed-off-by: default avatarAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
Link: https://msgid.link/r/20240405090929.1184068-13-cezary.rojewski@intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent ff0aefe2
...@@ -381,6 +381,7 @@ struct avs_apl_log_buffer_layout { ...@@ -381,6 +381,7 @@ struct avs_apl_log_buffer_layout {
u32 write_ptr; u32 write_ptr;
u8 buffer[]; u8 buffer[];
} __packed; } __packed;
static_assert(sizeof(struct avs_apl_log_buffer_layout) == 8);
#define avs_apl_log_payload_size(adev) \ #define avs_apl_log_payload_size(adev) \
(avs_log_buffer_size(adev) - sizeof(struct avs_apl_log_buffer_layout)) (avs_log_buffer_size(adev) - sizeof(struct avs_apl_log_buffer_layout))
......
...@@ -52,12 +52,14 @@ union avs_icl_memwnd2_slot_type { ...@@ -52,12 +52,14 @@ union avs_icl_memwnd2_slot_type {
u32 type:24; u32 type:24;
}; };
} __packed; } __packed;
static_assert(sizeof(union avs_icl_memwnd2_slot_type) == 4);
struct avs_icl_memwnd2_desc { struct avs_icl_memwnd2_desc {
u32 resource_id; u32 resource_id;
union avs_icl_memwnd2_slot_type slot_id; union avs_icl_memwnd2_slot_type slot_id;
u32 vma; u32 vma;
} __packed; } __packed;
static_assert(sizeof(struct avs_icl_memwnd2_desc) == 12);
#define AVS_ICL_MEMWND2_SLOTS_COUNT 15 #define AVS_ICL_MEMWND2_SLOTS_COUNT 15
...@@ -68,6 +70,7 @@ struct avs_icl_memwnd2 { ...@@ -68,6 +70,7 @@ struct avs_icl_memwnd2 {
}; };
u8 slot_array[AVS_ICL_MEMWND2_SLOTS_COUNT][SZ_4K]; u8 slot_array[AVS_ICL_MEMWND2_SLOTS_COUNT][SZ_4K];
} __packed; } __packed;
static_assert(sizeof(struct avs_icl_memwnd2) == 65536);
#define AVS_ICL_SLOT_UNUSED \ #define AVS_ICL_SLOT_UNUSED \
((union avs_icl_memwnd2_slot_type) { 0x00000000U }) ((union avs_icl_memwnd2_slot_type) { 0x00000000U })
......
...@@ -56,6 +56,7 @@ struct avs_fw_manifest { ...@@ -56,6 +56,7 @@ struct avs_fw_manifest {
u32 feature_mask; u32 feature_mask;
struct avs_fw_version version; struct avs_fw_version version;
} __packed; } __packed;
static_assert(sizeof(struct avs_fw_manifest) == 36);
struct avs_fw_ext_manifest { struct avs_fw_ext_manifest {
u32 id; u32 id;
...@@ -64,6 +65,7 @@ struct avs_fw_ext_manifest { ...@@ -64,6 +65,7 @@ struct avs_fw_ext_manifest {
u16 version_minor; u16 version_minor;
u32 entries; u32 entries;
} __packed; } __packed;
static_assert(sizeof(struct avs_fw_ext_manifest) == 16);
static int avs_fw_ext_manifest_strip(struct firmware *fw) static int avs_fw_ext_manifest_strip(struct firmware *fw)
{ {
......
...@@ -93,12 +93,14 @@ union avs_global_msg { ...@@ -93,12 +93,14 @@ union avs_global_msg {
} ext; } ext;
}; };
} __packed; } __packed;
static_assert(sizeof(union avs_global_msg) == 8);
struct avs_tlv { struct avs_tlv {
u32 type; u32 type;
u32 length; u32 length;
u32 value[]; u32 value[];
} __packed; } __packed;
static_assert(sizeof(struct avs_tlv) == 8);
enum avs_module_msg_type { enum avs_module_msg_type {
AVS_MOD_INIT_INSTANCE = 0, AVS_MOD_INIT_INSTANCE = 0,
...@@ -155,6 +157,7 @@ union avs_module_msg { ...@@ -155,6 +157,7 @@ union avs_module_msg {
} ext; } ext;
}; };
} __packed; } __packed;
static_assert(sizeof(union avs_module_msg) == 8);
#define AVS_IPC_NOT_SUPPORTED 15 #define AVS_IPC_NOT_SUPPORTED 15
...@@ -190,6 +193,7 @@ union avs_reply_msg { ...@@ -190,6 +193,7 @@ union avs_reply_msg {
} ext; } ext;
}; };
} __packed; } __packed;
static_assert(sizeof(union avs_reply_msg) == 8);
enum avs_notify_msg_type { enum avs_notify_msg_type {
AVS_NOTIFY_PHRASE_DETECTED = 4, AVS_NOTIFY_PHRASE_DETECTED = 4,
...@@ -226,6 +230,7 @@ union avs_notify_msg { ...@@ -226,6 +230,7 @@ union avs_notify_msg {
} ext; } ext;
}; };
} __packed; } __packed;
static_assert(sizeof(union avs_notify_msg) == 8);
#define AVS_MSG(hdr) { .val = hdr } #define AVS_MSG(hdr) { .val = hdr }
...@@ -264,6 +269,7 @@ struct avs_notify_voice_data { ...@@ -264,6 +269,7 @@ struct avs_notify_voice_data {
u16 kpd_score; u16 kpd_score;
u16 reserved; u16 reserved;
} __packed; } __packed;
static_assert(sizeof(struct avs_notify_voice_data) == 4);
struct avs_notify_res_data { struct avs_notify_res_data {
u32 resource_type; u32 resource_type;
...@@ -272,6 +278,7 @@ struct avs_notify_res_data { ...@@ -272,6 +278,7 @@ struct avs_notify_res_data {
u32 reserved; u32 reserved;
u32 data[6]; u32 data[6];
} __packed; } __packed;
static_assert(sizeof(struct avs_notify_res_data) == 40);
struct avs_notify_mod_data { struct avs_notify_mod_data {
u32 module_instance_id; u32 module_instance_id;
...@@ -279,6 +286,7 @@ struct avs_notify_mod_data { ...@@ -279,6 +286,7 @@ struct avs_notify_mod_data {
u32 data_size; u32 data_size;
u32 data[]; u32 data[];
} __packed; } __packed;
static_assert(sizeof(struct avs_notify_mod_data) == 12);
/* ROM messages */ /* ROM messages */
enum avs_rom_control_msg_type { enum avs_rom_control_msg_type {
...@@ -332,6 +340,7 @@ struct avs_dxstate_info { ...@@ -332,6 +340,7 @@ struct avs_dxstate_info {
u32 core_mask; /* which cores are subject for power transition */ u32 core_mask; /* which cores are subject for power transition */
u32 dx_mask; /* bit[n]=1 core n goes to D0, bit[n]=0 it goes to D3 */ u32 dx_mask; /* bit[n]=1 core n goes to D0, bit[n]=0 it goes to D3 */
} __packed; } __packed;
static_assert(sizeof(struct avs_dxstate_info) == 8);
int avs_ipc_set_dx(struct avs_dev *adev, u32 core_mask, bool powerup); int avs_ipc_set_dx(struct avs_dev *adev, u32 core_mask, bool powerup);
int avs_ipc_set_d0ix(struct avs_dev *adev, bool enable_pg, bool streaming); int avs_ipc_set_d0ix(struct avs_dev *adev, bool enable_pg, bool streaming);
...@@ -367,11 +376,13 @@ struct avs_skl_log_state { ...@@ -367,11 +376,13 @@ struct avs_skl_log_state {
u32 enable; u32 enable;
u32 min_priority; u32 min_priority;
} __packed; } __packed;
static_assert(sizeof(struct avs_skl_log_state) == 8);
struct avs_skl_log_state_info { struct avs_skl_log_state_info {
u32 core_mask; u32 core_mask;
struct avs_skl_log_state logs_core[]; struct avs_skl_log_state logs_core[];
} __packed; } __packed;
static_assert(sizeof(struct avs_skl_log_state_info) == 4);
struct avs_apl_log_state_info { struct avs_apl_log_state_info {
u32 aging_timer_period; u32 aging_timer_period;
...@@ -379,6 +390,7 @@ struct avs_apl_log_state_info { ...@@ -379,6 +390,7 @@ struct avs_apl_log_state_info {
u32 core_mask; u32 core_mask;
struct avs_skl_log_state logs_core[]; struct avs_skl_log_state logs_core[];
} __packed; } __packed;
static_assert(sizeof(struct avs_apl_log_state_info) == 12);
enum avs_icl_log_priority { enum avs_icl_log_priority {
AVS_ICL_LOG_CRITICAL = 0, AVS_ICL_LOG_CRITICAL = 0,
...@@ -403,6 +415,7 @@ struct avs_icl_log_state_info { ...@@ -403,6 +415,7 @@ struct avs_icl_log_state_info {
u32 enable; u32 enable;
u32 logs_priorities_mask[]; u32 logs_priorities_mask[];
} __packed; } __packed;
static_assert(sizeof(struct avs_icl_log_state_info) == 12);
int avs_ipc_set_enable_logs(struct avs_dev *adev, u8 *log_info, size_t size); int avs_ipc_set_enable_logs(struct avs_dev *adev, u8 *log_info, size_t size);
...@@ -521,6 +534,7 @@ struct avs_module_type { ...@@ -521,6 +534,7 @@ struct avs_module_type {
u32 lib_code:1; u32 lib_code:1;
u32 rsvd:24; u32 rsvd:24;
} __packed; } __packed;
static_assert(sizeof(struct avs_module_type) == 4);
union avs_segment_flags { union avs_segment_flags {
u32 ul; u32 ul;
...@@ -537,12 +551,14 @@ union avs_segment_flags { ...@@ -537,12 +551,14 @@ union avs_segment_flags {
u32 length:16; u32 length:16;
}; };
} __packed; } __packed;
static_assert(sizeof(union avs_segment_flags) == 4);
struct avs_segment_desc { struct avs_segment_desc {
union avs_segment_flags flags; union avs_segment_flags flags;
u32 v_base_addr; u32 v_base_addr;
u32 file_offset; u32 file_offset;
} __packed; } __packed;
static_assert(sizeof(struct avs_segment_desc) == 12);
struct avs_module_entry { struct avs_module_entry {
u16 module_id; u16 module_id;
...@@ -559,11 +575,13 @@ struct avs_module_entry { ...@@ -559,11 +575,13 @@ struct avs_module_entry {
u16 instance_bss_size; u16 instance_bss_size;
struct avs_segment_desc segments[3]; struct avs_segment_desc segments[3];
} __packed; } __packed;
static_assert(sizeof(struct avs_module_entry) == 116);
struct avs_mods_info { struct avs_mods_info {
u32 count; u32 count;
struct avs_module_entry entries[]; struct avs_module_entry entries[];
} __packed; } __packed;
static_assert(sizeof(struct avs_mods_info) == 4);
static inline bool avs_module_entry_is_loaded(struct avs_module_entry *mentry) static inline bool avs_module_entry_is_loaded(struct avs_module_entry *mentry)
{ {
...@@ -577,6 +595,7 @@ struct avs_sys_time { ...@@ -577,6 +595,7 @@ struct avs_sys_time {
u32 val_l; u32 val_l;
u32 val_u; u32 val_u;
} __packed; } __packed;
static_assert(sizeof(struct avs_sys_time) == 8);
int avs_ipc_set_system_time(struct avs_dev *adev); int avs_ipc_set_system_time(struct avs_dev *adev);
...@@ -680,6 +699,7 @@ struct avs_audio_format { ...@@ -680,6 +699,7 @@ struct avs_audio_format {
u32 sample_type:8; u32 sample_type:8;
u32 reserved:8; u32 reserved:8;
} __packed; } __packed;
static_assert(sizeof(struct avs_audio_format) == 24);
struct avs_modcfg_base { struct avs_modcfg_base {
u32 cpc; u32 cpc;
...@@ -688,12 +708,14 @@ struct avs_modcfg_base { ...@@ -688,12 +708,14 @@ struct avs_modcfg_base {
u32 is_pages; u32 is_pages;
struct avs_audio_format audio_fmt; struct avs_audio_format audio_fmt;
} __packed; } __packed;
static_assert(sizeof(struct avs_modcfg_base) == 40);
struct avs_pin_format { struct avs_pin_format {
u32 pin_index; u32 pin_index;
u32 iobs; u32 iobs;
struct avs_audio_format audio_fmt; struct avs_audio_format audio_fmt;
} __packed; } __packed;
static_assert(sizeof(struct avs_pin_format) == 32);
struct avs_modcfg_ext { struct avs_modcfg_ext {
struct avs_modcfg_base base; struct avs_modcfg_base base;
...@@ -703,6 +725,7 @@ struct avs_modcfg_ext { ...@@ -703,6 +725,7 @@ struct avs_modcfg_ext {
/* input pin formats followed by output ones */ /* input pin formats followed by output ones */
struct avs_pin_format pin_fmts[]; struct avs_pin_format pin_fmts[];
} __packed; } __packed;
static_assert(sizeof(struct avs_modcfg_ext) == 56);
enum avs_dma_type { enum avs_dma_type {
AVS_DMA_HDA_HOST_OUTPUT = 0, AVS_DMA_HDA_HOST_OUTPUT = 0,
...@@ -726,6 +749,7 @@ union avs_virtual_index { ...@@ -726,6 +749,7 @@ union avs_virtual_index {
u8 instance:3; u8 instance:3;
} dmic; } dmic;
} __packed; } __packed;
static_assert(sizeof(union avs_virtual_index) == 1);
union avs_connector_node_id { union avs_connector_node_id {
u32 val; u32 val;
...@@ -735,6 +759,7 @@ union avs_connector_node_id { ...@@ -735,6 +759,7 @@ union avs_connector_node_id {
u32 rsvd:19; u32 rsvd:19;
}; };
} __packed; } __packed;
static_assert(sizeof(union avs_connector_node_id) == 4);
#define INVALID_PIPELINE_ID 0xFF #define INVALID_PIPELINE_ID 0xFF
#define INVALID_NODE_ID \ #define INVALID_NODE_ID \
...@@ -747,6 +772,7 @@ union avs_gtw_attributes { ...@@ -747,6 +772,7 @@ union avs_gtw_attributes {
u32 rsvd:31; u32 rsvd:31;
}; };
} __packed; } __packed;
static_assert(sizeof(union avs_gtw_attributes) == 4);
struct avs_copier_gtw_cfg { struct avs_copier_gtw_cfg {
union avs_connector_node_id node_id; union avs_connector_node_id node_id;
...@@ -757,6 +783,7 @@ struct avs_copier_gtw_cfg { ...@@ -757,6 +783,7 @@ struct avs_copier_gtw_cfg {
DECLARE_FLEX_ARRAY(u32, blob); DECLARE_FLEX_ARRAY(u32, blob);
} config; } config;
} __packed; } __packed;
static_assert(sizeof(struct avs_copier_gtw_cfg) == 16);
struct avs_copier_cfg { struct avs_copier_cfg {
struct avs_modcfg_base base; struct avs_modcfg_base base;
...@@ -764,6 +791,7 @@ struct avs_copier_cfg { ...@@ -764,6 +791,7 @@ struct avs_copier_cfg {
u32 feature_mask; u32 feature_mask;
struct avs_copier_gtw_cfg gtw_cfg; struct avs_copier_gtw_cfg gtw_cfg;
} __packed; } __packed;
static_assert(sizeof(struct avs_copier_cfg) == 84);
struct avs_volume_cfg { struct avs_volume_cfg {
u32 channel_id; u32 channel_id;
...@@ -772,22 +800,26 @@ struct avs_volume_cfg { ...@@ -772,22 +800,26 @@ struct avs_volume_cfg {
u32 reserved; /* alignment */ u32 reserved; /* alignment */
u64 curve_duration; u64 curve_duration;
} __packed; } __packed;
static_assert(sizeof(struct avs_volume_cfg) == 24);
struct avs_peakvol_cfg { struct avs_peakvol_cfg {
struct avs_modcfg_base base; struct avs_modcfg_base base;
struct avs_volume_cfg vols[]; struct avs_volume_cfg vols[];
} __packed; } __packed;
static_assert(sizeof(struct avs_peakvol_cfg) == 40);
struct avs_micsel_cfg { struct avs_micsel_cfg {
struct avs_modcfg_base base; struct avs_modcfg_base base;
struct avs_audio_format out_fmt; struct avs_audio_format out_fmt;
} __packed; } __packed;
static_assert(sizeof(struct avs_micsel_cfg) == 64);
struct avs_mux_cfg { struct avs_mux_cfg {
struct avs_modcfg_base base; struct avs_modcfg_base base;
struct avs_audio_format ref_fmt; struct avs_audio_format ref_fmt;
struct avs_audio_format out_fmt; struct avs_audio_format out_fmt;
} __packed; } __packed;
static_assert(sizeof(struct avs_mux_cfg) == 88);
struct avs_updown_mixer_cfg { struct avs_updown_mixer_cfg {
struct avs_modcfg_base base; struct avs_modcfg_base base;
...@@ -796,21 +828,25 @@ struct avs_updown_mixer_cfg { ...@@ -796,21 +828,25 @@ struct avs_updown_mixer_cfg {
s32 coefficients[AVS_CHANNELS_MAX]; s32 coefficients[AVS_CHANNELS_MAX];
u32 channel_map; u32 channel_map;
} __packed; } __packed;
static_assert(sizeof(struct avs_updown_mixer_cfg) == 84);
struct avs_src_cfg { struct avs_src_cfg {
struct avs_modcfg_base base; struct avs_modcfg_base base;
u32 out_freq; u32 out_freq;
} __packed; } __packed;
static_assert(sizeof(struct avs_src_cfg) == 44);
struct avs_probe_gtw_cfg { struct avs_probe_gtw_cfg {
union avs_connector_node_id node_id; union avs_connector_node_id node_id;
u32 dma_buffer_size; u32 dma_buffer_size;
} __packed; } __packed;
static_assert(sizeof(struct avs_probe_gtw_cfg) == 8);
struct avs_probe_cfg { struct avs_probe_cfg {
struct avs_modcfg_base base; struct avs_modcfg_base base;
struct avs_probe_gtw_cfg gtw_cfg; struct avs_probe_gtw_cfg gtw_cfg;
} __packed; } __packed;
static_assert(sizeof(struct avs_probe_cfg) == 48);
struct avs_aec_cfg { struct avs_aec_cfg {
struct avs_modcfg_base base; struct avs_modcfg_base base;
...@@ -818,6 +854,7 @@ struct avs_aec_cfg { ...@@ -818,6 +854,7 @@ struct avs_aec_cfg {
struct avs_audio_format out_fmt; struct avs_audio_format out_fmt;
u32 cpc_lp_mode; u32 cpc_lp_mode;
} __packed; } __packed;
static_assert(sizeof(struct avs_aec_cfg) == 92);
struct avs_asrc_cfg { struct avs_asrc_cfg {
struct avs_modcfg_base base; struct avs_modcfg_base base;
...@@ -828,11 +865,13 @@ struct avs_asrc_cfg { ...@@ -828,11 +865,13 @@ struct avs_asrc_cfg {
u32 disable_jitter_buffer:1; u32 disable_jitter_buffer:1;
u32 rsvd3:27; u32 rsvd3:27;
} __packed; } __packed;
static_assert(sizeof(struct avs_asrc_cfg) == 48);
struct avs_wov_cfg { struct avs_wov_cfg {
struct avs_modcfg_base base; struct avs_modcfg_base base;
u32 cpc_lp_mode; u32 cpc_lp_mode;
} __packed; } __packed;
static_assert(sizeof(struct avs_wov_cfg) == 44);
/* Module runtime parameters */ /* Module runtime parameters */
...@@ -845,6 +884,7 @@ struct avs_copier_sink_format { ...@@ -845,6 +884,7 @@ struct avs_copier_sink_format {
struct avs_audio_format src_fmt; struct avs_audio_format src_fmt;
struct avs_audio_format sink_fmt; struct avs_audio_format sink_fmt;
} __packed; } __packed;
static_assert(sizeof(struct avs_copier_sink_format) == 52);
int avs_ipc_copier_set_sink_format(struct avs_dev *adev, u16 module_id, int avs_ipc_copier_set_sink_format(struct avs_dev *adev, u16 module_id,
u8 instance_id, u32 sink_id, u8 instance_id, u32 sink_id,
...@@ -878,6 +918,7 @@ struct avs_probe_dma { ...@@ -878,6 +918,7 @@ struct avs_probe_dma {
union avs_connector_node_id node_id; union avs_connector_node_id node_id;
u32 dma_buffer_size; u32 dma_buffer_size;
} __packed; } __packed;
static_assert(sizeof(struct avs_probe_dma) == 8);
enum avs_probe_type { enum avs_probe_type {
AVS_PROBE_TYPE_INPUT = 0, AVS_PROBE_TYPE_INPUT = 0,
...@@ -894,6 +935,7 @@ union avs_probe_point_id { ...@@ -894,6 +935,7 @@ union avs_probe_point_id {
u32 index:6; u32 index:6;
} id; } id;
} __packed; } __packed;
static_assert(sizeof(union avs_probe_point_id) == 4);
enum avs_connection_purpose { enum avs_connection_purpose {
AVS_CONNECTION_PURPOSE_EXTRACT = 0, AVS_CONNECTION_PURPOSE_EXTRACT = 0,
...@@ -906,6 +948,7 @@ struct avs_probe_point_desc { ...@@ -906,6 +948,7 @@ struct avs_probe_point_desc {
u32 purpose; u32 purpose;
union avs_connector_node_id node_id; union avs_connector_node_id node_id;
} __packed; } __packed;
static_assert(sizeof(struct avs_probe_point_desc) == 12);
int avs_ipc_probe_get_dma(struct avs_dev *adev, struct avs_probe_dma **dmas, size_t *num_dmas); int avs_ipc_probe_get_dma(struct avs_dev *adev, struct avs_probe_dma **dmas, size_t *num_dmas);
int avs_ipc_probe_attach_dma(struct avs_dev *adev, struct avs_probe_dma *dmas, size_t num_dmas); int avs_ipc_probe_attach_dma(struct avs_dev *adev, struct avs_probe_dma *dmas, size_t num_dmas);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment