ASoC: Intel: AVS - Audio DSP for cAVS
Subsystems (3)
Cezary Rojewski
maintainerv5 cover ASoC: Intel: AVS - Audio DSP for cAVS
A continuation of cleanup work of Intel SST solutions found in sound/soc/intel/. With two major chapters released last year catpt [1] and removal of haswell solution [2], time has come for Skylake-driver.
Througout 2019, 2020 and 2021 Skylake-driver has had many fixes applied and even attempts of refactors as seen in fundamental overhaul [3], IPC flow adjustments [4] and LARGE_CONFIG overhaul [5] series. Unfortunately, story repeats itself - problems are found within the core of a driver. Painting it with different colors does not change the fact that is it still a house of cards. As changes needed to address those issues would make Skylake solution incompatible with its previous revisions, a decision has been made to provide a new solution instead. In time it would deprecate and replace Skylake-driver.
That solution has been called AVS - from AudioDSP architecture name:
Audio-Voice-Speech. It is meant to provide support for the exact same range of platforms as its predecessor: SKL, KBL, AML and APL.
Note: this series is dependent upon HDA-series [6] which exposes several codec-organization functions allowing for reduced code size on avs-driver side.
Note: this series does not add fully functional driver as its size would get out of control. Here, focus is put on adding IPC protocol and code loading code.
Changes v4 -> v5:
- dropped WARN()s usage as requested by Pierre
- another round of typo fixes
- aligned code to make use of 100-char-per-line limit
- updated the dates in source and header files, it's 2022 already
Changes v3 -> v4:
- noted the limitations of LARGE_CONFIG_GET handler and dropped non-inclusive wording as requested by Pierre and Ranjani
- code loading flow now verifies if power downing non-MAIN_CORE fails
- commented kfree() usage in FW_CONFIG and HW_CONFIG getters
Changes v2 -> v3:
- fixed variable initialization errors mentioned by sparse
Changes v1 -> v2:
Almost all updates here are thanks to feedback from Pierre.
- several comments and few kernel-docs have been added in areas which felt more or less unclear
- avs_ipc_wait_busy_completion() now spins up to 'repeats_left' number of times before giving up
- 'adsp_ba' field of struct avs_dev has been renamed to 'dsp_ba'
- 'dops' field of struct avs_spec has been renamed to 'dsp_ops'
- IPC abstraction has been simplified: SKL_ADSP_REG_HIP* regs are used directly
- fixed allnoconfig with AVS enabled compilation issues
- fixed code loading error paths: previously requested firmware is now released before function return to the caller
- code and function arguments tied to D0IX support have been removed from this patchset and will be part of followup series adding that feature instead
- enriched dev_err() messages in avs_dsp_get_core() and avs_dsp_put_core()
- numerous wording fixes used in power/reset/stall DSP operations
Changes RFC v1 [7]: -> v1:
- separated HDA codec-organization patches, path and topology handling, PCM and complementary features such as recovery from this series to ease the review process
- fixed EXPORT_SYMBOL_GPL for exported members of ASoC framework
- result of stall() is now checked when sending ROM message
- result of snd_hdac_ext_stream_set_spib() is now checked when loading basefw
- if basefw is not ready, notification processing is now skipped
- documented several topology parsing helpers
Changes [internal] RFC v2 -> [public] RFC v1:
- dropped any sysfs related changes from this series, moved to follow up one
- dropped entire subscription-mechanism found in ipc.c. Handlers that are delegated to service certain firmware notifications are now called directly
- fixed kernel doc for snd_soc_dapm_new_dai_widgets() as reported by ikp
- prefixed snd_hda_codec_device_init() as suggested by Amadeo
- improved comments for d0ix transitions for APL-based platforms as suggested by Pierre
- a ton of spelling related fixes in most of the commit messages
- fixed remaining warnings pointed by scan-build (variable assigned but not used)
- replaced most of 'cAVS X.Y' expression usages with 'platform-based' equivalents as suggested by Pierre e.g.: cAVS 1.5 -> SKL-based
Changes [internal] RFC v1 -> [internal] RFC v2:
- fixed memleak caused by lack of kfree(vols) if memory allocation fails in avs_peakvol_create() as reported by Curtis
- fixed missing 'i' iterator incrementation in avs_widget_ready() causing reference loss as reported by Curtis
- replace hardcode: 0x40 usage with snd_hdac_calc_stream_format as suggested by Curtis.
In consequence, readability for all code loading (CL) procedues has increased and such approach auto-documents the CL stream preparation
- updated behavior of all index-fetching functions found in utils.c:
avs_module_entry_index(), avs_module_id_entry_index() and follow ups:
avs_get_module_entry(), avs_get_module_id_entry() to better conform to linux-kernel standard when no entry is found (return -ENOENT) rather than C++ standard (return -1, what in kernel case translated to -EPERM) as suggested by Curtis and Peter
- several suggestions have been made regarding spacing, and so far, I've agreed and applied with all of them. None proposed seemed out of place or redundant
- avs_path_stop() renamed to avs_path_pause() pipeline states are represented by RESET/PAUSED/RUNNING. avs_path_reset() and avs_path_run() were already there and avs_path_stop() just didn't look cohesive
- added missing parsers for num_output_pin and num_input_pin which are required for custom modules such as WAVES or DSM
- dropped 'priv_param_length' from custom module descriptor as this field is obsolete in firmware
- parse_dictionary() has been split into parse_dictionary_header() and parse_dictionary_entries() to drop code duplication present in several parsing function which could not re-use entire parse_dictionary()
- added avs_tplg_vendor_array_lookup_next() and avs_tplg_vendor_entry_next() to drop code duplicated present in several parsing functions. This change greatly impacted readability of all parsers
- parsing helpers such avs_tplg_vendor_array_lookup() now return offset by updating specified in function argument list u32 *offset variable. This is to address problem when u32 offset would be greater than max int, which is the return type for these functions
- AVS_DEFINE_PTR_PARSER() macro has been introduced to drop code duplication for all ptr-parsing users
- all struct avs_path_module creators have had their declaration
updated: function argument *owner ceased to exist as it could already be accessed by mod->owner
- fixed the order of operation for conditional paths (e.g.: echo reference) so these are no longer controlled by "source" path and instead are impacted by state changes of source and sink paths both. Previously only source path e.g. playback sourcing echo reference would trigger RUNNING status for conditional path. Equivalent RUNNING on WoV path which is in this case sink path, would not do so, leading to order-of-operation problems. Behavior has been changed to: both source and sink need to be RUNNING for conditional path to be set to RUNNING too. PAUSED for either source or sink will cause PAUSED transition for conditional path.
- to achieve the above, path states are now saved in 'state' i.e. new u32 field for struct avs_path
- resigned from fw_filename field usage in favour of newly added tplg_filename for machine board descriptors as suggested by Pierre
- platform descriptor fields have had their names update better reflect their purpose as suggested by Pierre
- fixed comp_list missing locking when manipulated
- all message senders now accept request as pointer as suggeseted by Peter
- resigned of AZX_ usage for all ADSP-related registers, leaving them only for HOST memory space related operations
- fixed disable path for core DSP operations: power/reset/stall as reported by Peter
- safety when locking between received responses (reply vs notification) has been lowered as suggested by Pierre. Most usages are not performed in IRQ context and none is done in hard-IRQ one
- s/master/main/ plus AVS_MAIN_CORE_MASK has replaced ->master_mask
- several functions have had their logging updated - logs have been moved to lower level functions as suggested by Pierre
- hdac_ext_stream usage has been streamlined to estream, hdac_streams are represented by hstream instead
- hw_params() are resilient to scenarios when they are called mutliple times as reported by Pierre
- avs_dsp_enable() now collapses if any of its steps fails as reported by Pierre and Peter
- avs_module_ida_empty() now returns value of type bool as suggested by Bard
[1]: https://www.spinics.net/lists/alsa-devel/msg116440.html
[2]: https://www.spinics.net/lists/alsa-devel/msg116901.html
[3]: https://www.spinics.net/lists/alsa-devel/msg94199.html
[4]: https://www.spinics.net/lists/alsa-devel/msg92588.html
[5]: https://lore.kernel.org/all/[email protected]/
[6]: https://lore.kernel.org/alsa-devel/[email protected]/T/#t
[7]: https://lore.kernel.org/all/[email protected]/
Cezary Rojewski (17):
ALSA: hda: Add helper macros for DSP capable devices
ASoC: Export DAI register and widget ctor and dctor functions
ASoC: Intel: Introduce AVS driver
ASoC: Intel: avs: Inter process communication
ASoC: Intel: avs: Add code loading requests
ASoC: Intel: avs: Add pipeline management requests
ASoC: Intel: avs: Add module management requests
ASoC: Intel: avs: Add power management requests
ASoC: Intel: avs: Add ROM requests
ASoC: Intel: avs: Add basefw runtime-parameter requests
ASoC: Intel: avs: Firmware resources management utilities
ASoC: Intel: avs: Declare module configuration types
ASoC: Intel: avs: Dynamic firmware resources management
ASoC: Intel: avs: General code loading flow
ASoC: Intel: avs: Implement CLDMA transfer
ASoC: Intel: avs: Code loading over CLDMA
ASoC: Intel: avs: Code loading over HDA
include/sound/hdaudio.h | 3 + include/sound/hdaudio_ext.h | 50 +++ include/sound/soc-dapm.h | 1 + sound/soc/intel/Kconfig | 12 + sound/soc/intel/Makefile | 1 + sound/soc/intel/avs/Makefile | 6 + sound/soc/intel/avs/avs.h | 247 +++++++++++ sound/soc/intel/avs/cldma.c | 316 ++++++++++++++ sound/soc/intel/avs/cldma.h | 29 ++ sound/soc/intel/avs/core.c | 61 +++ sound/soc/intel/avs/dsp.c | 302 +++++++++++++ sound/soc/intel/avs/ipc.c | 382 ++++++++++++++++ sound/soc/intel/avs/loader.c | 608 ++++++++++++++++++++++++++ sound/soc/intel/avs/messages.c | 695 +++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 752 ++++++++++++++++++++++++++++++++ sound/soc/intel/avs/registers.h | 75 ++++ sound/soc/intel/avs/utils.c | 301 +++++++++++++ sound/soc/soc-core.c | 1 + sound/soc/soc-dapm.c | 15 + 19 files changed, 3857 insertions(+) create mode 100644 sound/soc/intel/avs/Makefile create mode 100644 sound/soc/intel/avs/avs.h create mode 100644 sound/soc/intel/avs/cldma.c create mode 100644 sound/soc/intel/avs/cldma.h create mode 100644 sound/soc/intel/avs/core.c create mode 100644 sound/soc/intel/avs/dsp.c create mode 100644 sound/soc/intel/avs/ipc.c create mode 100644 sound/soc/intel/avs/loader.c create mode 100644 sound/soc/intel/avs/messages.c create mode 100644 sound/soc/intel/avs/messages.h create mode 100644 sound/soc/intel/avs/registers.h create mode 100644 sound/soc/intel/avs/utils.c
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 1/17 ALSA: hda: Add helper macros for DSP capable devices
HDAudio drivers make heavy use of I/O operations. Declare a range of update, read and write helpers similar to those available for HDAudio legacy driver. These macros are used by AVS driver to improve code readability.
--- include/sound/hdaudio.h | 3 +++ include/sound/hdaudio_ext.h | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+)
include/sound/hdaudio.h +3 -0
@@ -9,6 +9,7 @@#include <linux/device.h> #include <linux/interrupt.h> #include <linux/io.h> +#include <linux/io-64-nonatomic-lo-hi.h> #include <linux/pm_runtime.h> #include <linux/timecounter.h> #include <sound/core.h>
@@ -448,6 +449,8 @@ static inline u16 snd_hdac_reg_readw(struct hdac_bus *bus, void __iomem *addr)#define snd_hdac_reg_writel (bus, addr, val) writel(val, addr)#define snd_hdac_reg_readl (bus, addr) readl(addr) +#define snd_hdac_reg_writeq (bus, addr, val) writeq(val, addr) +#define snd_hdac_reg_readq (bus, addr) readq(addr)/* * macros for easy use
include/sound/hdaudio_ext.h +50 -0
62 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v5 01/17] ALSA: hda: Add helper macros for DSP capable devices
Quoted 7 lines · Cezary Rojewski
HDAudio drivers make heavy use of I/O operations. Declare a range of update, read and write helpers similar to those available for HDAudio legacy driver. These macros are used by AVS driver to improve code readability.
Signed-off-by Cezary Rojewski <[email protected]>
(I already gave Ack for v4; please include it when you respin v6.)
thanks,
Takashi
Cezary Rojewski
maintainerPATCH v5 2/17 ASoC: Export DAI register and widget ctor and dctor functions
In reply to Cezary RojewskiTo allow for more flexibility i.e. populating component DAIs dynamically during its initialization, without being limited to topology loading procedure, expose snd_soc_register(), snd_soc_dapm_new_dai_widgets() and snd_soc_dapm_free_widget() functions.
Allows users to first check available resources e.g. number of PCMs supported by HDAudio codec before allocating the number of DAPM widgets needed. This prevents superfluous objects from being created or allows driver to adjust to situation when resources are limited.
--- include/sound/soc-dapm.h | 1 + sound/soc/soc-core.c | 1 + sound/soc/soc-dapm.c | 15 +++++++++++++++ 3 files changed, 17 insertions(+)
include/sound/soc-dapm.h +1 -0
@@ -429,6 +429,7 @@ struct snd_soc_dapm_widget *snd_soc_dapm_new_control_unlocked( const struct snd_soc_dapm_widget *widget);int snd_soc_dapm_new_dai_widgets (struct snd_soc_dapm_context *dapm,struct snd_soc_dai *dai); +void snd_soc_dapm_free_widget (struct snd_soc_dapm_widget *w);int snd_soc_dapm_link_dai_widgets (struct snd_soc_card *card);void snd_soc_dapm_connect_dai_link_widgets (struct snd_soc_card *card);
sound/soc/soc-core.c +1 -0
@@ -2465,6 +2465,7 @@ struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,dev_dbg (dev,"ASoC: Registered DAI '%s'\n" , dai->name);return dai; } +EXPORT_SYMBOL_GPL (snd_soc_register_dai);/** * snd_soc_unregister_dais - Unregister DAIs from the ASoC core
sound/soc/soc-dapm.c +15 -0
@@ -2484,6 +2484,12 @@ static void dapm_free_path(struct snd_soc_dapm_path *path)kfree (path); } +/** +* snd_soc_dapm_free_widget - Free specified widget +* @w: widget to free +* +* Removes widget from all paths and frees memory occupied by it. +*/ void snd_soc_dapm_free_widget (struct snd_soc_dapm_widget *w) {struct snd_soc_dapm_path *p, *next_p;
@@ -2506,6 +2512,7 @@ void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w)kfree_const (w->sname);kfree (w); } +EXPORT_SYMBOL_GPL (snd_soc_dapm_free_widget);void snd_soc_dapm_reset_cache (struct snd_soc_dapm_context *dapm) {
@@ -4208,6 +4215,13 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card,return ERR_PTR (ret); } +/** +* snd_soc_dapm_new_dai_widgets - Create new DAPM widgets +* @dapm: DAPM context +* @dai: parent DAI +* +* Returns 0 on success, error code otherwise. +*/ int snd_soc_dapm_new_dai_widgets (struct snd_soc_dapm_context *dapm,struct snd_soc_dai *dai) {
@@ -4253,6 +4267,7 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,return 0 ; } +EXPORT_SYMBOL_GPL (snd_soc_dapm_new_dai_widgets);int snd_soc_dapm_link_dai_widgets (struct snd_soc_card *card) {
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 3/17 ASoC: Intel: Introduce AVS driver
In reply to Cezary RojewskiDeclare base structures and core DSP operations for the avs solution. The base structures describe PCI HDAudio bus device and platform-type differentiations. First set of operations added controls the lifecycle of any Audio DSP core: (un)powering, (un)resetting and (un)stalling.
--- sound/soc/intel/Kconfig | 11 ++++ sound/soc/intel/Makefile | 1 + sound/soc/intel/avs/Makefile | 5 ++ sound/soc/intel/avs/avs.h | 71 +++++++++++++++++++++ sound/soc/intel/avs/dsp.c | 107 ++++++++++++++++++++++++++++++++ sound/soc/intel/avs/registers.h | 22 +++++++ 6 files changed, 217 insertions(+) create mode 100644 sound/soc/intel/avs/Makefile create mode 100644 sound/soc/intel/avs/avs.h create mode 100644 sound/soc/intel/avs/dsp.c create mode 100644 sound/soc/intel/avs/registers.h
sound/soc/intel/Kconfig +11 -0
@@ -209,5 +209,16 @@ config SND_SOC_INTEL_KEEMBAY If you have a Intel Keembay platform then enable this option by saying Y or m. +config SND_SOC_INTEL_AVS + tristate "Intel AVS driver" + depends on PCI && ACPI + depends on COMMON_CLK + select SND_SOC_ACPI + select SND_HDA_EXT_CORE + help + Enable support for Intel(R) cAVS 1.5 platforms with DSP + capabilities. This includes Skylake, Kabylake, Amberlake and + Apollolake. + # ASoC codec drivers source "sound/soc/intel/boards/Kconfig"
sound/soc/intel/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_SND_SST_ATOM_HIFI2_PLATFORM) += atom/ obj-$(CONFIG_SND_SOC_INTEL_CATPT) += catpt/ obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE_COMMON) += skylake/ obj-$(CONFIG_SND_SOC_INTEL_KEEMBAY) += keembay/ +obj-$(CONFIG_SND_SOC_INTEL_AVS) += avs/ # Machine support obj-$(CONFIG_SND_SOC) += boards/
sound/soc/intel/avs/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-only + +snd-soc-avs-objs := dsp.o + +obj-$(CONFIG_SND_SOC_INTEL_AVS) += snd-soc-avs.o
sound/soc/intel/avs/avs.h new file +71 -0
71 lines not on this page · raw message
sound/soc/intel/avs/dsp.c new file +107 -0
107 lines not on this page · raw message
sound/soc/intel/avs/registers.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright(c) 2021-2022 Intel Corporation. All rights reserved. +* +* Authors: Cezary Rojewski <[email protected]> +* Amadeusz Slawinski <[email protected]> +*/ + +#ifndef __SOUND_SOC_INTEL_AVS_REGS_H +#define __SOUND_SOC_INTEL_AVS_REGS_H + +/* Intel HD Audio General DSP Registers */ +#define AVS_ADSP_GEN_BASE 0x0 +#define AVS_ADSP_REG_ADSPCS (AVS_ADSP_GEN_BASE + 0x04) + +#define AVS_ADSPCS_CRST_MASK (cm) (cm) +#define AVS_ADSPCS_CSTALL_MASK (cm) ((cm) << 8) +#define AVS_ADSPCS_SPA_MASK (cm) ((cm) << 16) +#define AVS_ADSPCS_CPA_MASK (cm) ((cm) << 24) +#define AVS_MAIN_CORE_MASK BIT(0) + +#endif /* __SOUND_SOC_INTEL_AVS_REGS_H */
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 4/17 ASoC: Intel: avs: Inter process communication
In reply to Cezary RojewskiImplement the IPC between Intel audio firmware and kernel driver. The IPC allows transmission of requests, handling of responses as well as unsolicited (i.e. firmware-generated) notifications.
A subscription mechanism is added to enable different parts of the driver to register for specific notifications.
The part of the DSP boot process that involves sending ROM message requires an extra step - must be followed by unstall operation of MAIN_CORE. All other types of messages do not require such specific handling, so separate set of functions is provided for sending these.
--- sound/soc/intel/avs/Makefile | 2 +- sound/soc/intel/avs/avs.h | 100 +++++++++ sound/soc/intel/avs/ipc.c | 376 ++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 170 +++++++++++++++ sound/soc/intel/avs/registers.h | 45 ++++ 5 files changed, 692 insertions(+), 1 deletion(-) create mode 100644 sound/soc/intel/avs/ipc.c create mode 100644 sound/soc/intel/avs/messages.h
sound/soc/intel/avs/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -snd-soc-avs-objs := dsp.o +snd-soc-avs-objs := dsp.o ipc.o obj-$(CONFIG_SND_SOC_INTEL_AVS) += snd-soc-avs.o
sound/soc/intel/avs/avs.h +100 -0
129 lines not on this page · raw message
sound/soc/intel/avs/ipc.c new file +376 -0
376 lines not on this page · raw message
sound/soc/intel/avs/messages.h new file +170 -0
170 lines not on this page · raw message
sound/soc/intel/avs/registers.h +45 -0
55 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 5/17 ASoC: Intel: avs: Add code loading requests
In reply to Cezary RojewskiBefore firmware and its modules can be used, they have to be loaded. Code loading process is complex and is a combination of DMA and IPC operations. Here, IPC part is being added and accounts for CLDMA and HDA mechanisms both.
--- sound/soc/intel/avs/Makefile | 2 +- sound/soc/intel/avs/messages.c | 65 ++++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 22 ++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 sound/soc/intel/avs/messages.c
sound/soc/intel/avs/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -snd-soc-avs-objs := dsp.o ipc.o +snd-soc-avs-objs := dsp.o ipc.o messages.o obj-$(CONFIG_SND_SOC_INTEL_AVS) += snd-soc-avs.o
sound/soc/intel/avs/messages.c new file +65 -0
65 lines not on this page · raw message
sound/soc/intel/avs/messages.h +22 -0
@@ -24,6 +24,9 @@ enum avs_msg_direction { };enum avs_global_msg_type { +AVS_GLB_LOAD_MULTIPLE_MODULES =15 , +AVS_GLB_UNLOAD_MULTIPLE_MODULES =16 , +AVS_GLB_LOAD_LIBRARY =24 ,AVS_GLB_NOTIFICATION =27 , };
@@ -38,6 +41,16 @@ union avs_global_msg { u32 msg_direction:1; u32 msg_target:1; }; +/* module loading */ +struct { +u32 mod_cnt:8 ; + } load_multi_mods; +/* library loading */ +struct { +u32 dma_id:5 ; +u32 rsvd:11 ; +u32 lib_id:4 ; + } load_lib; };union {u32 val;
@@ -84,6 +97,10 @@ union avs_reply_msg { };union {u32 val; +/* module loading */ +struct { +u32 err_mod_id:16 ; + } load_multi_mods; } ext; }; } __packed;
@@ -167,4 +184,9 @@ struct avs_notify_mod_data { u32 data[]; } __packed; +/* Code loading messages */ +int avs_ipc_load_modules (struct avs_dev *adev,u16 *mod_ids,u32 num_mod_ids); +int avs_ipc_unload_modules (struct avs_dev *adev,u16 *mod_ids,u32 num_mod_ids); +int avs_ipc_load_library (struct avs_dev *adev,u32 dma_id,u32 lib_id); +#endif /* __SOUND_SOC_INTEL_AVS_MSGS_H */
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 6/17 ASoC: Intel: avs: Add pipeline management requests
In reply to Cezary RojewskiPipeline represents a scheduling entity. Their existence as well as their state machine is controlled through CREATE_PIPELINE, DELETE_PIPELINE and SET_PIPELINE_STATE IPCs.
--- sound/soc/intel/avs/messages.c | 76 ++++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 48 +++++++++++++++++++++ 2 files changed, 124 insertions(+)
sound/soc/intel/avs/messages.c +76 -0
@@ -63,3 +63,79 @@ int avs_ipc_load_library(struct avs_dev *adev, u32 dma_id, u32 lib_id)return ret; } + +int avs_ipc_create_pipeline (struct avs_dev *adev,u16 req_size,u8 priority, +u8 instance_id,bool lp,u16 attributes) +{ +union avs_global_msg msg =AVS_GLOBAL_REQUEST (CREATE_PIPELINE ); +struct avs_ipc_msg request = {{0 }}; +int ret; + + msg.create_ppl.ppl_mem_size = req_size; + msg.create_ppl.ppl_priority = priority; + msg.create_ppl.instance_id = instance_id; + msg.ext.create_ppl.lp = lp; + msg.ext.create_ppl.attributes = attributes; + request.header = msg.val; + + ret =avs_dsp_send_msg (adev, &request,NULL ); +if (ret) +avs_ipc_err (adev, &request,"create pipeline" , ret); + +return ret; +} + +int avs_ipc_delete_pipeline (struct avs_dev *adev,u8 instance_id) +{ +union avs_global_msg msg =AVS_GLOBAL_REQUEST (DELETE_PIPELINE ); +struct avs_ipc_msg request = {{0 }}; +int ret; + + msg.ppl.instance_id = instance_id; + request.header = msg.val; + + ret =avs_dsp_send_msg (adev, &request,NULL ); +if (ret) +avs_ipc_err (adev, &request,"delete pipeline" , ret); + +return ret; +} + +int avs_ipc_set_pipeline_state (struct avs_dev *adev,u8 instance_id, +enum avs_pipeline_state state) +{ +union avs_global_msg msg =AVS_GLOBAL_REQUEST (SET_PIPELINE_STATE ); +struct avs_ipc_msg request = {{0 }}; +int ret; + + msg.set_ppl_state.ppl_id = instance_id; + msg.set_ppl_state.state = state; + request.header = msg.val; + + ret =avs_dsp_send_msg (adev, &request,NULL ); +if (ret) +avs_ipc_err (adev, &request,"set pipeline state" , ret); + +return ret; +} + +int avs_ipc_get_pipeline_state (struct avs_dev *adev,u8 instance_id, +enum avs_pipeline_state *state) +{ +union avs_global_msg msg =AVS_GLOBAL_REQUEST (GET_PIPELINE_STATE ); +struct avs_ipc_msg request = {{0 }}; +struct avs_ipc_msg reply = {{0 }}; +int ret; + + msg.get_ppl_state.ppl_id = instance_id; + request.header = msg.val; + + ret =avs_dsp_send_msg (adev, &request, &reply); +if (ret) { +avs_ipc_err (adev, &request,"get pipeline state" , ret); +return ret; + } + + *state = reply.rsp.ext.get_ppl_state.state; +return ret; +}
sound/soc/intel/avs/messages.h +48 -0
76 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 7/17 ASoC: Intel: avs: Add module management requests
In reply to Cezary RojewskiFirmware modules implement processing algorithms. Their lifecycle, similarly to pipelines is being controlled by IPCs: initialization, deletion and (un)binding.
Modules can be configured at runtime - runtime parameters. This is done with help of LARGE_CONFIG IPCs: getter and setter.
Due to firmware limitations, LARGE_CONFIG_GET handler implementation does not support retrieving payload with size larger than IPC inbox window size.
--- sound/soc/intel/avs/ipc.c | 8 +- sound/soc/intel/avs/messages.c | 261 +++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 52 +++++++ 3 files changed, 320 insertions(+), 1 deletion(-)
sound/soc/intel/avs/ipc.c +7 -1
@@ -21,8 +21,14 @@ static void avs_dsp_receive_rx(struct avs_dev *adev, u64 header) ipc->rx.header = header;/* Abort copying payload if request processing was unsuccessful. */ -if (!msg.status) +if (!msg.status) { +/* update size in case of LARGE_CONFIG_GET */ +if (msg.msg_target ==AVS_MOD_MSG && + msg.global_msg_type ==AVS_MOD_LARGE_CONFIG_GET ) + ipc->rx.size = msg.ext.large_config.data_off_size; +memcpy_fromio (ipc->rx.data,avs_uplink_addr (adev), ipc->rx.size); + } }static void avs_dsp_process_notification (struct avs_dev *adev,u64 header)
sound/soc/intel/avs/messages.c +261 -0
270 lines not on this page · raw message
sound/soc/intel/avs/messages.h +52 -0
74 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 8/17 ASoC: Intel: avs: Add power management requests
In reply to Cezary RojewskiAudio DSP supports low power states i.e.: transitions between D0 and D3 and D0-substates in form of D0i0 and D0i3. That process is a combination of core and IPC operations. Here, Dx and D0ix IPC handlers are added.
--- sound/soc/intel/avs/messages.c | 44 ++++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 15 ++++++++++++ 2 files changed, 59 insertions(+)
sound/soc/intel/avs/messages.c +44 -0
@@ -400,3 +400,47 @@ int avs_ipc_get_large_config(struct avs_dev *adev, u16 module_id, u8 instance_idreturn 0 ; } + +int avs_ipc_set_dx (struct avs_dev *adev,u32 core_mask,bool powerup) +{ +union avs_module_msg msg =AVS_MODULE_REQUEST (SET_DX ); +struct avs_ipc_msg request; +struct avs_dxstate_info dx; +int ret; + + dx.core_mask = core_mask; + dx.dx_mask = powerup ? core_mask :0 ; + request.header = msg.val; + request.data = &dx; + request.size =sizeof (dx); + + ret =avs_dsp_send_msg (adev, &request,NULL ); +if (ret) +avs_ipc_err (adev, &request,"set dx" , ret); + +return ret; +} + +/* +* avs_ipc_set_d0ix - Set power gating policy (entering D0IX substates) +* +* @enable_pg: Whether to enable or disable power gating +* @streaming: Whether a stream is running when transitioning +*/ +int avs_ipc_set_d0ix (struct avs_dev *adev,bool enable_pg,bool streaming) +{ +union avs_module_msg msg =AVS_MODULE_REQUEST (SET_D0IX ); +struct avs_ipc_msg request = {{0 }}; +int ret; + + msg.ext.set_d0ix.wake = enable_pg; + msg.ext.set_d0ix.streaming = streaming; + + request.header = msg.val; + + ret =avs_dsp_send_msg (adev, &request,NULL ); +if (ret) +avs_ipc_err (adev, &request,"set d0ix" , ret); + +return ret; +}
sound/soc/intel/avs/messages.h +15 -0
@@ -97,6 +97,8 @@ enum avs_module_msg_type {AVS_MOD_LARGE_CONFIG_SET =4 ,AVS_MOD_BIND =5 ,AVS_MOD_UNBIND =6 , +AVS_MOD_SET_DX =7 , +AVS_MOD_SET_D0IX =8 , AVS_MOD_DELETE_INSTANCE = 11, };
@@ -133,6 +135,10 @@ union avs_module_msg { u32 dst_queue:3; u32 src_queue:3; } bind_unbind; +struct { +u32 wake:1 ; +u32 streaming:1 ; + } set_d0ix; } ext; }; } __packed;
@@ -289,4 +295,13 @@ int avs_ipc_get_large_config(struct avs_dev *adev, u16 module_id, u8 instance_id u8 param_id, u8 *request_data, size_t request_size, u8 **reply_data, size_t *reply_size); +/* DSP cores and domains power management messages */ +struct avs_dxstate_info { +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 */ +} __packed; + +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); +#endif /* __SOUND_SOC_INTEL_AVS_MSGS_H */
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 9/17 ASoC: Intel: avs: Add ROM requests
In reply to Cezary RojewskiROM requests are messages initiated by Host to alter firmware early boot process. They specify whether the next boot should be a fresh start or if IMR can be used to speed things up.
--- sound/soc/intel/avs/messages.c | 18 ++++++++++++++++++ sound/soc/intel/avs/messages.h | 14 ++++++++++++++ 2 files changed, 32 insertions(+)
sound/soc/intel/avs/messages.c +18 -0
@@ -12,6 +12,24 @@#define AVS_CL_TIMEOUT_MS 5000 +int avs_ipc_set_boot_config (struct avs_dev *adev,u32 dma_id,u32 purge) +{ +union avs_global_msg msg =AVS_GLOBAL_REQUEST (ROM_CONTROL ); +struct avs_ipc_msg request = {{0 }}; +int ret; + + msg.boot_cfg.rom_ctrl_msg_type =AVS_ROM_SET_BOOT_CONFIG ; + msg.boot_cfg.dma_id = dma_id; + msg.boot_cfg.purge_request = purge; + request.header = msg.val; + + ret =avs_dsp_send_rom_msg (adev, &request); +if (ret) +avs_ipc_err (adev, &request,"set boot config" , ret); + +return ret; +} +int avs_ipc_load_modules (struct avs_dev *adev,u16 *mod_ids,u32 num_mod_ids) {union avs_global_msg msg =AVS_GLOBAL_REQUEST (LOAD_MULTIPLE_MODULES );
sound/soc/intel/avs/messages.h +14 -0
@@ -24,6 +24,7 @@ enum avs_msg_direction { };enum avs_global_msg_type { +AVS_GLB_ROM_CONTROL =1 ,AVS_GLB_LOAD_MULTIPLE_MODULES =15 ,AVS_GLB_UNLOAD_MULTIPLE_MODULES =16 ,AVS_GLB_CREATE_PIPELINE =17 ,
@@ -45,6 +46,12 @@ union avs_global_msg { u32 msg_direction:1; u32 msg_target:1; }; +/* set boot config */ +struct { +u32 rom_ctrl_msg_type:9 ; +u32 dma_id:5 ; +u32 purge_request:1 ; + } boot_cfg;/* module loading */ struct {u32 mod_cnt:8 ;
@@ -255,6 +262,13 @@ struct avs_notify_mod_data {u32 data[]; } __packed; +/* ROM messages */ +enum avs_rom_control_msg_type { +AVS_ROM_SET_BOOT_CONFIG =0 , +}; + +int avs_ipc_set_boot_config (struct avs_dev *adev,u32 dma_id,u32 purge); +/* Code loading messages */ int avs_ipc_load_modules (struct avs_dev *adev,u16 *mod_ids,u32 num_mod_ids);int avs_ipc_unload_modules (struct avs_dev *adev,u16 *mod_ids,u32 num_mod_ids);
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 10/17 ASoC: Intel: avs: Add basefw runtime-parameter requests
In reply to Cezary RojewskiEach module may expose a range of runtime parameters. For basefw, implement handlers for: FIRMWARE_CONFIG, HARDWARE_CONFIG and MODULES_INFO. These are used by driver to dynamically allocate resources in respect to platform details, reducing number of hardcodes and code duplications that would otherwise be needed to be defined within the driver code.
--- sound/soc/intel/avs/messages.c | 214 +++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 179 +++++++++++++++++++++++++++ 2 files changed, 393 insertions(+)
sound/soc/intel/avs/messages.c +214 -0
@@ -462,3 +462,217 @@ int avs_ipc_set_d0ix(struct avs_dev *adev, bool enable_pg, bool streaming)return ret; } + +int avs_ipc_get_fw_config (struct avs_dev *adev,struct avs_fw_cfg *cfg) +{ +struct avs_tlv *tlv; +size_t payload_size; +size_t offset =0 ; +u8 *payload; +int ret; + + ret =avs_ipc_get_large_config (adev,AVS_BASEFW_MOD_ID ,AVS_BASEFW_INST_ID , +AVS_BASEFW_FIRMWARE_CONFIG ,NULL ,0 , + &payload, &payload_size); +if (ret) +return ret; + +while (offset < payload_size) { + tlv = (struct avs_tlv *)(payload + offset); + +switch (tlv->type) { +case AVS_FW_CFG_FW_VERSION : +memcpy (&cfg->fw_version, tlv->value,sizeof (cfg->fw_version)); +break ; + +case AVS_FW_CFG_MEMORY_RECLAIMED : + cfg->memory_reclaimed = *tlv->value; +break ; + +case AVS_FW_CFG_SLOW_CLOCK_FREQ_HZ : + cfg->slow_clock_freq_hz = *tlv->value; +break ; + +case AVS_FW_CFG_FAST_CLOCK_FREQ_HZ : + cfg->fast_clock_freq_hz = *tlv->value; +break ; + +case AVS_FW_CFG_ALH_SUPPORT_LEVEL : + cfg->alh_support = *tlv->value; +break ; + +case AVS_FW_CFG_IPC_DL_MAILBOX_BYTES : + cfg->ipc_dl_mailbox_bytes = *tlv->value; +break ; + +case AVS_FW_CFG_IPC_UL_MAILBOX_BYTES : + cfg->ipc_ul_mailbox_bytes = *tlv->value; +break ; + +case AVS_FW_CFG_TRACE_LOG_BYTES : + cfg->trace_log_bytes = *tlv->value; +break ; + +case AVS_FW_CFG_MAX_PPL_COUNT : + cfg->max_ppl_count = *tlv->value; +break ; + +case AVS_FW_CFG_MAX_ASTATE_COUNT : + cfg->max_astate_count = *tlv->value; +break ; + +case AVS_FW_CFG_MAX_MODULE_PIN_COUNT : + cfg->max_module_pin_count = *tlv->value; +break ; + +case AVS_FW_CFG_MODULES_COUNT : + cfg->modules_count = *tlv->value; +break ; + +case AVS_FW_CFG_MAX_MOD_INST_COUNT : + cfg->max_mod_inst_count = *tlv->value; +break ; + +case AVS_FW_CFG_MAX_LL_TASKS_PER_PRI_COUNT : + cfg->max_ll_tasks_per_pri_count = *tlv->value; +break ; + +case AVS_FW_CFG_LL_PRI_COUNT : + cfg->ll_pri_count = *tlv->value; +break ; + +case AVS_FW_CFG_MAX_DP_TASKS_COUNT : + cfg->max_dp_tasks_count = *tlv->value; +break ; + +case AVS_FW_CFG_MAX_LIBS_COUNT : + cfg->max_libs_count = *tlv->value; +break ; + +case AVS_FW_CFG_XTAL_FREQ_HZ : + cfg->xtal_freq_hz = *tlv->value; +break ; + +case AVS_FW_CFG_POWER_GATING_POLICY : + cfg->power_gating_policy = *tlv->value; +break ; + +/* Known but not useful to us. */ +case AVS_FW_CFG_DMA_BUFFER_CONFIG : +case AVS_FW_CFG_SCHEDULER_CONFIG : +case AVS_FW_CFG_CLOCKS_CONFIG : +break ; + +default : +dev_info (adev->dev,"Unrecognized fw param: %d\n" , tlv->type); +break ; + } + + offset +=sizeof (*tlv) + tlv->length; + } + +/* No longer needed, free it as it's owned by the get_large_config() caller. */ +kfree (payload); +return ret; +} + +int avs_ipc_get_hw_config (struct avs_dev *adev,struct avs_hw_cfg *cfg) +{ +struct avs_tlv *tlv; +size_t payload_size; +size_t size, offset =0 ; +u8 *payload; +int ret; + + ret =avs_ipc_get_large_config (adev,AVS_BASEFW_MOD_ID ,AVS_BASEFW_INST_ID , +AVS_BASEFW_HARDWARE_CONFIG ,NULL ,0 , + &payload, &payload_size); +if (ret) +return ret; + +while (offset < payload_size) { + tlv = (struct avs_tlv *)(payload + offset); + +switch (tlv->type) { +case AVS_HW_CFG_AVS_VER : + cfg->avs_version = *tlv->value; +break ; + +case AVS_HW_CFG_DSP_CORES : + cfg->dsp_cores = *tlv->value; +break ; + +case AVS_HW_CFG_MEM_PAGE_BYTES : + cfg->mem_page_bytes = *tlv->value; +break ; + +case AVS_HW_CFG_TOTAL_PHYS_MEM_PAGES : + cfg->total_phys_mem_pages = *tlv->value; +break ; + +case AVS_HW_CFG_I2S_CAPS : + cfg->i2s_caps.i2s_version = tlv->value[0 ]; + size = tlv->value[1 ]; + cfg->i2s_caps.ctrl_count = size; +if (!size) +break ; + +/* Multiply to get entire array size. */ + size *=sizeof (*cfg->i2s_caps.ctrl_base_addr); + cfg->i2s_caps.ctrl_base_addr =devm_kmemdup (adev->dev, + &tlv->value[2 ], + size,GFP_KERNEL ); +if (!cfg->i2s_caps.ctrl_base_addr) { + ret = -ENOMEM ; + goto exit; + } +break ; + +case AVS_HW_CFG_GATEWAY_COUNT : + cfg->gateway_count = *tlv->value; +break ; + +case AVS_HW_CFG_HP_EBB_COUNT : + cfg->hp_ebb_count = *tlv->value; +break ; + +case AVS_HW_CFG_LP_EBB_COUNT : + cfg->lp_ebb_count = *tlv->value; +break ; + +case AVS_HW_CFG_EBB_SIZE_BYTES : + cfg->ebb_size_bytes = *tlv->value; +break ; + +case AVS_HW_CFG_GPDMA_CAPS : +break ; + +default : +dev_info (adev->dev,"Unrecognized hw config: %d\n" , tlv->type); +break ; + } + + offset +=sizeof (*tlv) + tlv->length; + } + +exit: +/* No longer needed, free it as it's owned by the get_large_config() caller. */ +kfree (payload); +return ret; +} + +int avs_ipc_get_modules_info (struct avs_dev *adev,struct avs_mods_info **info) +{ +size_t payload_size; +u8 *payload; +int ret; + + ret =avs_ipc_get_large_config (adev,AVS_BASEFW_MOD_ID ,AVS_BASEFW_INST_ID , +AVS_BASEFW_MODULES_INFO ,NULL ,0 , + &payload, &payload_size); +if (ret) +return ret; + + *info = (struct avs_mods_info *)payload; +return 0 ; +}
sound/soc/intel/avs/messages.h +179 -0
183 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 11/17 ASoC: Intel: avs: Firmware resources management utilities
In reply to Cezary RojewskiWith basefw runtime parameter handlers added, implement utility functions to ease pipelines and modules allocation. IDA is enlisted to help with that.
As firmware is modular and multiple binaries can be loaded on-demand depending on the streaming scenario, custom firmware caching mechanism is added.
--- sound/soc/intel/avs/Makefile | 2 +- sound/soc/intel/avs/avs.h | 37 +++++ sound/soc/intel/avs/utils.c | 301 +++++++++++++++++++++++++++++++++++ 3 files changed, 339 insertions(+), 1 deletion(-) create mode 100644 sound/soc/intel/avs/utils.c
sound/soc/intel/avs/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -snd-soc-avs-objs := dsp.o ipc.o messages.o +snd-soc-avs-objs := dsp.o ipc.o messages.o utils.o obj-$(CONFIG_SND_SOC_INTEL_AVS) += snd-soc-avs.o
sound/soc/intel/avs/avs.h +37 -0
@@ -53,12 +53,26 @@ struct avs_spec {const u32 rom_status; }; +struct avs_fw_entry { +char *name; +const struct firmware *fw; + +struct list_head node; +}; +/* * struct avs_dev - Intel HD-Audio driver data * * @dev: PCI device * @dsp_ba: DSP bar address * @spec: platform-specific descriptor +* @fw_cfg: Firmware configuration, obtained through FW_CONFIG message +* @hw_cfg: Hardware configuration, obtained through HW_CONFIG message +* @mods_info: Available module-types, obtained through MODULES_INFO message +* @mod_idas: Module instance ID pool, one per module-type +* @modres_mutex: For synchronizing any @mods_info updates +* @ppl_ida: Pipeline instance ID pool +* @fw_list: List of libraries loaded, including base firmware */ struct avs_dev {struct hda_bus base;
@@ -68,6 +82,14 @@ struct avs_dev {const struct avs_spec *spec;struct avs_ipc *ipc; +struct avs_fw_cfg fw_cfg; +struct avs_hw_cfg hw_cfg; +struct avs_mods_info *mods_info; +struct ida **mod_idas; +struct mutex modres_mutex; +struct ida ppl_ida; +struct list_head fw_list; +struct completion fw_ready; };
@@ -168,4 +190,19 @@ void avs_dsp_interrupt_control(struct avs_dev *adev, bool enable);int avs_ipc_init (struct avs_ipc *ipc,struct device *dev);void avs_ipc_block (struct avs_ipc *ipc); +/* Firmware resources management */ + +int avs_get_module_entry (struct avs_dev *adev,const guid_t *uuid,struct avs_module_entry *entry); +int avs_get_module_id_entry (struct avs_dev *adev,u32 module_id,struct avs_module_entry *entry); +int avs_get_module_id (struct avs_dev *adev,const guid_t *uuid); +bool avs_is_module_ida_empty (struct avs_dev *adev,u32 module_id); + +int avs_module_info_init (struct avs_dev *adev,bool purge); +void avs_module_info_free (struct avs_dev *adev); +int avs_module_id_alloc (struct avs_dev *adev,u16 module_id); +void avs_module_id_free (struct avs_dev *adev,u16 module_id,u8 instance_id); +int avs_request_firmware (struct avs_dev *adev,const struct firmware **fw_p,const char *name); +void avs_release_last_firmware (struct avs_dev *adev); +void avs_release_firmwares (struct avs_dev *adev); +#endif /* __SOUND_SOC_INTEL_AVS_H */
sound/soc/intel/avs/utils.c new file +301 -0
301 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 12/17 ASoC: Intel: avs: Declare module configuration types
In reply to Cezary RojewskiDeclare structures and constants for all modules being part of basefw binary. These are used in streaming operations to communicate the needs of software to firmware side.
While adding module types, append handler for SET_SINK_FORMAT runtime for COPIER module which allows for configuration of output pin other than the default one (0).
--- sound/soc/intel/avs/messages.c | 17 +++ sound/soc/intel/avs/messages.h | 252 +++++++++++++++++++++++++++++++++ 2 files changed, 269 insertions(+)
sound/soc/intel/avs/messages.c +17 -0
@@ -676,3 +676,20 @@ int avs_ipc_get_modules_info(struct avs_dev *adev, struct avs_mods_info **info) *info = (struct avs_mods_info *)payload;return 0 ; } + +int avs_ipc_copier_set_sink_format (struct avs_dev *adev,u16 module_id, +u8 instance_id,u32 sink_id, +const struct avs_audio_format *src_fmt, +const struct avs_audio_format *sink_fmt) +{ +struct avs_copier_sink_format cpr_fmt; + + cpr_fmt.sink_id = sink_id; +/* Firmware expects driver to resend copier's input format. */ + cpr_fmt.src_fmt = *src_fmt; + cpr_fmt.sink_fmt = *sink_fmt; + +return avs_ipc_set_large_config (adev, module_id, instance_id, +AVS_COPIER_SET_SINK_FORMAT , + (u8 *)&cpr_fmt,sizeof (cpr_fmt)); +}
sound/soc/intel/avs/messages.h +252 -0
256 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 13/17 ASoC: Intel: avs: Dynamic firmware resources management
In reply to Cezary RojewskiWrap elementary DSP-core operations and resource control into more complex handlers. This is done to reduce the number of invocations of wrapped operations throughout the driver as order of operations matters - most flows involve register manipulation and IPCs combined.
--- sound/soc/intel/avs/avs.h | 10 +++ sound/soc/intel/avs/dsp.c | 169 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+)
sound/soc/intel/avs/avs.h +10 -0
@@ -89,6 +89,7 @@ struct avs_dev {struct mutex modres_mutex;struct ida ppl_ida;struct list_head fw_list; +int *core_refs;/* reference count per core */ struct completion fw_ready; };
@@ -205,4 +206,13 @@ int avs_request_firmware(struct avs_dev *adev, const struct firmware **fw_p, convoid avs_release_last_firmware (struct avs_dev *adev);void avs_release_firmwares (struct avs_dev *adev); +int avs_dsp_init_module (struct avs_dev *adev,u16 module_id,u8 ppl_instance_id, +u8 core_id,u8 domain,void *param,u32 param_size, +u16 *instance_id); +void avs_dsp_delete_module (struct avs_dev *adev,u16 module_id,u16 instance_id, +u8 ppl_instance_id,u8 core_id); +int avs_dsp_create_pipeline (struct avs_dev *adev,u16 req_size,u8 priority, +bool lp,u16 attributes,u8 *instance_id); +int avs_dsp_delete_pipeline (struct avs_dev *adev,u8 instance_id); +#endif /* __SOUND_SOC_INTEL_AVS_H */
sound/soc/intel/avs/dsp.c +169 -0
173 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 14/17 ASoC: Intel: avs: General code loading flow
In reply to Cezary RojewskiCode loading is a complex procedure and requires combined effort of DMA and IPCs. With IPCs already in place, lay out ground for specific DMA transfer operations.
--- sound/soc/intel/avs/Makefile | 2 +- sound/soc/intel/avs/avs.h | 17 +++ sound/soc/intel/avs/core.c | 61 +++++++++ sound/soc/intel/avs/dsp.c | 26 ++++ sound/soc/intel/avs/loader.c | 235 ++++++++++++++++++++++++++++++++ sound/soc/intel/avs/registers.h | 6 + 6 files changed, 346 insertions(+), 1 deletion(-) create mode 100644 sound/soc/intel/avs/core.c create mode 100644 sound/soc/intel/avs/loader.c
sound/soc/intel/avs/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -snd-soc-avs-objs := dsp.o ipc.o messages.o utils.o +snd-soc-avs-objs := dsp.o ipc.o messages.o utils.o core.o loader.o obj-$(CONFIG_SND_SOC_INTEL_AVS) += snd-soc-avs.o
sound/soc/intel/avs/avs.h +17 -0
@@ -10,8 +10,11 @@#define __SOUND_SOC_INTEL_AVS_H#include <linux/device.h> +#include <linux/firmware.h> #include <sound/hda_codec.h> +#include <sound/hda_register.h> #include "messages.h" +#include "registers.h" struct avs_dev ;
@@ -32,6 +35,9 @@ struct avs_dsp_ops {irqreturn_t (*const irq_handler)(int ,void *);irqreturn_t (*const irq_thread)(int ,void *);void (*const int_control)(struct avs_dev *,bool ); +int (*const load_basefw)(struct avs_dev *,struct firmware *); +int (*const load_lib)(struct avs_dev *,struct firmware *,u32 ); +int (*const transfer_mods)(struct avs_dev *,bool ,struct avs_module_entry *,u32 ); };#define avs_dsp_op (adev, op, ...) \
@@ -45,6 +51,7 @@ struct avs_spec {const char *name;const struct avs_dsp_ops *const dsp_ops; +struct avs_fw_version min_fw_version;/* anything below is rejected */ const u32 core_init_mask;/* used during DSP boot */ const u64 attributes;/* bitmask of AVS_PLATATTR_* */
@@ -90,6 +97,7 @@ struct avs_dev {struct ida ppl_ida;struct list_head fw_list;int *core_refs;/* reference count per core */ +char **lib_names;struct completion fw_ready; };
@@ -215,4 +223,13 @@ int avs_dsp_create_pipeline(struct avs_dev *adev, u16 req_size, u8 priority, bool lp, u16 attributes, u8 *instance_id);int avs_dsp_delete_pipeline (struct avs_dev *adev,u8 instance_id); +/* Firmware loading */ + +void avs_hda_clock_gating_enable (struct avs_dev *adev,bool enable); +void avs_hda_power_gating_enable (struct avs_dev *adev,bool enable); +void avs_hda_l1sen_enable (struct avs_dev *adev,bool enable); + +int avs_dsp_boot_firmware (struct avs_dev *adev,bool purge); +int avs_dsp_first_boot_firmware (struct avs_dev *adev); +#endif /* __SOUND_SOC_INTEL_AVS_H */
sound/soc/intel/avs/core.c new file +61 -0
61 lines not on this page · raw message
sound/soc/intel/avs/dsp.c +26 -0
@@ -198,6 +198,7 @@ int avs_dsp_init_module(struct avs_dev *adev, u16 module_id, u8 ppl_instance_id, u16 *instance_id) {struct avs_module_entry mentry; +bool was_loaded = false;int ret, id; id =avs_module_id_alloc (adev, module_id);
@@ -212,6 +213,16 @@ int avs_dsp_init_module(struct avs_dev *adev, u16 module_id, u8 ppl_instance_id,if (ret) goto err_mod_entry; +/* Load code into memory if this is the first instance. */ +if (!id && !avs_module_entry_is_loaded (&mentry)) { + ret =avs_dsp_op (adev, transfer_mods, true, &mentry,1 ); +if (ret) { +dev_err (adev->dev,"load modules failed: %d\n" , ret); + goto err_mod_entry; + } + was_loaded = true; + } + ret =avs_ipc_init_instance (adev, module_id, id, ppl_instance_id, core_id, domain, param, param_size);if (ret) {
@@ -223,6 +234,8 @@ int avs_dsp_init_module(struct avs_dev *adev, u16 module_id, u8 ppl_instance_id,return 0 ; err_ipc: +if (was_loaded) +avs_dsp_op (adev, transfer_mods, false, &mentry,1 );avs_dsp_put_core (adev, core_id); err_mod_entry:avs_module_id_free (adev, module_id, id);
@@ -232,12 +245,25 @@ int avs_dsp_init_module(struct avs_dev *adev, u16 module_id, u8 ppl_instance_id,void avs_dsp_delete_module (struct avs_dev *adev,u16 module_id,u16 instance_id,u8 ppl_instance_id,u8 core_id) { +struct avs_module_entry mentry; +int ret; +/* Modules not owned by any pipeline need to be freed explicitly. */ if (ppl_instance_id ==INVALID_PIPELINE_ID )avs_ipc_delete_instance (adev, module_id, instance_id);avs_module_id_free (adev, module_id, instance_id); + ret =avs_get_module_id_entry (adev, module_id, &mentry); +/* Unload occupied memory if this was the last instance. */ +if (!ret && mentry.type.load_type ==AVS_MODULE_LOAD_TYPE_LOADABLE ) { +if (avs_is_module_ida_empty (adev, module_id)) { + ret =avs_dsp_op (adev, transfer_mods, false, &mentry,1 ); +if (ret) +dev_err (adev->dev,"unload modules failed: %d\n" , ret); + } + } +avs_dsp_put_core (adev, core_id); }
sound/soc/intel/avs/loader.c new file +235 -0
235 lines not on this page · raw message
sound/soc/intel/avs/registers.h +6 -0
@@ -9,6 +9,12 @@#ifndef __SOUND_SOC_INTEL_AVS_REGS_H#define __SOUND_SOC_INTEL_AVS_REGS_H +#define AZX_PCIREG_PGCTL 0x44 +#define AZX_PCIREG_CGCTL 0x48 +#define AZX_PGCTL_LSRMD_MASK BIT(4) +#define AZX_CGCTL_MISCBDCGE_MASK BIT(6) +#define AZX_VS_EM2_L1SEN BIT(13) +/* Intel HD Audio General DSP Registers */ #define AVS_ADSP_GEN_BASE 0x0#define AVS_ADSP_REG_ADSPCS (AVS_ADSP_GEN_BASE + 0x04)
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 15/17 ASoC: Intel: avs: Implement CLDMA transfer
In reply to Cezary RojewskiSKL and KBL rely on a dedicated HDAudio DMA stream for code loading and authentication. The implementation of this specific mechanism for SKL-based platforms re-uses HDAudio DMA (streaming) functions found in HDA library to avoid duplication of functionality.
--- sound/soc/intel/avs/Makefile | 1 + sound/soc/intel/avs/cldma.c | 316 ++++++++++++++++++++++++++++++++ sound/soc/intel/avs/cldma.h | 29 +++ sound/soc/intel/avs/registers.h | 2 + 4 files changed, 348 insertions(+) create mode 100644 sound/soc/intel/avs/cldma.c create mode 100644 sound/soc/intel/avs/cldma.h
sound/soc/intel/avs/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only snd-soc-avs-objs := dsp.o ipc.o messages.o utils.o core.o loader.o +snd-soc-avs-objs += cldma.o obj-$(CONFIG_SND_SOC_INTEL_AVS) += snd-soc-avs.o
sound/soc/intel/avs/cldma.c new file +316 -0
316 lines not on this page · raw message
sound/soc/intel/avs/cldma.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright(c) 2021-2022 Intel Corporation. All rights reserved. +* +* Author: Cezary Rojewski <[email protected]> +*/ + +#ifndef __SOUND_SOC_INTEL_AVS_CLDMA_H +#define __SOUND_SOC_INTEL_AVS_CLDMA_H + +#define AVS_CL_DEFAULT_BUFFER_SIZE (32 * PAGE_SIZE) + +struct hda_cldma ; +extern struct hda_cldma code_loader; + +void hda_cldma_fill (struct hda_cldma *cl); +void hda_cldma_transfer (struct hda_cldma *cl,unsigned long start_delay); + +int hda_cldma_start (struct hda_cldma *cl); +int hda_cldma_stop (struct hda_cldma *cl); +int hda_cldma_reset (struct hda_cldma *cl); + +void hda_cldma_set_data (struct hda_cldma *cl,void *data,unsigned int size); +void hda_cldma_setup (struct hda_cldma *cl); +int hda_cldma_init (struct hda_cldma *cl,struct hdac_bus *bus,void __iomem *dsp_ba, +unsigned int buffer_size); +void hda_cldma_free (struct hda_cldma *cl); + +#endif
sound/soc/intel/avs/registers.h +2 -0
@@ -22,7 +22,9 @@#define AVS_ADSP_REG_ADSPIS (AVS_ADSP_GEN_BASE + 0x0C)#define AVS_ADSP_ADSPIC_IPC BIT(0) +#define AVS_ADSP_ADSPIC_CLDMA BIT(1)#define AVS_ADSP_ADSPIS_IPC BIT(0) +#define AVS_ADSP_ADSPIS_CLDMA BIT(1)#define AVS_ADSPCS_CRST_MASK (cm) (cm)#define AVS_ADSPCS_CSTALL_MASK (cm) ((cm) << 8)
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 16/17 ASoC: Intel: avs: Code loading over CLDMA
In reply to Cezary RojewskiWith CLDMA transfer implemented, make use of it to shape firmware, library and module loading routines for SKL and KBL platforms.
--- sound/soc/intel/avs/avs.h | 7 ++ sound/soc/intel/avs/loader.c | 159 +++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+)
sound/soc/intel/avs/avs.h +7 -0
@@ -43,6 +43,8 @@ struct avs_dsp_ops {#define avs_dsp_op (adev, op, ...) \ ((adev)->spec->dsp_ops->op(adev, ## __VA_ARGS__)) +#define AVS_PLATATTR_CLDMA BIT_ULL(0) +#define avs_platattr_test (adev, attr) \ ((adev)->spec->attributes & AVS_PLATATTR_##attr)
@@ -232,4 +234,9 @@ void avs_hda_l1sen_enable(struct avs_dev *adev, bool enable);int avs_dsp_boot_firmware (struct avs_dev *adev,bool purge);int avs_dsp_first_boot_firmware (struct avs_dev *adev); +int avs_cldma_load_basefw (struct avs_dev *adev,struct firmware *fw); +int avs_cldma_load_library (struct avs_dev *adev,struct firmware *lib,u32 id); +int avs_cldma_transfer_modules (struct avs_dev *adev,bool load, +struct avs_module_entry *mods,u32 num_mods); +#endif /* __SOUND_SOC_INTEL_AVS_H */
sound/soc/intel/avs/loader.c +159 -0
183 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v5 17/17 ASoC: Intel: avs: Code loading over HDA
In reply to Cezary RojewskiCompared to SKL and KBL, more recent cAVS platforms are meant to re-use one of HDAudio streams during boot procedure causing CLDMA to become obsolete. Once transferred, given stream is returned to pool available for audio streaming.
Module loading handler is stub as library and module code became inseparable in later firmware generations.
--- sound/soc/intel/Kconfig | 1 + sound/soc/intel/avs/avs.h | 5 + sound/soc/intel/avs/loader.c | 214 +++++++++++++++++++++++++++++++++++ 3 files changed, 220 insertions(+)
sound/soc/intel/Kconfig +1 -0
@@ -215,6 +215,7 @@ config SND_SOC_INTEL_AVS depends on COMMON_CLK select SND_SOC_ACPI select SND_HDA_EXT_CORE + select SND_HDA_DSP_LOADER help Enable support for Intel(R) cAVS 1.5 platforms with DSP capabilities. This includes Skylake, Kabylake, Amberlake and
sound/soc/intel/avs/avs.h +5 -0
@@ -44,6 +44,7 @@ struct avs_dsp_ops { ((adev)->spec->dsp_ops->op(adev, ## __VA_ARGS__))#define AVS_PLATATTR_CLDMA BIT_ULL(0) +#define AVS_PLATATTR_IMR BIT_ULL(1)#define avs_platattr_test (adev, attr) \ ((adev)->spec->attributes & AVS_PLATATTR_##attr)
@@ -238,5 +239,9 @@ int avs_cldma_load_basefw(struct avs_dev *adev, struct firmware *fw);int avs_cldma_load_library (struct avs_dev *adev,struct firmware *lib,u32 id);int avs_cldma_transfer_modules (struct avs_dev *adev,bool load,struct avs_module_entry *mods,u32 num_mods); +int avs_hda_load_basefw (struct avs_dev *adev,struct firmware *fw); +int avs_hda_load_library (struct avs_dev *adev,struct firmware *lib,u32 id); +int avs_hda_transfer_modules (struct avs_dev *adev,bool load, +struct avs_module_entry *mods,u32 num_mods);#endif /* __SOUND_SOC_INTEL_AVS_H */
sound/soc/intel/avs/loader.c +214 -0
240 lines not on this page · raw message
Signature · 1 line
2.25.1
Mark Brown
maintainerQuoted 14 lines · Cezary Rojewski
A continuation of cleanup work of Intel SST solutions found in
sound/soc/intel/. With two major chapters released last year catpt [1] and removal of haswell solution [2], time has come for Skylake-driver.Througout 2019, 2020 and 2021 Skylake-driver has had many fixes applied and even attempts of refactors as seen in fundamental overhaul [3], IPC flow adjustments [4] and
LARGE_CONFIGoverhaul [5] series. Unfortunately, story repeats itself - problems are found within the core of a driver. Painting it with different colors does not change the fact that is it still a house of cards. As changes needed to address those issues would make Skylake solution incompatible with its previous revisions, a decision has been made to provide a new solution instead. In time it would deprecate and replace Skylake-driver.
Quoted 1 line
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/17] ALSA: hda: Add helper macros for DSP capable devices
commit: c19bd02e9029f0f75b58f4b8662527da74be8985
[02/17] ASoC: Export DAI register and widget ctor and dctor functions
commit: da0398099a83483014adc509a2845c88ccf672af
[03/17] ASoC: Intel: Introduce AVS driver
commit: 9fe51c559a862d6c884f6784de26c8f9463187b1
[04/17] ASoC: Intel: avs: Inter process communication
commit: 2879516fcd6d7ec5972762dbd94859d9221e70d8
[05/17] ASoC: Intel: avs: Add code loading requests
commit: cb1eb6b5be42799d23f81ffde84ee3537365b0ed
[06/17] ASoC: Intel: avs: Add pipeline management requests
commit: b956b27b477ae63e92240f813c1027de601df11f
[07/17] ASoC: Intel: avs: Add module management requests
commit: f14a1c5a9f830025dc8638303ddefd5f731ae4bc
[08/17] ASoC: Intel: avs: Add power management requests
commit: 469e87ca9a2029c325362496c7b589683a382505
[09/17] ASoC: Intel: avs: Add ROM requests
commit: 25f414fcdb875e4203ff43f42898367c32df4827
[10/17] ASoC: Intel: avs: Add basefw runtime-parameter requests
commit: 3322e1688953966da15fcd0ae3183a351e241ea3
[11/17] ASoC: Intel: avs: Firmware resources management utilities
commit: c1a427e8da9332a5832fd4a5429adede34bfa85f
[12/17] ASoC: Intel: avs: Declare module configuration types
commit: 580a5912d1fe774f9902b614fa33e1add92ca749
[13/17] ASoC: Intel: avs: Dynamic firmware resources management
commit: 215e67b2d2de1d8d34a53c440b9a19a732ee6fb0
[14/17] ASoC: Intel: avs: General code loading flow
commit: b27f452317236b0cbaa94c4498f8241e2ad871b1
[15/17] ASoC: Intel: avs: Implement CLDMA transfer
commit: 45864e49a05aa446b9d99c464c1a9f46956ed32c
[16/17] ASoC: Intel: avs: Code loading over CLDMA
commit: 65794fe1a5f6f5fb10fa7b71a762158332144855
[17/17] ASoC: Intel: avs: Code loading over HDA
commit: 092cf7b26a48a542d9aabfc0f517fa263102a4c1All 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
Mark Brown
maintainerQuoted 3 lines · Cezary Rojewski
A continuation of cleanup work of Intel SST solutions found in
sound/soc/intel/. With two major chapters released last year catpt [1] and removal of haswell solution [2], time has come for Skylake-driver.
I've applied this but please do look at some of the clarifications that Pierre is asking for - there probably is some room for improvement there, but nothing that's going to require a restructuring of the whole codebase so it seems better to apply and look at things incrementally than to have to recheck the whole series again. Splitting this into easier to digest chunks is helping.
Cezary Rojewski
maintainerQuoted 11 lines · Mark Brown
Quoted 3 lines · Cezary Rojewski
A continuation of cleanup work of Intel SST solutions found in
sound/soc/intel/. With two major chapters released last year catpt [1] and removal of haswell solution [2], time has come for Skylake-driver.I've applied this but please do look at some of the clarifications that Pierre is asking for - there probably is some room for improvement there, but nothing that's going to require a restructuring of the whole codebase so it seems better to apply and look at things incrementally than to have to recheck the whole series again. Splitting this into easier to digest chunks is helping.
Every comment and review is taken seriously.
I'll sync with the team shortly and proceed with the discussion around "avs path" series too. Did not want to spam the list with several avs-related topics at once and thus the delay.
Regards,
Czarek