ASoC: SOF: Add IPC4 FW loader support
Subsystems (3)
cover ASoC: SOF: Add IPC4 FW loader support
The patches in this series add support for FW loading for IPC4 in the SOF driver.
Ranjani Sridharan (5):
ASoC: SOF: Intel: HDA: Set IPC4-specific DSP ops for CaVS platforms
ASoC: SOF: Add IPC4 private header
ASoC: SOF: Add header for IPC4 manifest
ASoC: SOF: IPC4: Add FW loader ops
ASoC: SOF: Intel: HDA: Set up sof_ipc4_fw_data for IPC4
include/sound/sof/ext_manifest4.h | 119 +++++++++++++++++ sound/soc/sof/Makefile | 2 +- sound/soc/sof/intel/apl.c | 29 ++++- sound/soc/sof/intel/cnl.c | 109 +++++++++++++++- sound/soc/sof/intel/hda-ipc.c | 82 ++++++++++++ sound/soc/sof/intel/hda.h | 6 + sound/soc/sof/intel/tgl.c | 29 ++++- sound/soc/sof/ipc4-loader.c | 210 ++++++++++++++++++++++++++++++ sound/soc/sof/ipc4-priv.h | 44 +++++++ sound/soc/sof/ipc4.c | 2 + 10 files changed, 619 insertions(+), 13 deletions(-) create mode 100644 include/sound/sof/ext_manifest4.h create mode 100644 sound/soc/sof/ipc4-loader.c create mode 100644 sound/soc/sof/ipc4-priv.h
Signature · 1 line
2.25.1
PATCH 1/5 ASoC: SOF: Intel: HDA: Set IPC4-specific DSP ops for CaVS platforms
Add implementation of low level, platform dependent IPC4 message handling and set the DSP ops for IPC4 for APL, CNL and TGL platforms.
--- sound/soc/sof/intel/apl.c | 17 ++++-- sound/soc/sof/intel/cnl.c | 97 +++++++++++++++++++++++++++++++++-- sound/soc/sof/intel/hda-ipc.c | 82 +++++++++++++++++++++++++++++ sound/soc/sof/intel/hda.h | 6 +++ sound/soc/sof/intel/tgl.c | 18 +++++-- 5 files changed, 208 insertions(+), 12 deletions(-)
sound/soc/sof/intel/apl.c +13 -4
@@ -37,11 +37,20 @@ int sof_apl_ops_init(struct snd_sof_dev *sdev)/* probe/remove/shutdown */ sof_apl_ops.shutdown = hda_dsp_shutdown; -/* doorbell */ - sof_apl_ops.irq_thread = hda_dsp_ipc_irq_thread; +if (sdev->pdata->ipc_type ==SOF_IPC ) { +/* doorbell */ + sof_apl_ops.irq_thread = hda_dsp_ipc_irq_thread; -/* ipc */ - sof_apl_ops.send_msg = hda_dsp_ipc_send_msg; +/* ipc */ + sof_apl_ops.send_msg = hda_dsp_ipc_send_msg; + } + +if (sdev->pdata->ipc_type ==SOF_INTEL_IPC4 ) { + sof_apl_ops.irq_thread = hda_dsp_ipc4_irq_thread; + +/* ipc */ + sof_apl_ops.send_msg = hda_dsp_ipc4_send_msg; + }/* set DAI driver ops */ hda_set_dai_drv_ops (sdev, &sof_apl_ops);
sound/soc/sof/intel/cnl.c +93 -4
122 lines not on this page · raw message
sound/soc/sof/intel/hda-ipc.c +82 -0
100 lines not on this page · raw message
sound/soc/sof/intel/hda.h +6 -0
@@ -764,4 +764,10 @@ extern int sof_hda_position_quirk;void hda_set_dai_drv_ops (struct snd_sof_dev *sdev,struct snd_sof_dsp_ops *ops); +/* IPC4 */ +irqreturn_t cnl_ipc4_irq_thread (int irq,void *context); +int cnl_ipc4_send_msg (struct snd_sof_dev *sdev,struct snd_sof_ipc_msg *msg); +irqreturn_t hda_dsp_ipc4_irq_thread (int irq,void *context); +int hda_dsp_ipc4_send_msg (struct snd_sof_dev *sdev,struct snd_sof_ipc_msg *msg); +#endif
sound/soc/sof/intel/tgl.c +14 -4
@@ -70,11 +70,21 @@ int sof_tgl_ops_init(struct snd_sof_dev *sdev)/* probe/remove/shutdown */ sof_tgl_ops.shutdown = hda_dsp_shutdown; -/* doorbell */ - sof_tgl_ops.irq_thread = cnl_ipc_irq_thread; +if (sdev->pdata->ipc_type ==SOF_IPC ) { +/* doorbell */ + sof_tgl_ops.irq_thread = cnl_ipc_irq_thread; -/* ipc */ - sof_tgl_ops.send_msg = cnl_ipc_send_msg; +/* ipc */ + sof_tgl_ops.send_msg = cnl_ipc_send_msg; + } + +if (sdev->pdata->ipc_type ==SOF_INTEL_IPC4 ) { +/* doorbell */ + sof_tgl_ops.irq_thread = cnl_ipc4_irq_thread; + +/* ipc */ + sof_tgl_ops.send_msg = cnl_ipc4_send_msg; + }/* set DAI driver ops */ hda_set_dai_drv_ops (sdev, &sof_tgl_ops);
Signature · 1 line
2.25.1
PATCH 2/5 ASoC: SOF: Add IPC4 private header
In reply to Ranjani SridharanAdd a struct sof_ipc4_fw_data to hold the firmware module data and manifest FW header offset.
The FW reports data about the modules supported by the base FW in its manifest and the FW header offset is platform dependent information.
This structure will be allocated when the ops are initialized for each platform and populated when the FW is loaded.
--- sound/soc/sof/ipc4-priv.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 sound/soc/sof/ipc4-priv.h
sound/soc/sof/ipc4-priv.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ +/* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* Copyright(c) 2022 Intel Corporation. All rights reserved. +*/ + +#ifndef __SOUND_SOC_SOF_IPC4_PRIV_H +#define __SOUND_SOC_SOF_IPC4_PRIV_H + +#include <linux/idr.h> +#include "sof-priv.h" + +/** +* struct sof_ipc4_fw_data - IPC4-specific data +* @manifest_fw_hdr_offset: FW header offset in the manifest +* @num_fw_modules : Number of modules in base FW +* @fw_modules: Array of base FW modules +*/ +struct sof_ipc4_fw_data { +u32 manifest_fw_hdr_offset; +int num_fw_modules; +void *fw_modules; +}; + +#endif
Signature · 1 line
2.25.1
PATCH 3/5 ASoC: SOF: Add header for IPC4 manifest
In reply to Ranjani SridharanAdd the header for the IPC4 manifest.
--- include/sound/sof/ext_manifest4.h | 119 ++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 include/sound/sof/ext_manifest4.h
include/sound/sof/ext_manifest4.h new file +119 -0
@@ -0,0 +1,119 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* Copyright(c) 2022 Intel Corporation. All rights reserved. +*/ + +/* +* Extended manifest is a place to store metadata about firmware, known during +* compilation time - for example firmware version or used compiler. +* Given information are read on host side before firmware startup. +* This part of output binary is not signed. +*/ + +#ifndef __SOF_FIRMWARE_EXT_MANIFEST4_H__ +#define __SOF_FIRMWARE_EXT_MANIFEST4_H__ + +#include <linux/uuid.h> + +/* In ASCII $AE1 */ +#define SOF_EXT_MAN4_MAGIC_NUMBER 0x31454124 + +#define MAX_MODULE_NAME_LEN 8 +#define MAX_FW_BINARY_NAME 8 +#define DEFAULT_HASH_SHA256_LEN 32 +#define SOF_MAN4_FW_HDR_OFFSET 0x2000 +#define SOF_MAN4_FW_HDR_OFFSET_CAVS_1_5 0x284 + +/********************************************************************* +* extended manifest (struct sof_ext_manifest4_hdr) +*------------------- +* css_manifest hdr +*------------------- +* offset reserved for future +*------------------- +* fw_hdr (struct sof_man4_fw_binary_header) +*------------------- +* module_entry[0] (struct sof_man4_module) +*------------------- +* module_entry[1] +*------------------- +* ... +*------------------- +* module_entry[n] +*------------------- +* module_config[0] (struct sof_man4_module_config) +*------------------- +* module_config[1] +*------------------- +* ... +*------------------- +* module_config[m] +*------------------- +* FW content +*------------------- +*********************************************************************/ + +struct sof_ext_manifest4_hdr { +uint32_t id; +uint32_t len;/* length of extension manifest */ +uint16_t version_major;/* header version */ +uint16_t version_minor; +uint32_t num_module_entries; +} __packed; + +struct sof_man4_fw_binary_header { +/* This part must be unchanged to be backward compatible with SPT-LP ROM */ +uint32_t id; +uint32_t len;/* sizeof(sof_man4_fw_binary_header) in bytes */ +uint8_t name[MAX_FW_BINARY_NAME ]; +uint32_t preload_page_count;/* number of pages of preloaded image */ +uint32_t fw_image_flags; +uint32_t feature_mask; +uint16_t major_version;/* Firmware version */ +uint16_t minor_version; +uint16_t hotfix_version; +uint16_t build_version; +uint32_t num_module_entries; + +/* This part may change to contain any additional data for BaseFw that is skipped by ROM */ +uint32_t hw_buf_base_addr; +uint32_t hw_buf_length; +uint32_t load_offset;/* This value is used by ROM */ +} __packed; + +struct sof_man4_segment_desc { +uint32_t flags; +uint32_t v_base_addr; +uint32_t file_offset; +} __packed; + +struct sof_man4_module { +uint32_t id; +uint8_t name[MAX_MODULE_NAME_LEN ]; +guid_t uuid; +uint32_t type; +uint8_t hash[DEFAULT_HASH_SHA256_LEN ]; +uint32_t entry_point; +uint16_t cfg_offset; +uint16_t cfg_count; +uint32_t affinity_mask; +uint16_t instance_max_count; +uint16_t instance_stack_size; +struct sof_man4_segment_desc segments[3 ]; +} __packed; + +struct sof_man4_module_config { +uint32_t par[4 ];/* module parameters */ +uint32_t is_bytes;/* actual size of instance .bss (bytes) */ +uint32_t cps;/* cycles per second */ +uint32_t ibs;/* input buffer size (bytes) */ +uint32_t obs;/* output buffer size (bytes) */ +uint32_t module_flags;/* flags, reserved for future use */ +uint32_t cpc;/* cycles per single run */ +uint32_t obls;/* output block size, reserved for future use */ +} __packed; + +#endif /* __SOF_FIRMWARE_EXT_MANIFEST4_H__ */
Signature · 1 line
2.25.1
PATCH 4/5 ASoC: SOF: IPC4: Add FW loader ops
In reply to Ranjani SridharanDefine and add the FW loader ops for IPC4. Also, introduce a new structure, struct sof_ipc4_private_data that will be used to define some IPC4-sepcific data.
--- sound/soc/sof/Makefile | 2 +- sound/soc/sof/ipc4-loader.c | 210 ++++++++++++++++++++++++++++++++++++ sound/soc/sof/ipc4-priv.h | 17 +++ sound/soc/sof/ipc4.c | 2 + 4 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 sound/soc/sof/ipc4-loader.c
sound/soc/sof/Makefile +1 -1
@@ -3,7 +3,7 @@ snd-sof-objs := core.o ops.o loader.o ipc.o pcm.o pm.o debug.o topology.o\ control.o trace.o iomem-utils.o sof-audio.o stream-ipc.o\ ipc3-topology.o ipc3-control.o ipc3.o ipc3-pcm.o ipc3-loader.o\ - ipc4.o + ipc4.o ipc4-loader.o ifneq ($(CONFIG_SND_SOC_SOF_CLIENT),) snd-sof-objs += sof-client.o endif
sound/soc/sof/ipc4-loader.c new file +210 -0
210 lines not on this page · raw message
sound/soc/sof/ipc4-priv.h +17 -0
@@ -10,6 +10,7 @@#define __SOUND_SOC_SOF_IPC4_PRIV_H#include <linux/idr.h> +#include <sound/sof/ext_manifest4.h> #include "sof-priv.h" /**
@@ -24,4 +25,20 @@ struct sof_ipc4_fw_data { void *fw_modules; }; +/** +* struct sof_ipc4_fw_module - IPC4 module info +* @sof_man4_module : Module info +* @m_ida: Module instance identifier +* @bss_size: Module object size +* @private: Module private data +*/ +struct sof_ipc4_fw_module { +struct sof_man4_module man4_module_entry; +struct ida m_ida; +u32 bss_size; +void *private; +}; + +extern const struct sof_ipc_fw_loader_ops ipc4_loader_ops; +#endif
sound/soc/sof/ipc4.c +2 -0
@@ -12,6 +12,7 @@#include <sound/sof/ipc4/header.h> #include "sof-priv.h" #include "sof-audio.h" +#include "ipc4-priv.h" #include "ops.h" #ifdef DEBUG_VERBOSE
@@ -601,4 +602,5 @@ const struct sof_ipc_ops ipc4_ops = { .rx_msg = sof_ipc4_rx_msg, .set_get_data = sof_ipc4_set_get_data, .get_reply = sof_ipc4_get_reply, + .fw_loader = &ipc4_loader_ops, };
Signature · 1 line
2.25.1
PATCH 5/5 ASoC: SOF: Intel: HDA: Set up sof_ipc4_fw_data for IPC4
In reply to Ranjani SridharanAllocate the sof_ipc4_fw_data struct for IPC4 and set the fw header offset for the platforms which will be used by the core when loading the firmware image.
The core expects that the "private" field in struct snd_sof_dev (which is unused today with IPC3) is used to save this data.
--- sound/soc/sof/intel/apl.c | 12 ++++++++++++ sound/soc/sof/intel/cnl.c | 12 ++++++++++++ sound/soc/sof/intel/tgl.c | 11 +++++++++++ 3 files changed, 35 insertions(+)
sound/soc/sof/intel/apl.c +12 -0
@@ -15,6 +15,8 @@* Hardware interface for audio DSP on Apollolake and GeminiLake */ +#include <sound/sof/ext_manifest4.h> +#include "../ipc4-priv.h" #include "../sof-priv.h" #include "hda.h" #include "../sof-audio.h"
@@ -46,6 +48,16 @@ int sof_apl_ops_init(struct snd_sof_dev *sdev) }if (sdev->pdata->ipc_type ==SOF_INTEL_IPC4 ) { +struct sof_ipc4_fw_data *ipc4_data; + + sdev->private =devm_kzalloc (sdev->dev,sizeof (*ipc4_data),GFP_KERNEL ); +if (!sdev->private) +return -ENOMEM ; + + ipc4_data = sdev->private; + ipc4_data->manifest_fw_hdr_offset =SOF_MAN4_FW_HDR_OFFSET ; + +/* doorbell */ sof_apl_ops.irq_thread = hda_dsp_ipc4_irq_thread;/* ipc */
sound/soc/sof/intel/cnl.c +12 -0
@@ -15,7 +15,9 @@* Hardware interface for audio DSP on Cannonlake. */ +#include <sound/sof/ext_manifest4.h> #include <sound/sof/ipc4/header.h> +#include "../ipc4-priv.h" #include "../ops.h" #include "hda.h" #include "hda-ipc.h"
@@ -344,6 +346,16 @@ int sof_cnl_ops_init(struct snd_sof_dev *sdev) }if (sdev->pdata->ipc_type ==SOF_INTEL_IPC4 ) { +struct sof_ipc4_fw_data *ipc4_data; + + sdev->private =devm_kzalloc (sdev->dev,sizeof (*ipc4_data),GFP_KERNEL ); +if (!sdev->private) +return -ENOMEM ; + + ipc4_data = sdev->private; + ipc4_data->manifest_fw_hdr_offset =SOF_MAN4_FW_HDR_OFFSET ; + +/* doorbell */ sof_cnl_ops.irq_thread = cnl_ipc4_irq_thread;/* ipc */
sound/soc/sof/intel/tgl.c +11 -0
@@ -9,6 +9,8 @@* Hardware interface for audio DSP on Tigerlake. */ +#include <sound/sof/ext_manifest4.h> +#include "../ipc4-priv.h" #include "../ops.h" #include "hda.h" #include "hda-ipc.h"
@@ -79,6 +81,15 @@ int sof_tgl_ops_init(struct snd_sof_dev *sdev) }if (sdev->pdata->ipc_type ==SOF_INTEL_IPC4 ) { +struct sof_ipc4_fw_data *ipc4_data; + + sdev->private =devm_kzalloc (sdev->dev,sizeof (*ipc4_data),GFP_KERNEL ); +if (!sdev->private) +return -ENOMEM ; + + ipc4_data = sdev->private; + ipc4_data->manifest_fw_hdr_offset =SOF_MAN4_FW_HDR_OFFSET ; +/* doorbell */ sof_tgl_ops.irq_thread = cnl_ipc4_irq_thread;
Signature · 1 line
2.25.1
Mark Brown
maintainerQuoted 11 lines · Ranjani Sridharan
The patches in this series add support for FW loading for IPC4 in the SOF driver.
Ranjani Sridharan (5):
ASoC: SOF: Intel: HDA: Set IPC4-specific DSP ops for CaVS platforms
ASoC: SOF: Add IPC4 private header
ASoC: SOF: Add header for IPC4 manifest
ASoC: SOF: IPC4: Add FW loader ops
ASoC: SOF: Intel: HDA: Set upsof_ipc4_fw_datafor IPC4[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/5] ASoC: SOF: Intel: HDA: Set IPC4-specific DSP ops for CaVS platforms
commit: e3105c0ccc3e706584030159b6fde54cab2f8aef
[2/5] ASoC: SOF: Add IPC4 private header
commit: 0af829041d3f8e8f585f5692884d9c7402e7794d
[3/5] ASoC: SOF: Add header for IPC4 manifest
commit: 71cb8ad1a78043ca0eec1686bdd2e65143943b78
[4/5] ASoC: SOF: IPC4: Add FW loader ops
commit: c62ff366b3c9984dbc30ab032540d1167acdda32
[5/5] ASoC: SOF: Intel: HDA: Set up sof_ipc4_fw_data for IPC4
commit: a4cfdebdfe62e276f7626eb55b859fe16dcc28efAll being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark