ASoC: Intel: AVS - Audio DSP for cAVS
Subsystems (3)
Cezary Rojewski
maintainerv3 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 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 | 2 + 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 | 248 +++++++++++ sound/soc/intel/avs/cldma.c | 317 ++++++++++++++ sound/soc/intel/avs/cldma.h | 29 ++ sound/soc/intel/avs/core.c | 62 +++ sound/soc/intel/avs/dsp.c | 303 +++++++++++++ sound/soc/intel/avs/ipc.c | 393 +++++++++++++++++ sound/soc/intel/avs/loader.c | 607 +++++++++++++++++++++++++ sound/soc/intel/avs/messages.c | 697 +++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 753 ++++++++++++++++++++++++++++++++ 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, 3873 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 v3 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 | 2 ++ include/sound/hdaudio_ext.h | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+)
include/sound/hdaudio.h +2 -0
@@ -448,6 +448,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
Cezary Rojewski
maintainerPATCH v3 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 v3 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 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
Re: [PATCH v3 03/17] ASoC: Intel: Introduce AVS driver
Quoted 91 lines · Cezary Rojewski
Declare 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.Signed-off-by: Amadeusz Sławiński <
[email protected]>Signed-off-by Cezary Rojewski <[email protected]>--- 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.hsound/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.osound/soc/intel/avs/avs.h new file +17
-0@@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright(c) 2021 Intel Corporation. All rights reserved. +* +* Authors: Cezary Rojewski <[email protected]> +* Amadeusz Slawinski <[email protected]> +*/ + +#ifndef __SOUND_SOC_INTEL_AVS_H +#define __SOUND_SOC_INTEL_AVS_H + +#include <linux/device.h> +#include <sound/hda_codec.h> + +struct avs_dev ; + +struct avs_dsp_ops {
sound/soc/intel/avs/avs.h line 27
Quoted 10 lines
sound/soc/intel/avs/avs.h new file +10
-0+int (*const power)(struct avs_dev *,u32 ,bool ); +int (*const reset)(struct avs_dev *,u32 ,bool ); +int (*const stall)(struct avs_dev *,u32 ,bool ); +}; + +#define avs_dsp_op (adev, op, ...) \ + ((adev)->spec->dsp_ops->op(adev, ## __VA_ARGS__)) + +#define avs_platattr_test (adev, attr) \ + ((adev)->spec->attributes & AVS_PLATATTR_##attr)
AVS_PLATATTR_* don't seem to be defined in this patch?
Thanks,
Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 03/17] ASoC: Intel: Introduce AVS driver
On 2022-03-04 4:51 PM, Ranjani Sridharan wrote:
...
Quoted 21 lines
Quoted 9 lines
sound/soc/intel/avs/avs.h new file +9
-0+#ifndef __SOUND_SOC_INTEL_AVS_H +#define __SOUND_SOC_INTEL_AVS_H + +#include <linux/device.h> +#include <sound/hda_codec.h> + +struct avs_dev ; + +struct avs_dsp_ops {sound/soc/intel/avs/avs.h line 27
Quoted 10 lines
sound/soc/intel/avs/avs.h new file +10
-0+int (*const power)(struct avs_dev *,u32 ,bool ); +int (*const reset)(struct avs_dev *,u32 ,bool ); +int (*const stall)(struct avs_dev *,u32 ,bool ); +}; + +#define avs_dsp_op (adev, op, ...) \ + ((adev)->spec->dsp_ops->op(adev, ## __VA_ARGS__)) + +#define avs_platattr_test (adev, attr) \ + ((adev)->spec->attributes & AVS_PLATATTR_##attr)AVS_PLATATTR_* don't seem to be defined in this patch?
Quoted 3 lines
Thanks,
Ranjani
Thanks for feedback! Consider dropping the unnecessary bits so it is easier to navigate through your responses.
Yes, AVS_PLATATTR_ constants were split from this patch. This patch defines just base API instead.
Regards,
Czarek
Cezary Rojewski
maintainerPATCH v3 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 | 387 ++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 170 ++++++++++++++ sound/soc/intel/avs/registers.h | 45 ++++ 5 files changed, 703 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 +387 -0
387 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
Re: [PATCH v3 04/17] ASoC: Intel: avs: Inter process communication
Quoted 153 lines · Cezary Rojewski
Implement 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.Signed-off-by: Amadeusz Sławiński <
[email protected]>Signed-off-by Cezary Rojewski <[email protected]>--- sound/soc/intel/avs/Makefile | 2 +- sound/soc/intel/avs/avs.h | 100 +++++++++ sound/soc/intel/avs/ipc.c | 387 ++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 170 ++++++++++++++ sound/soc/intel/avs/registers.h | 45 ++++ 5 files changed, 703 insertions(+), 1 deletion(-) create mode 100644 sound/soc/intel/avs/ipc.c create mode 100644 sound/soc/intel/avs/messages.hsound/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.osound/soc/intel/avs/avs.h +17
-0@@ -11,13 +11,27 @@#include <linux/device.h> #include <sound/hda_codec.h> +#include "messages.h" struct avs_dev ; +/* +* struct avs_dsp_ops - Platform-specific DSP operations +* +* @power: Power on or off DSP cores +* @reset: Enter or exit reset state on DSP cores +* @stall: Stall or run DSP cores +* @irq_handler: Top half of IPC servicing +* @irq_thread: Bottom half of IPC servicing +* @int_control: Enable or disable IPC interrupts +*/ struct avs_dsp_ops {int (*const power)(struct avs_dev *,u32 ,bool );int (*const reset)(struct avs_dev *,u32 ,bool );int (*const stall)(struct avs_dev *,u32 ,bool ); +irqreturn_t (*const irq_handler)(int ,void *); +irqreturn_t (*const irq_thread)(int ,void *); +void (*const int_control)(struct avs_dev *,bool ); };#define avs_dsp_op (adev, op, ...) \@@ -34,6 +48,9 @@ struct avs_spec {const u32 core_init_mask;/* used during DSP boot */ const u64 attributes;/* bitmask of AVS_PLATATTR_* */ +const u32 sram_base_offset; +const u32 sram_window_size; +const u32 rom_status; };/*
sound/soc/intel/avs/avs.h +23
-0@@ -49,6 +66,9 @@ struct avs_dev {void __iomem *dsp_ba;const struct avs_spec *spec; +struct avs_ipc *ipc; + +struct completion fw_ready; };/* from hda_bus to avs_dev */ @@ -68,4 +88,84 @@ int avs_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stall);int avs_dsp_core_enable (struct avs_dev *adev,u32 core_mask);int avs_dsp_core_disable (struct avs_dev *adev,u32 core_mask); +/* Inter Process Communication */ + +struct avs_ipc_msg { +union { +u64 header; +union avs_global_msg glb; +union avs_reply_msg rsp; + }; +void *data; +size_t size; +}; + +/* +* struct avs_ipc - DSP IPC context +* +* @dev: PCI device +* @rx: Reply message cache +* @default_timeout_ms: default message timeout in MS +* @ready: whether firmware is ready and communication is open +* @rx_completed: whether RX for previously sent TX has been received
+ * @rx_lock: for serializating manipulation of rx_* fields
+ * @msg_lock: for synchronizing request handling
+ * @done_completion: DONE-part of IPC i.e. ROM and ACKs from FW
+ * @busy_completion: BUSY-part of IPC i.e. receiving responses from FW
+ */sound/soc/intel/avs/avs.h +17
-0+struct avs_ipc { +struct device *dev; + +struct avs_ipc_msg rx; +u32 default_timeout_ms; +bool ready; + +bool rx_completed; +spinlock_t rx_lock; +struct mutex msg_mutex; +struct completion done_completion; +struct completion busy_completion; +}; + +#define AVS_EIPC EREMOTEIO +/* +* IPC handlers may return positive value (firmware error code) what denotes
+ * successful HOST <-> DSP communication yet failure to process specific request.
+ *
+ * Below macro converts returned value to linux kernel error code.
+ * All IPC callers MUST use it as soon as firmware error code is consumed.
+ */sound/soc/intel/avs/avs.h +4
-0+#define AVS_IPC_RET (ret) \ + (((ret) <= 0) ? (ret) : -AVS_EIPC) + +static inline void avs_ipc_err(struct avs_dev *adev, struct
avs_ipc_msg*tx,
sound/soc/intel/avs/avs.h int avs_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stall); · line 145
Quoted 4 lines
sound/soc/intel/avs/avs.h +4
-0+ const char *name, int error) +{ +/* +* If IPC channel is blocked e.g.: due to ongoing recovery,
Do you mean firmware recovery? In which cases do you perform a recovery?
Quoted 2 lines
sound/soc/intel/avs/avs.h +1
-0+* -EPERM error code is expected and thus it's not an actual error.
And what happens in this case? do you retry the IPC after recovery?
Quoted 59 lines
sound/soc/intel/avs/avs.h +3
-0+*/ +if (error == -EPERM ) + dev_dbg(adev->dev, "%s 0x%08x 0x%08x failed: %d\n",name,
sound/soc/intel/avs/avs.h +3
-0+ tx->glb.primary, tx->glb.ext.val, error); + else + dev_err(adev->dev, "%s 0x%08x 0x%08x failed: %d\n",name,
sound/soc/intel/avs/avs.h +11
-0+ tx->glb.primary, tx->glb.ext.val, error); +} + +irqreturn_t avs_dsp_irq_handler (int irq,void *dev_id); +irqreturn_t avs_dsp_irq_thread (int irq,void *dev_id); +void avs_dsp_process_response (struct avs_dev *adev,u64 header); +int avs_dsp_send_msg_timeout (struct avs_dev *adev, +struct avs_ipc_msg *request, +struct avs_ipc_msg *reply,int timeout); +int avs_dsp_send_msg (struct avs_dev *adev, + struct avs_ipc_msg *request, struct avs_ipc_msg*reply);
sound/soc/intel/avs/avs.h +2
-0+int avs_dsp_send_rom_msg_timeout (struct avs_dev *adev, + struct avs_ipc_msg *request, inttimeout);
+intavs_dsp_send_rom_msg(struct avs_dev *adev, struct avs_ipc_msg *request);sound/soc/intel/avs/avs.h +4
-0+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); +#endif /* __SOUND_SOC_INTEL_AVS_H */ sound/soc/intel/avs/ipc.c new file +23
-0@@ -0,0 +1,387 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright(c) 2021 Intel Corporation. All rights reserved. +// +// Authors: Cezary Rojewski <[email protected]> +// Amadeusz Slawinski <[email protected]> +// + +#include <linux/slab.h> +#include <sound/hdaudio_ext.h> +#include "avs.h" +#include "messages.h" +#include "registers.h" + +#define AVS_IPC_TIMEOUT_MS 300 + +static void avs_dsp_receive_rx (struct avs_dev *adev,u64 header) +{ +struct avs_ipc *ipc = adev->ipc; +union avs_reply_msg msg =AVS_MSG (header); + + ipc->rx.header = header; +/* Abort copying payload if request processing was
Quoted 1 line
unsuccessful. */
This seems misplaced? Why would you called this function is the status showed an error?
Quoted 41 lines
sound/soc/intel/avs/ipc.c new file +6
-0+if (!msg.status) +memcpy_fromio (ipc->rx.data,avs_uplink_addr (adev), + ipc->rx.size); +} + +static void avs_dsp_process_notification(struct avs_dev *adev, u64header)
sound/soc/intel/avs/ipc.c new file +7
-0+{ +struct avs_notify_mod_data mod_data; +union avs_notify_msg msg =AVS_MSG (header); +size_t data_size =0 ; +void *data =NULL ; + +/* Ignore spurious notifications until handshake is established. */
sound/soc/intel/avs/ipc.c new file +1
-0+ if (!adev->ipc->ready && msg.notify_msg_type !=
AVS_NOTIFY_FW_READY) {sound/soc/intel/avs/ipc.c new file +1
-0+ dev_dbg(adev->dev, "FW not ready, skip notification:0x%08x\n",
sound/soc/intel/avs/ipc.c new file +19
-0+ msg.primary); +return ; + } + +/* Calculate notification payload size. */ +switch (msg.notify_msg_type) { +case AVS_NOTIFY_FW_READY : +break ; + +case AVS_NOTIFY_PHRASE_DETECTED : + data_size =sizeof (struct avs_notify_voice_data ); +break ; + +case AVS_NOTIFY_RESOURCE_EVENT : + data_size =sizeof (struct avs_notify_res_data ); +break ; + +case AVS_NOTIFY_MODULE_EVENT : +/* To know the total payload size, header needs to be read first. */
sound/soc/intel/avs/ipc.c new file +1
-0+ memcpy_fromio(&mod_data, avs_uplink_addr(adev),
sizeof(mod_data));
sound/soc/intel/avs/ipc.c line 64
Quoted 6 lines
sound/soc/intel/avs/ipc.c new file +6
-0+ data_size =sizeof (mod_data) + mod_data.data_size; +break ; + +default : +dev_info (adev->dev,"unknown notification: 0x%08x\n" , + msg.primary);
info? should it be a warning?
sound/soc/intel/avs/ipc.c line 71
Quoted 7 lines
sound/soc/intel/avs/ipc.c new file +7
-0+break ; + } + +if (data_size) { + data =kmalloc (data_size,GFP_KERNEL ); +if (!data) +return ;
Should this function be modified to return the error? If it failed here, all subsequent IPC's rec'd will also fail isnt it?
Quoted 7 lines
sound/soc/intel/avs/ipc.c new file +7
-0+ +memcpy_fromio (data,avs_uplink_addr (adev), data_size); + } + +/* Perform notification-specific operations. */ +switch (msg.notify_msg_type) { +case AVS_NOTIFY_FW_READY :
sound/soc/intel/avs/ipc.c line 88
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+dev_dbg (adev->dev,"FW READY 0x%08x\n" , msg.primary); + adev->ipc->ready = true; +complete (&adev->fw_ready); +break ; + +default : +break ; + } + +kfree (data);
You alloc memory for "data", copy the data and free it? Where is it used?
Quoted 169 lines
sound/soc/intel/avs/ipc.c new file +8
-0+} + +void avs_dsp_process_response (struct avs_dev *adev,u64 header) +{ +struct avs_ipc *ipc = adev->ipc; + +/* +* Response may either be solicited - a reply for a request that has
sound/soc/intel/avs/ipc.c new file +33
-0+* been sent beforehand - or unsolicited (notification). +*/ +if (avs_msg_is_reply (header)) { +/* Response processing is invoked from IRQ thread. */ +spin_lock_irq (&ipc->rx_lock); +avs_dsp_receive_rx (adev, header); + ipc->rx_completed = true; +spin_unlock_irq (&ipc->rx_lock); + }else { +avs_dsp_process_notification (adev, header); + } + +complete (&ipc->busy_completion); +} + +irqreturn_t avs_dsp_irq_handler (int irq,void *dev_id) +{ +struct avs_dev *adev = dev_id; +struct avs_ipc *ipc = adev->ipc; +u32 adspis, hipc_rsp, hipc_ack; +irqreturn_t ret =IRQ_NONE ; + + adspis =snd_hdac_adsp_readl (adev,AVS_ADSP_REG_ADSPIS ); +if (adspis ==UINT_MAX || !(adspis &AVS_ADSP_ADSPIS_IPC )) +return ret; + + hipc_ack =snd_hdac_adsp_readl (adev,SKL_ADSP_REG_HIPCIE ); + hipc_rsp =snd_hdac_adsp_readl (adev,SKL_ADSP_REG_HIPCT ); + +/* DSP acked host's request */ +if (hipc_ack &SKL_ADSP_HIPCIE_DONE ) { +/* +* As an extra precaution, mask done interrupt. Code executed
sound/soc/intel/avs/ipc.c new file +1
-0+* due to complete() found below does not assume any masking.
sound/soc/intel/avs/ipc.c new file +49
-0+*/ +snd_hdac_adsp_updatel (adev,SKL_ADSP_REG_HIPCCTL , +AVS_ADSP_HIPCCTL_DONE ,0 ); + +complete (&ipc->done_completion); + +/* tell DSP it has our attention */ +snd_hdac_adsp_updatel (adev,SKL_ADSP_REG_HIPCIE , +SKL_ADSP_HIPCIE_DONE , +SKL_ADSP_HIPCIE_DONE ); +/* unmask done interrupt */ +snd_hdac_adsp_updatel (adev,SKL_ADSP_REG_HIPCCTL , +AVS_ADSP_HIPCCTL_DONE , +AVS_ADSP_HIPCCTL_DONE ); + ret =IRQ_HANDLED ; + } + +/* DSP sent new response to process */ +if (hipc_rsp &SKL_ADSP_HIPCT_BUSY ) { +/* mask busy interrupt */ +snd_hdac_adsp_updatel (adev,SKL_ADSP_REG_HIPCCTL , +AVS_ADSP_HIPCCTL_BUSY ,0 ); + + ret =IRQ_WAKE_THREAD ; + } + +return ret; +} + +irqreturn_t avs_dsp_irq_thread (int irq,void *dev_id) +{ +struct avs_dev *adev = dev_id; +union avs_reply_msg msg; +u32 hipct, hipcte; + + hipct =snd_hdac_adsp_readl (adev,SKL_ADSP_REG_HIPCT ); + hipcte =snd_hdac_adsp_readl (adev,SKL_ADSP_REG_HIPCTE ); + +/* ensure DSP sent new response to process */ +if (!(hipct &SKL_ADSP_HIPCT_BUSY )) +return IRQ_NONE ; + + msg.primary = hipct; + msg.ext.val = hipcte; +avs_dsp_process_response (adev, msg.val); + +/* tell DSP we accepted its message */ + snd_hdac_adsp_updatel(adev, SKL_ADSP_REG_HIPCT, + SKL_ADSP_HIPCT_BUSY,
SKL_ADSP_HIPCT_BUSY);sound/soc/intel/avs/ipc.c new file +3
-0+/* unmask busy interrupt */ + snd_hdac_adsp_updatel(adev, SKL_ADSP_REG_HIPCCTL, + AVS_ADSP_HIPCCTL_BUSY,
AVS_ADSP_HIPCCTL_BUSY);sound/soc/intel/avs/ipc.c new file +14
-0+ +return IRQ_HANDLED ; +} + +static bool avs_ipc_is_busy (struct avs_ipc *ipc) +{ +struct avs_dev *adev =to_avs_dev (ipc->dev); +u32 hipc_rsp; + + hipc_rsp =snd_hdac_adsp_readl (adev,SKL_ADSP_REG_HIPCT ); +return hipc_rsp &SKL_ADSP_HIPCT_BUSY ; +} + +static int avs_ipc_wait_busy_completion(struct avs_ipc *ipc, inttimeout)
sound/soc/intel/avs/ipc.c new file +42
-0+{ +u32 repeats_left =128 ;/* to avoid infinite looping */ +int ret; + +again: + ret =wait_for_completion_timeout (&ipc->busy_completion, +msecs_to_jiffies (timeout)); + +/* DSP could be unresponsive at this point. */ +if (!ipc->ready) +return -EPERM ; + +if (!ret) { +if (!avs_ipc_is_busy (ipc)) +return -ETIMEDOUT ; +/* +* Firmware did its job, either notification or reply +* has been received - now wait until it's processed. +*/ +wait_for_completion_killable (&ipc->busy_completion); + } + +/* Ongoing notification's bottom-half may cause early wakeup */ +spin_lock (&ipc->rx_lock); +if (!ipc->rx_completed) { +if (repeats_left) { +/* Reply delayed due to notification. */ + repeats_left--; +reinit_completion (&ipc->busy_completion); +spin_unlock (&ipc->rx_lock); + goto again; + } + +spin_unlock (&ipc->rx_lock); +return -ETIMEDOUT ; + } + +spin_unlock (&ipc->rx_lock); +return 0 ; +} + +static void avs_ipc_msg_init(struct avs_ipc *ipc, struct avs_ipc_msg*reply)
sound/soc/intel/avs/ipc.c new file +12
-0+{ +lockdep_assert_held (&ipc->rx_lock); + + ipc->rx.header =0 ; + ipc->rx.size = reply ? reply->size :0 ; + ipc->rx_completed = false; + +reinit_completion (&ipc->done_completion); +reinit_completion (&ipc->busy_completion); +} + +static void avs_dsp_send_tx(struct avs_dev *adev, struct avs_ipc_msg
Quoted 1 line
*tx)
send_tx? send and tx both imply the same isnt it? maybe just use one or the other?
Quoted 33 lines
sound/soc/intel/avs/ipc.c new file +5
-0+{ + tx->header |=SKL_ADSP_HIPCI_BUSY ; + +if (tx->size) + memcpy_toio(avs_downlink_addr(adev), tx->data, tx-Quoted 1 line
size);
sound/soc/intel/avs/ipc.c new file +1
-0+ snd_hdac_adsp_writel(adev, SKL_ADSP_REG_HIPCIE, tx->header >>32);
sound/soc/intel/avs/ipc.c new file +1
-0+ snd_hdac_adsp_writel(adev, SKL_ADSP_REG_HIPCI, tx->header &
UINT_MAX);sound/soc/intel/avs/ipc.c new file +3
-0+} + +static int avs_dsp_do_send_msg(struct avs_dev *adev, struct
avs_ipc_msg*request,sound/soc/intel/avs/ipc.c new file +19
-0+ struct avs_ipc_msg *reply, int timeout) +{ +struct avs_ipc *ipc = adev->ipc; +int ret; + +if (!ipc->ready) +return -EPERM ; + +mutex_lock (&ipc->msg_mutex); + +spin_lock (&ipc->rx_lock); +avs_ipc_msg_init (ipc, reply); +avs_dsp_send_tx (adev, request); +spin_unlock (&ipc->rx_lock); + + ret =avs_ipc_wait_busy_completion (ipc, timeout); +if (ret) { +if (ret == -ETIMEDOUT ) { + dev_crit(adev->dev, "communication severed: %d,
Quoted 1 line
rebooting dsp..\n",
Where does this reboot happen?
Thanks,
Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 04/17] ASoC: Intel: avs: Inter process communication
Quoted 1 line · Ranjani Sridharan
On Fri, 2022-03-04 at 15:57 +0100, Cezary Rojewski wrote:
...
Quoted 8 lines
sound/soc/intel/avs/avs.h int avs_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stall); · line 145
Quoted 6 lines
+static inline void avs_ipc_err(struct
avs_dev*adev, structavs_ipc_msg*tx,sound/soc/intel/avs/avs.h +4
-0+ const char *name, int error) +{ +/* +* If IPC channel is blocked e.g.: due to ongoing recovery, Do you mean firmware recovery? In which cases do you perform a recovery?
Thanks for feedback! Consider dropping the unnecessary bits so it is easier to navigate through your responses.
Please note: kernel mailing list is not for explaining SW <-> FW communication details. Feel free to contact my colleagues from firmware team if in need of any FW-iface details.
That goes for most of the comments found below too.
-
Yes, I mean firmware recovery here. Code found in this patchset shows that message timeout is one of the reasons.
Quoted 3 lines
Quoted 2 lines
(quoted diff) +1
-0+ * -EPERM error code is expected and thus it's not an actualerror.
And what happens in this case? do you retry the IPC after recovery?
Not at all. Why would you want retry IPC after recovery in the first place?
Quoted 54 lines
Quoted 54 lines
sound/soc/intel/avs/avs.h +3
-0+*/ +if (error == -EPERM ) + dev_dbg(adev->dev, "%s 0x%08x 0x%08x failed: %d\n",name,
sound/soc/intel/avs/avs.h +3
-0+ tx->glb.primary, tx->glb.ext.val, error); + else + dev_err(adev->dev, "%s 0x%08x 0x%08x failed: %d\n",name,
sound/soc/intel/avs/avs.h +11
-0+ tx->glb.primary, tx->glb.ext.val, error); +} + +irqreturn_t avs_dsp_irq_handler (int irq,void *dev_id); +irqreturn_t avs_dsp_irq_thread (int irq,void *dev_id); +void avs_dsp_process_response (struct avs_dev *adev,u64 header); +int avs_dsp_send_msg_timeout (struct avs_dev *adev, +struct avs_ipc_msg *request, +struct avs_ipc_msg *reply,int timeout); +int avs_dsp_send_msg (struct avs_dev *adev, + struct avs_ipc_msg *request, struct avs_ipc_msg*reply);
(quoted diff) +2
-0+int avs_dsp_send_rom_msg_timeout(struct avs_dev *adev, + struct avs_ipc_msg *request, inttimeout);
+intavs_dsp_send_rom_msg(struct avs_dev *adev, struct avs_ipc_msg *request);sound/soc/intel/avs/avs.h +4
-0+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); +#endif /* __SOUND_SOC_INTEL_AVS_H */ sound/soc/intel/avs/ipc.c new file +18
-0@@ -0,0 +1,387 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright(c) 2021 Intel Corporation. All rights reserved. +// +// Authors: Cezary Rojewski <[email protected]> +// Amadeusz Slawinski <[email protected]> +// + +#include <linux/slab.h> +#include <sound/hdaudio_ext.h> +#include "avs.h" +#include "messages.h" +#include "registers.h" + +#define AVS_IPC_TIMEOUT_MS 300 + +static void avs_dsp_receive_rx (struct avs_dev *adev,u64 header) +{
Quoted 8 lines
Quoted 6 lines
sound/soc/intel/avs/ipc.c new file +5
-0+struct avs_ipc *ipc = adev->ipc; +union avs_reply_msg msg =AVS_MSG (header); + + ipc->rx.header = header; +/* Abort copying payload if request processing was unsuccessful. */
This seems misplaced? Why would you called this function is the status showed an error?
This comment is part of Pierre's feedback, not misplaced at all.
Header can be message-specific and contain valid info to perform even on failure.
Quoted 40 lines
Quoted 40 lines
sound/soc/intel/avs/ipc.c new file +6
-0+if (!msg.status) +memcpy_fromio (ipc->rx.data,avs_uplink_addr (adev), + ipc->rx.size); +} + +static void avs_dsp_process_notification(struct avs_dev *adev, u64header)
sound/soc/intel/avs/ipc.c new file +7
-0+{ +struct avs_notify_mod_data mod_data; +union avs_notify_msg msg =AVS_MSG (header); +size_t data_size =0 ; +void *data =NULL ; + +/* Ignore spurious notifications until handshake is established. */
sound/soc/intel/avs/ipc.c new file +1
-0+ if (!adev->ipc->ready && msg.notify_msg_type !=
AVS_NOTIFY_FW_READY) {sound/soc/intel/avs/ipc.c new file +1
-0+ dev_dbg(adev->dev, "FW not ready, skip notification:0x%08x\n",
sound/soc/intel/avs/ipc.c new file +19
-0+ msg.primary); +return ; + } + +/* Calculate notification payload size. */ +switch (msg.notify_msg_type) { +case AVS_NOTIFY_FW_READY : +break ; + +case AVS_NOTIFY_PHRASE_DETECTED : + data_size =sizeof (struct avs_notify_voice_data ); +break ; + +case AVS_NOTIFY_RESOURCE_EVENT : + data_size =sizeof (struct avs_notify_res_data ); +break ; + +case AVS_NOTIFY_MODULE_EVENT : +/* To know the total payload size, header needs to be read first. */
sound/soc/intel/avs/ipc.c new file +1
-0+ memcpy_fromio(&mod_data, avs_uplink_addr(adev),
Quoted 8 lines
sound/soc/intel/avs/ipc.c line 64
Quoted 7 lines
sizeof(mod_data));sound/soc/intel/avs/ipc.c new file +6
-0+ data_size =sizeof (mod_data) + mod_data.data_size; +break ; + +default : +dev_info (adev->dev,"unknown notification: 0x%08x\n" , + msg.primary);info? should it be a warning?
Pierre's feedback was exactly the opposite.
Quoted 9 lines
sound/soc/intel/avs/ipc.c line 71
Quoted 7 lines
sound/soc/intel/avs/ipc.c new file +7
-0+break ; + } + +if (data_size) { + data =kmalloc (data_size,GFP_KERNEL ); +if (!data) +return ;Should this function be modified to return the error? If it failed here, all subsequent IPC's rec'd will also fail isnt it?
Hmm.. we are servicing an IPC here, can't return an error code, really. Also, some memory could have been freed between IRQs.
Quoted 11 lines
Quoted 11 lines
sound/soc/intel/avs/ipc.c new file +11
-0+ +memcpy_fromio (data,avs_uplink_addr (adev), data_size); + } + +/* Perform notification-specific operations. */ +switch (msg.notify_msg_type) { +case AVS_NOTIFY_FW_READY : +dev_dbg (adev->dev,"FW READY 0x%08x\n" , msg.primary); + adev->ipc->ready = true; +complete (&adev->fw_ready); +break ;
Quoted 8 lines
sound/soc/intel/avs/ipc.c line 88
Quoted 6 lines
sound/soc/intel/avs/ipc.c new file +6
-0+ +default : +break ; + } + +kfree (data);You alloc memory for "data", copy the data and free it? Where is it used?
This patch implement the backbone for the entire IPC protocol. Specific handlers are not found here.
Quoted 9 lines
Quoted 9 lines
+static void
avs_ipc_msg_init(struct avs_ipc *ipc, struct avs_ipc_msg *reply)sound/soc/intel/avs/ipc.c new file +7
-0+{ +lockdep_assert_held (&ipc->rx_lock); + + ipc->rx.header =0 ; + ipc->rx.size = reply ? reply->size :0 ; + ipc->rx_completed = false; +
Quoted 8 lines
Quoted 6 lines
sound/soc/intel/avs/ipc.c new file +5
-0+reinit_completion (&ipc->done_completion); +reinit_completion (&ipc->busy_completion); +} + +static void avs_dsp_send_tx(struct avs_dev *adev, struct avs_ipc_msg*tx)
send_tx? send and tx both imply the same isnt it? maybe just use one or the other?
Matter of taste I believe. Also, aligned with the catpt-driver.
Quoted 15 lines
Quoted 15 lines
+static int avs_dsp_do_send_msg(struct
avs_dev*adev, structavs_ipc_msg*request,sound/soc/intel/avs/ipc.c new file +13
-0+ struct avs_ipc_msg *reply, int timeout) +{ +struct avs_ipc *ipc = adev->ipc; +int ret; + +if (!ipc->ready) +return -EPERM ; + +mutex_lock (&ipc->msg_mutex); + +spin_lock (&ipc->rx_lock); +avs_ipc_msg_init (ipc, reply); +avs_dsp_send_tx (adev, request);
Quoted 8 lines
Quoted 7 lines
sound/soc/intel/avs/ipc.c new file +6
-0+spin_unlock (&ipc->rx_lock); + + ret =avs_ipc_wait_busy_completion (ipc, timeout); +if (ret) { +if (ret == -ETIMEDOUT ) { + dev_crit(adev->dev, "communication severed: %d,rebooting dsp..\n",
Where does this reboot happen?
This patch implement the backbone for the entire IPC protocol. Specific handlers are not found here. Message remained.
Regards,
Czarek
Re: [PATCH v3 04/17] ASoC: Intel: avs: Inter process communication
Quoted 9 lines · Cezary Rojewski
Quoted 3 lines
Quoted 2 lines
+ *
-EPERMerror code is expected and thus it's not an actual
error.And what happens in this case? do you retry the IPC after recovery?
Not at all. Why would you want retry IPC after recovery in the first place?
So what happens after FW recovery? Will this lead to an xrun and cause usersapce to restart the stream?
Thanks,Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 04/17] ASoC: Intel: avs: Inter process communication
Quoted 8 lines · Ranjani Sridharan
Quoted 7 lines · Cezary Rojewski
Quoted 3 lines
Quoted 2 lines
+ *
-EPERMerror code is expected and thus it's not an actual
error.And what happens in this case? do you retry the IPC after recovery?
Quoted 4 lines
Quoted 2 lines
Not at all. Why would you want retry IPC after recovery in the first place?
So what happens after FW recovery? Will this lead to an xrun and cause usersapce to restart the stream?
If DSP dies so does the stream. Recovery is not guaranteed, it's an attempt. What userspace does with that is for userspace to decide.
Regards,
Czarek
Cezary Rojewski
maintainerPATCH v3 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 v3 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
Re: [PATCH v3 06/17] ASoC: Intel: avs: Add pipeline management requests
Quoted 73 lines · Cezary Rojewski
Pipeline represents a scheduling entity. Their existence as well as their state machine is controlled through
CREATE_PIPELINE,DELETE_PIPELINEandSET_PIPELINE_STATEIPCs.Signed-off-by: Amadeusz Sławiński <
[email protected]>Signed-off-by Cezary Rojewski <[email protected]>--- 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 +2
-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, u8priority,
sound/soc/intel/avs/messages.c +40
-0+ 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);sound/soc/intel/avs/messages.c +6
-0+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;
sound/soc/intel/avs/messages.c int avs_ipc_load_library(struct avs_dev *adev, u32 dma_id, u32 lib_id) · line 123
Quoted 10 lines
sound/soc/intel/avs/messages.c +10
-0+ + 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)
Can the pipeline state in the firmware change without the driver's knowledge? When should the driver use this get_pipeline_state()?
Thanks,Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 06/17] ASoC: Intel: avs: Add pipeline management requests
Quoted 4 lines · Ranjani Sridharan
Quoted 3 lines · Cezary Rojewski
Pipeline represents a scheduling entity. Their existence as well as their state machine is controlled through
CREATE_PIPELINE,DELETE_PIPELINEandSET_PIPELINE_STATEIPCs.
...
Quoted 15 lines
Quoted 15 lines
sound/soc/intel/avs/messages.c +4
-0+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);sound/soc/intel/avs/messages.c +10
-0+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);
Quoted 8 lines
sound/soc/intel/avs/messages.c int avs_ipc_load_library(struct avs_dev *adev, u32 dma_id, u32 lib_id) · line 123
Quoted 6 lines
sound/soc/intel/avs/messages.c +6
-0+ +return ret; +} + +int avs_ipc_get_pipeline_state (struct avs_dev *adev,u8 instance_id, +enum avs_pipeline_state *state)Can the pipeline state in the firmware change without the driver's knowledge? When should the driver use this
get_pipeline_state()?
Thanks for feedback! Consider dropping the unnecessary bits so it is easier to navigate through your responses.
Please note: kernel mailing list is not for explaining SW <-> FW communication details. Feel free to contact my colleagues from firmware team if in need of any FW-iface details.
-
Actual state machine is found in the firmware, not in the driver. Driver may use such information when profiling and also during debug.
Regards,
Czarek
Cezary Rojewski
maintainerPATCH v3 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.
--- sound/soc/intel/avs/ipc.c | 8 +- sound/soc/intel/avs/messages.c | 262 +++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 53 +++++++ 3 files changed, 322 insertions(+), 1 deletion(-)
sound/soc/intel/avs/ipc.c +7 -1
@@ -21,9 +21,15 @@ 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 +262 -0
271 lines not on this page · raw message
sound/soc/intel/avs/messages.h +53 -0
75 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v3 07/17] ASoC: Intel: avs: Add module management requests
Quoted 120 lines · Cezary Rojewski
Firmware 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 ofLARGE_CONFIGIPCs: getter and setter.Signed-off-by: Amadeusz Sławiński <
[email protected]>Signed-off-by Cezary Rojewski <[email protected]>--- sound/soc/intel/avs/ipc.c | 8 +- sound/soc/intel/avs/messages.c | 262 +++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 53 +++++++ 3 files changed, 322 insertions(+), 1 deletion(-)sound/soc/intel/avs/ipc.c +0
-0@@ -21,9 +21,15 @@ static void avs_dsp_receive_rx(struct avs_dev *adev, u64 header) ipc->rx.header = header;/* Abort copying payload if request processing was unsuccessful. */
sound/soc/intel/avs/ipc.c +5
-1-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;
sound/soc/intel/avs/ipc.c +2
-0+memcpy_fromio (ipc->rx.data,avs_uplink_addr (adev), ipc->rx.size); + } } static void avs_dsp_process_notification(struct avs_dev *adev, u64header)
sound/soc/intel/avs/messages.c +15
-0@@ -6,6 +6,7 @@// Amadeusz Slawinski <[email protected]> // +#include <linux/slab.h> #include "avs.h" #include "messages.h" @@ -139,3 +140,264 @@ int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, *state = reply.rsp.ext.get_ppl_state.state;return ret; } + +/* +* avs_ipc_init_instance - Initialize module instance +* +* @adev: Driver context +* @module_id: Module-type id +* @instance_id: Unique module instance id +* @ppl_id: Parent pipeline id +* @core_id: DSP core to allocate module on +* @domain: Processing domain (low latency or data processing) +* @param: Module-type specific configuration +* @param_size: Size of @param in bytes +* +* Argument verification, as well as pipeline state checks are done by the
+ * firmware.
+ *
+ * Note: @ppl_id and @core_id are independent of each other as single pipeline
+ * can be composed of module instances located on different DSP cores.
+ */
+int avs_ipc_init_instance(structavs_dev*adev, u16module_id, u8instance_id,sound/soc/intel/avs/messages.c +35
-0+ u8 ppl_id, u8 core_id, u8 domain, + void *param, u32 param_size) +{ + union avs_module_msg msg = AVS_MODULE_REQUEST(INIT_INSTANCE); +struct avs_ipc_msg request; +int ret; + + msg.module_id = module_id; + msg.instance_id = instance_id; +/* firmware expects size provided in dwords */ + msg.ext.init_instance.param_block_size = +DIV_ROUND_UP (param_size,sizeof (u32)); + msg.ext.init_instance.ppl_instance_id = ppl_id; + msg.ext.init_instance.core_id = core_id; + msg.ext.init_instance.proc_domain = domain; + + request.header = msg.val; + request.data = param; + request.size = param_size; + + ret =avs_dsp_send_msg (adev, &request,NULL ); +if (ret) +avs_ipc_err (adev, &request,"init instance" , ret); + +return ret; +} + +/* +* avs_ipc_delete_instance - Delete module instance +* +* @adev: Driver context +* @module_id: Module-type id +* @instance_id: Unique module instance id +* +* Argument verification, as well as pipeline state checks are done
Quoted 8 lines
by the
+ * firmware.
+ *
+ * Note: only standalone modules i.e. without a parent pipeline shall be
+ * deleted using this IPC message. In all other cases, pipeline owning the
+ * modules peforms cleanup automatically when it is deleted.
Can you please provide an example of such stand-alone modules? If they aren't part of any pipeline, how do they get scheduled?
Quoted 55 lines
+ */
+intavs_ipc_delete_instance(struct avs_dev *adev, u16 module_id, u8 instance_id)sound/soc/intel/avs/messages.c +28
-0+{ +union avs_module_msg msg =AVS_MODULE_REQUEST (DELETE_INSTANCE ); +struct avs_ipc_msg request = {{0 }}; +int ret; + + msg.module_id = module_id; + msg.instance_id = instance_id; + request.header = msg.val; + + ret =avs_dsp_send_msg (adev, &request,NULL ); +if (ret) +avs_ipc_err (adev, &request,"delete instance" , ret); + +return ret; +} + +/* +* avs_ipc_bind - Bind two module instances +* +* @adev: Driver context +* @module_id: Source module-type id +* @instance_id: Source module instance id +* @dst_module_id: Sink module-type id +* @dst_instance_id: Sink module instance id +* @dst_queue: Sink module pin to bind @src_queue with +* @src_queue: Source module pin to bind @dst_queue with +*/ +int avs_ipc_bind(struct avs_dev *adev, u16 module_id, u8
instance_id,sound/soc/intel/avs/messages.c +23
-0+ u16 dst_module_id, u8 dst_instance_id, + u8 dst_queue, u8 src_queue) +{ + union avs_module_msg msg = AVS_MODULE_REQUEST(BIND); +struct avs_ipc_msg request = {{0 }}; +int ret; + + msg.module_id = module_id; + msg.instance_id = instance_id; + msg.ext.bind_unbind.dst_module_id = dst_module_id; + msg.ext.bind_unbind.dst_instance_id = dst_instance_id; + msg.ext.bind_unbind.dst_queue = dst_queue; + msg.ext.bind_unbind.src_queue = src_queue; + request.header = msg.val; + + ret =avs_dsp_send_msg (adev, &request,NULL ); +if (ret) +avs_ipc_err (adev, &request,"bind modules" , ret); + +return ret; +} + +/*
sound/soc/intel/avs/messages.c int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, · line 265
Quoted 10 lines
sound/soc/intel/avs/messages.c +10
-0+* avs_ipc_unbind - Unbind two module instances +* +* @adev: Driver context +* @module_id: Source module-type id +* @instance_id: Source module instance id +* @dst_module_id: Sink module-type id +* @dst_instance_id: Sink module instance id +* @dst_queue: Sink module pin to unbind @src_queue from +* @src_queue: Source module pin to unbind @dst_queue from +*/
Are there any rules for unbinding? For example if you have 2 modules connected to a mixer? Can you unbind the module belonging to the host pipeline that is getting stopped while the mixer is still active?
Quoted 127 lines
+int avs_ipc_unbind(struct
avs_dev*adev, u16module_id, u8instance_id,sound/soc/intel/avs/messages.c +23
-0+ u16 dst_module_id, u8 dst_instance_id, + u8 dst_queue, u8 src_queue) +{ + union avs_module_msg msg = AVS_MODULE_REQUEST(UNBIND); +struct avs_ipc_msg request = {{0 }}; +int ret; + + msg.module_id = module_id; + msg.instance_id = instance_id; + msg.ext.bind_unbind.dst_module_id = dst_module_id; + msg.ext.bind_unbind.dst_instance_id = dst_instance_id; + msg.ext.bind_unbind.dst_queue = dst_queue; + msg.ext.bind_unbind.src_queue = src_queue; + request.header = msg.val; + + ret =avs_dsp_send_msg (adev, &request,NULL ); +if (ret) +avs_ipc_err (adev, &request,"unbind modules" , ret); + +return ret; +} + +static int __avs_ipc_set_large_config(struct avs_dev *adev, u16
module_id, u8instance_id,sound/soc/intel/avs/messages.c +1
-0+ u8 param_id, bool init_block,bool
final_block,sound/soc/intel/avs/messages.c +1
-0+u8 *request_data, size_t
request_size,size_toff_size)sound/soc/intel/avs/messages.c +2
-0+{ + union avs_module_msg msg =
AVS_MODULE_REQUEST(LARGE_CONFIG_SET);sound/soc/intel/avs/messages.c +36
-0+struct avs_ipc_msg request; +int ret; + + msg.module_id = module_id; + msg.instance_id = instance_id; + msg.ext.large_config.data_off_size = off_size; + msg.ext.large_config.large_param_id = param_id; + msg.ext.large_config.final_block = final_block; + msg.ext.large_config.init_block = init_block; + + request.header = msg.val; + request.data = request_data; + request.size = request_size; + + ret =avs_dsp_send_msg (adev, &request,NULL ); +if (ret) +avs_ipc_err (adev, &request,"large config set" , ret); + +return ret; +} + +int avs_ipc_set_large_config (struct avs_dev *adev,u16 module_id, +u8 instance_id,u8 param_id, +u8 *request,size_t request_size) +{ +size_t remaining, tx_size; +bool final; +int ret; + + remaining = request_size; + tx_size =min_t (size_t,AVS_MAILBOX_SIZE , remaining); + final = (tx_size == remaining); + +/* Initial request states total payload size. */ + ret = __avs_ipc_set_large_config(adev, module_id, instance_id, + param_id, 1, final, request,
tx_size,sound/soc/intel/avs/messages.c +15
-0+ request_size); +if (ret) +return ret; + + remaining -= tx_size; + +/* Loop the rest only when payload exceeds mailbox's size. */ +while (remaining) { +size_t offset; + + offset = request_size - remaining; + tx_size =min_t (size_t,AVS_MAILBOX_SIZE , remaining); + final = (tx_size == remaining); + + ret = __avs_ipc_set_large_config(adev, module_id,
instance_id,sound/soc/intel/avs/messages.c +2
-0+ param_id,0 , final, + request + offset,
tx_size,sound/soc/intel/avs/messages.c +11
-0+ offset); +if (ret) +return ret; + + remaining -= tx_size; + } + +return 0 ; +} + +int avs_ipc_get_large_config(struct avs_dev *adev, u16 module_id, u8
instance_id,sound/soc/intel/avs/messages.c +1
-0+ u8 param_id, u8 *request_data, size_t
request_size,sound/soc/intel/avs/messages.c +3
-0+ u8 **reply_data, size_t *reply_size) +{ + union avs_module_msg msg =
AVS_MODULE_REQUEST(LARGE_CONFIG_GET);sound/soc/intel/avs/messages.c +15
-0+struct avs_ipc_msg request; +struct avs_ipc_msg reply = {{0 }}; +size_t size; +void *buf; +int ret; + + reply.data =kzalloc (AVS_MAILBOX_SIZE ,GFP_KERNEL ); +if (!reply.data) +return -ENOMEM ; + + msg.module_id = module_id; + msg.instance_id = instance_id; + msg.ext.large_config.data_off_size = request_size; + msg.ext.large_config.large_param_id = param_id; +/* final_block is always 0 on request. Updated by fw on reply. */
sound/soc/intel/avs/messages.c +4
-0+ msg.ext.large_config.final_block =0 ; + msg.ext.large_config.init_block =1 ; + + request.header = msg.val;
sound/soc/intel/avs/messages.c int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, · line 390
Quoted 10 lines
sound/soc/intel/avs/messages.c +10
-0+ request.data = request_data; + request.size = request_size; + reply.size =AVS_MAILBOX_SIZE ; + + ret =avs_dsp_send_msg (adev, &request, &reply); +if (ret) { +avs_ipc_err (adev, &request,"large config get" , ret); +kfree (reply.data); +return ret; + }
How come you dont have a loop here? What if the rec'd data size if larger than the max size of IP payload?
Thanks,Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 07/17] ASoC: Intel: avs: Add module management requests
Quoted 1 line · Ranjani Sridharan
On Fri, 2022-03-04 at 15:57 +0100, Cezary Rojewski wrote:
...
Quoted 16 lines
Quoted 8 lines
+/*
+ *avs_ipc_delete_instance- Delete module instance
+ *
+ * @adev: Driver context
+ * @module_id: Module-type id
+ * @instance_id: Unique module instance id
+ *
+ * Argument verification, as well as pipeline state checks are doneQuoted 8 lines
by the
+ * firmware.
+ *
+ * Note: only standalone modules i.e. without a parent pipeline shall be
+ * deleted using this IPC message. In all other cases, pipeline owning the
+ * modules peforms cleanup automatically when it is deleted.
Quoted 2 lines
Can you please provide an example of such stand-alone modules? If they aren't part of any pipeline, how do they get scheduled?
Thanks for feedback! Consider dropping the unnecessary bits so it is easier to navigate through your responses.
Please note: kernel mailing list is not for explaining SW <-> FW communication details. Feel free to contact my colleagues from firmware team if in need of any FW-iface details.
That goes for most of the comments found below too.
Quoted 11 lines
Quoted 11 lines
+/*
+ *avs_ipc_unbind- Unbind two module instances
+ *
+ * @adev: Driver context
+ * @module_id: Source module-type id
+ * @instance_id: Source module instance id
+ * @dst_module_id: Sink module-type id
+ * @dst_instance_id: Sink module instance id
+ * @dst_queue: Sink module pin to unbind @src_queue from
+ * @src_queue: Source module pin to unbind @dst_queue from
+ */
Quoted 3 lines
Are there any rules for unbinding? For example if you have 2 modules connected to a mixer? Can you unbind the module belonging to the host pipeline that is getting stopped while the mixer is still active?
Here we have just a delegate. All the rules are defined and enforced by the firmware.
Quoted 23 lines
Quoted 23 lines
+int avs_ipc_unbind(struct
avs_dev*adev, u16module_id, u8instance_id,sound/soc/intel/avs/messages.c +21
-0+ u16 dst_module_id, u8 dst_instance_id, + u8 dst_queue, u8 src_queue) +{ + union avs_module_msg msg = AVS_MODULE_REQUEST(UNBIND); +struct avs_ipc_msg request = {{0 }}; +int ret; + + msg.module_id = module_id; + msg.instance_id = instance_id; + msg.ext.bind_unbind.dst_module_id = dst_module_id; + msg.ext.bind_unbind.dst_instance_id = dst_instance_id; + msg.ext.bind_unbind.dst_queue = dst_queue; + msg.ext.bind_unbind.src_queue = src_queue; + request.header = msg.val; + + ret =avs_dsp_send_msg (adev, &request,NULL ); +if (ret) +avs_ipc_err (adev, &request,"unbind modules" , ret); + +return ret; +}
...
Quoted 32 lines
Quoted 32 lines
+int avs_ipc_get_large_config(struct
avs_dev*adev, u16module_id, u8instance_id,(quoted diff) +1
-0+ u8 param_id, u8 *request_data, size_t
request_size,sound/soc/intel/avs/messages.c +3
-0+ u8 **reply_data, size_t *reply_size) +{ + union avs_module_msg msg =
AVS_MODULE_REQUEST(LARGE_CONFIG_GET);sound/soc/intel/avs/messages.c +15
-0+struct avs_ipc_msg request; +struct avs_ipc_msg reply = {{0 }}; +size_t size; +void *buf; +int ret; + + reply.data =kzalloc (AVS_MAILBOX_SIZE ,GFP_KERNEL ); +if (!reply.data) +return -ENOMEM ; + + msg.module_id = module_id; + msg.instance_id = instance_id; + msg.ext.large_config.data_off_size = request_size; + msg.ext.large_config.large_param_id = param_id; +/* final_block is always 0 on request. Updated by fw on reply. */
sound/soc/intel/avs/messages.c +8
-0+ msg.ext.large_config.final_block =0 ; + msg.ext.large_config.init_block =1 ; + + request.header = msg.val; + request.data = request_data; + request.size = request_size; + reply.size =AVS_MAILBOX_SIZE ; +
Quoted 8 lines
sound/soc/intel/avs/messages.c int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, · line 390
Quoted 6 lines
sound/soc/intel/avs/messages.c +6
-0+ ret =avs_dsp_send_msg (adev, &request, &reply); +if (ret) { +avs_ipc_err (adev, &request,"large config get" , ret); +kfree (reply.data); +return ret; + }How come you dont have a loop here? What if the rec'd data size if larger than the max size of IP payload?
That's not how LARGE_CONFIG_GET message works. There is no looping involved or expected by the firmware and so we don't have it here.
Regards,
Czarek
Re: [PATCH v3 07/17] ASoC: Intel: avs: Add module management requests
Quoted 9 lines · Cezary Rojewski
Quoted 5 lines
Are there any rules for unbinding? For example if you have 2 modules
connected to a mixer? Can you unbind the module belonging to the host
pipeline that is getting stopped while the mixer is still active?
Quoted 4 lines
Here we have just a delegate. All the rules are defined and enforced by
the firmware.
I'm not following this, Czarek. If there are rules defined by the FW, the driver has to follow it isnt it? What I am asking is how and where do you enforce this in the AVS driver?
...
Quoted 10 lines
Quoted 3 lines
Quoted 1 line
How come you dont have a loop here? What if the rec'd data size if larger than the max size of IP payload?
That's not how
LARGE_CONFIG_GETmessage works. There is no loopinginvolved or expected by the firmware and so we don't have it here.
So, are you saying that when retrieving data from the FW, the size of the retrieved data can never exceed max IPC payload size?
Thanks,Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 07/17] ASoC: Intel: avs: Add module management requests
Quoted 10 lines · Ranjani Sridharan
Quoted 9 lines · Cezary Rojewski
Quoted 5 lines
Are there any rules for unbinding? For example if you have 2 modules
connected to a mixer? Can you unbind the module belonging to the host
pipeline that is getting stopped while the mixer is still active?
Quoted 7 lines
Quoted 4 lines
Here we have just a delegate. All the rules are defined and enforced by
the firmware.
I'm not following this, Czarek. If there are rules defined by the FW, the driver has to follow it isnt it? What I am asking is how and where do you enforce this in the AVS driver?
How the stream looks is defined by the topology. Code that translates such patterns into runtime being is not part of this patchset. It's part of avs_path and its collaterals instead.
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
How come you dont have a loop here? What if the rec'd data size if larger than the max size of IP payload?
Quoted 6 lines
Quoted 3 lines
That's not how
LARGE_CONFIG_GETmessage works. There is no loopinginvolved or expected by the firmware and so we don't have it here.
So, are you saying that when retrieving data from the FW, the size of the retrieved data can never exceed max IPC payload size?
Precisely.
Regards,
Czarek
Re: [PATCH v3 07/17] ASoC: Intel: avs: Add module management requests
Quoted 9 lines · Cezary Rojewski
Quoted 5 lines
I'm not following this, Czarek. If there are rules defined by the FW,
the driver has to follow it isnt it? What I am asking is how and where
do you enforce this in the AVS driver?
Quoted 7 lines
How the stream looks is defined by the topology. Code that translates
such patterns into runtime being is not part of this patchset. It's part
of
avs_pathand its collaterals instead.
Alright, I'll wait for the next patchset for the explanation.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
How come you dont have a loop here? What if the rec'd data size if
larger than the max size of IP payload?That's not how
LARGE_CONFIG_GETmessage works. There is no looping
involved or expected by the firmware and so we don't have it here.
Quoted 8 lines
Quoted 3 lines
So, are you saying that when retrieving data from the FW, the size of
the retrieved data can never exceed max IPC payload size?Precisely.
This is fundmentally flawed isnt it? If set_large_config() sets a config that can exceed max IPC size, get_large_config() has to be able to support it.
Thanks,
Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 07/17] ASoC: Intel: avs: Add module management requests
Quoted 36 lines · Ranjani Sridharan
Quoted 9 lines · Cezary Rojewski
Quoted 5 lines
I'm not following this, Czarek. If there are rules defined by the FW,
the driver has to follow it isnt it? What I am asking is how and where
do you enforce this in the AVS driver?Quoted 7 lines
How the stream looks is defined by the topology. Code that translates
such patterns into runtime being is not part of this patchset. It's part
of
avs_pathand its collaterals instead.Alright, I'll wait for the next patchset for the explanation.
Quoted 17 lines
Quoted 13 lines
Quoted 10 lines
Quoted 6 lines
How come you dont have a loop here? What if the rec'd data size if
larger than the max size of IP payload?That's not how
LARGE_CONFIG_GETmessage works. There is no looping
involved or expected by the firmware and so we don't have it here.So, are you saying that when retrieving data from the FW, the size of
the retrieved data can never exceed max IPC payload size?
Quoted 4 lines
Quoted 1 line
Precisely.
This is fundmentally flawed isnt it? If
set_large_config()sets a config that can exceed max IPC size,get_large_config()has to be able to support it.
I could ask people on the list to "not look for a second" then there would be no problem explaining all the *recommended flows*.
Simple, honest answer is: Yes, that's fundamentally flawed.
Now, as older firmware generations do not expect nor support larger payload sizes, adding such code here is essentially adding dead code so we have decided to add none of it.
Regards,
Czarek
Re: [PATCH v3 07/17] ASoC: Intel: avs: Add module management requests
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
How come you dont have a loop here? What if the rec'd data size if
larger than the max size of IP payload?Quoted 7 lines
Quoted 4 lines
That's not how
LARGE_CONFIG_GETmessage works. There is no looping
involved or expected by the firmware and so we don't have it here.So, are you saying that when retrieving data from the FW, the size of
the retrieved data can never exceed max IPC payload size?Precisely.
Quoted 8 lines
Quoted 3 lines
This is fundmentally flawed isnt it? If
set_large_config()sets a config that can exceed max IPC size,get_large_config()has to be able to support it.I could ask people on the list to "not look for a second" then there would be no problem explaining all the *recommended flows*.
Simple, honest answer is: Yes, that's fundamentally flawed.
Now, as older firmware generations do not expect nor support larger payload sizes, adding such code here is essentially adding dead code so we have decided to add none of it.
Adding a comment and/or an explanation in the commit message wouldn't hurt then.
Cezary Rojewski
maintainerPATCH v3 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
@@ -401,3 +401,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;
@@ -290,4 +296,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
Re: [PATCH v3 08/17] ASoC: Intel: avs: Add power management requests
Quoted 27 lines · Cezary Rojewski
Audio 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.Signed-off-by: Amadeusz Sławiński <
[email protected]>Signed-off-by Cezary Rojewski <[email protected]>--- 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 +2
-0@@ -401,3 +401,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
Quoted 1 line
powerup)
a description for this function would be helpful.
Quoted 21 lines
sound/soc/intel/avs/messages.c +21
-0+{ +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
Quoted 5 lines
substates)
+ *
+ * @enable_pg: Whether to enable or disable power gating
+ * @streaming: Whether a stream is running when transitioning
+ */
What do you mean why "whether a stream is running" does it mean any stream? What is the difference between a D0ix transition with a stream running compared to not running?
Thanks,Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 08/17] ASoC: Intel: avs: Add power management requests
Quoted 1 line · Ranjani Sridharan
On Fri, 2022-03-04 at 15:57 +0100, Cezary Rojewski wrote:
...
Quoted 3 lines
Quoted 2 lines
+int
avs_ipc_set_dx(struct avs_dev *adev, u32 core_mask, bool powerup)a description for this function would be helpful.
Both relevant fields have comments as requested by Pierre.
We put quite an effort - which was triggered thanks to the feedback received - to have plain, simple delegates in form of: set necessary bits and let firmware to its job. I believe SET_DX is a good example of such.
Quoted 21 lines
Quoted 21 lines
sound/soc/intel/avs/messages.c +21
-0+{ +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
Quoted 8 lines
Quoted 5 lines
substates)
+ *
+ * @enable_pg: Whether to enable or disable power gating
+ * @streaming: Whether a stream is running when transitioning
+ */What do you mean why "whether a stream is running" does it mean any stream? What is the difference between a D0ix transition with a stream running compared to not running?
Precisely, any stream. The transition details are found within the firmware. Host (the driver) is responsible for scheduling and requesting the transition. Nothing more, nothing less.
Regards,
Czarek
Cezary Rojewski
maintainerPATCH v3 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
Re: [PATCH v3 09/17] ASoC: Intel: avs: Add ROM requests
Quoted 20 lines · Cezary Rojewski
ROM 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.Signed-off-by: Amadeusz Sławiński <
[email protected]>Signed-off-by Cezary Rojewski <[email protected]>--- 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 +0
-0
sound/soc/intel/avs/messages.c line 16
Quoted 5 lines
sound/soc/intel/avs/messages.c +1
-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)
Does purge set to true indicate a fresh boot and a false indicate IMR restore? A description would help.
Thanks,Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 09/17] ASoC: Intel: avs: Add ROM requests
Quoted 22 lines · Ranjani Sridharan
Quoted 21 lines · Cezary Rojewski
ROM 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.Signed-off-by: Amadeusz Sławiński <
[email protected]>Signed-off-by Cezary Rojewski <[email protected]>--- 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 +0
-0@@ -12,6 +12,24 @@
Quoted 6 lines
sound/soc/intel/avs/messages.c
Quoted 4 lines
sound/soc/intel/avs/messages.c +1
-0#define AVS_CL_TIMEOUT_MS 5000 +int avs_ipc_set_boot_config (struct avs_dev *adev,u32 dma_id,u32 purge)Does purge set to true indicate a fresh boot and a false indicate IMR restore? A description would help.
Indeed, purge indicates a fresh boot.
I believe flow is explained well by the layout of the calling functions, local variable naming and step-ordering which are found later in the series.
Regards,
Czarek
Cezary Rojewski
maintainerPATCH v3 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 | 215 +++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 179 +++++++++++++++++++++++++++ 2 files changed, 394 insertions(+)
sound/soc/intel/avs/messages.c +215 -0
@@ -463,3 +463,218 @@ 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; + } + +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: +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
Re: [PATCH v3 10/17] ASoC: Intel: avs: Add basefw runtime-parameter requests
Quoted 135 lines · Cezary Rojewski
Each module may expose a range of runtime parameters. For basefw, implement handlers for:
FIRMWARE_CONFIG,HARDWARE_CONFIGandMODULES_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.Signed-off-by: Amadeusz Sławiński <
[email protected]>Signed-off-by Cezary Rojewski <[email protected]>--- sound/soc/intel/avs/messages.c | 215 +++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 179 +++++++++++++++++++++++++++ 2 files changed, 394 insertions(+)sound/soc/intel/avs/messages.c +2
-0@@ -463,3 +463,218 @@ 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)
sound/soc/intel/avs/messages.c +8
-0+{ +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,sound/soc/intel/avs/messages.c +1
-0+ AVS_BASEFW_FIRMWARE_CONFIG,NULL, 0,
sound/soc/intel/avs/messages.c +93
-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",
sound/soc/intel/avs/messages.c int avs_ipc_set_d0ix(struct avs_dev *adev, bool enable_pg, bool streaming) · line 577
Quoted 8 lines
sound/soc/intel/avs/messages.c +8
-0+ tlv->type); +break ; + } + + offset +=sizeof (*tlv) + tlv->length; + } + +kfree (payload);
I think it would be easier to understand this kfree if payload was also allocated in this function in stead of inside the get_large_config(). Thanks,
Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 10/17] ASoC: Intel: avs: Add basefw runtime-parameter requests
Quoted 1 line · Ranjani Sridharan
On Fri, 2022-03-04 at 15:57 +0100, Cezary Rojewski wrote:
...
Quoted 109 lines
Quoted 109 lines
+int
avs_ipc_get_fw_config(struct avs_dev *adev, struct avs_fw_cfg *cfg)sound/soc/intel/avs/messages.c +8
-0+{ +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,(quoted diff) +1
-0+ AVS_BASEFW_FIRMWARE_CONFIG,NULL, 0,
sound/soc/intel/avs/messages.c +93
-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",
(quoted diff) +2
-0+ tlv->type); + break;
Quoted 8 lines
sound/soc/intel/avs/messages.c int avs_ipc_set_d0ix(struct avs_dev *adev, bool enable_pg, bool streaming) · line 577
Quoted 6 lines
sound/soc/intel/avs/messages.c +6
-0+ } + + offset +=sizeof (*tlv) + tlv->length; + } + +kfree (payload);I think it would be easier to understand this kfree if payload was also allocated in this function in stead of inside the
get_large_config().
That's a good thinking. There was an internal conversation regarding this back in time when we have been implementing getters for the first time. There are no clear victors, there are drawbacks - as you do not know the size upfront, caller has to guess and then reallocate the buffer accordingly to retrieved payload size from the firmware. So, even if you allocate buffer here, chances are, it's not the same buffer when the avs_ipc_get_large_config() returns to the caller.
We have decided to reduce the code size by letting the single, common handler do the allocation and leave the other responsibilities to the caller.
Regards,
Czarek
Re: [PATCH v3 10/17] ASoC: Intel: avs: Add basefw runtime-parameter requests
Quoted 18 lines
Quoted 5 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ kfree(payload);I think it would be easier to understand this kfree if payload was also
allocated in this function in stead of inside theget_large_config().That's a good thinking. There was an internal conversation regarding this back in time when we have been implementing getters for the first
time. There are no clear victors, there are drawbacks - as you do not
know the size upfront, caller has to guess and then reallocate the buffer accordingly to retrieved payload size from the firmware. So, even
if you allocate buffer here, chances are, it's not the same buffer when
theavs_ipc_get_large_config()returns to the caller.
Quoted 5 lines
We have decided to reduce the code size by letting the single, common
handler do the allocation and leave the other responsibilities to the
caller.
What could make it simpler is if you allocate MAX IPC size for payload in this function and then copy the right size in the avs_ipc_get_large_config(). payload_size tells you that information anyway right?
Thanks,
Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 10/17] ASoC: Intel: avs: Add basefw runtime-parameter requests
Quoted 24 lines · Ranjani Sridharan
Quoted 18 lines
Quoted 5 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ kfree(payload);I think it would be easier to understand this kfree if payload was also
allocated in this function in stead of inside theget_large_config().That's a good thinking. There was an internal conversation regarding this back in time when we have been implementing getters for the first
time. There are no clear victors, there are drawbacks - as you do not
know the size upfront, caller has to guess and then reallocate the buffer accordingly to retrieved payload size from the firmware. So, even
if you allocate buffer here, chances are, it's not the same buffer when
theavs_ipc_get_large_config()returns to the caller.Quoted 5 lines
We have decided to reduce the code size by letting the single, common
handler do the allocation and leave the other responsibilities to the
caller.
Quoted 4 lines
What could make it simpler is if you allocate MAX IPC size for payload in this function and then copy the right size in the
avs_ipc_get_large_config().payload_sizetells you that information anyway right?
As stated, there is no clear winner here - you had to repeat such code for every getter.
Since we are getting payload_size already, retrieving payload itself is just fine.
Regards,
Czarek
Re: [PATCH v3 10/17] ASoC: Intel: avs: Add basefw runtime-parameter requests
Quoted 12 lines · Cezary Rojewski
Quoted 5 lines
What could make it simpler is if you allocate MAX IPC size for payload
in this function and then copy the right size in theavs_ipc_get_large_config().payload_sizetells you that information anyway right?As stated, there is no clear winner here - you had to repeat such code
Quoted 8 lines
for every getter.
Since we are getting
payload_sizealready, retrieving payload itself isjust fine.
OK, can you please add a comment to state this in the patch so the reviewer doesnt have to track down where this memory is allocated?
Thanks,Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 10/17] ASoC: Intel: avs: Add basefw runtime-parameter requests
Quoted 17 lines · Ranjani Sridharan
Quoted 16 lines · Cezary Rojewski
Quoted 5 lines
What could make it simpler is if you allocate MAX IPC size for payload
in this function and then copy the right size in theavs_ipc_get_large_config().payload_sizetells you that information anyway right?As stated, there is no clear winner here - you had to repeat such code
for every getter.
Quoted 7 lines
Quoted 4 lines
Since we are getting
payload_sizealready, retrieving payload itself isjust fine.
OK, can you please add a comment to state this in the patch so the reviewer doesnt have to track down where this memory is allocated?
Sure, will add in v4.
Cezary Rojewski
maintainerPATCH v3 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
Re: [PATCH v3 11/17] ASoC: Intel: avs: Firmware resources management utilities
Quoted 55 lines · Cezary Rojewski
With 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.Signed-off-by: Amadeusz Sławiński <
[email protected]>Signed-off-by Cezary Rojewski <[email protected]>--- 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.csound/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.osound/soc/intel/avs/avs.h +8
-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
Quoted 7 lines
message
+ * @hw_cfg: Hardware configuration, obtained throughHW_CONFIGmessage
+ * @mods_info: Available module-types, obtained throughMODULES_INFOmessage
+ * @mod_idas: Module instance ID pool, one per module-type
+ * @modres_mutex: For synchronizing any @mods_info updates
Is this mutex really necessary? Can you please elaborate under what circumstances your will have parallel module updates?
Quoted 253 lines
+ * @ppl_ida: Pipeline instance ID pool
+ * @fw_list: List of libraries loaded, including base firmware */
structavs_dev{sound/soc/intel/avs/avs.h +11
-0struct 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);
+intavs_get_module_id_entry(struct avs_dev *adev, u32 module_id, struct avs_module_entry *entry);sound/soc/intel/avs/avs.h +7
-0+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);
+intavs_request_firmware(struct avs_dev *adev, const struct firmware **fw_p, const char *name);sound/soc/intel/avs/avs.h +3
-0+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 +15
-0@@ -0,0 +1,301 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright(c) 2021 Intel Corporation. All rights reserved. +// +// Authors: Cezary Rojewski <[email protected]> +// Amadeusz Slawinski <[email protected]> +// + +#include <linux/firmware.h> +#include <linux/slab.h> +#include "avs.h" +#include "messages.h" + +/* Caller responsible for holding adev->modres_mutex. */ +static int avs_module_entry_index(struct avs_dev *adev, const guid_t*uuid)
sound/soc/intel/avs/utils.c new file +16
-0+{ +int i; + +for (i =0 ; i < adev->mods_info->count; i++) { +struct avs_module_entry *module; + + module = &adev->mods_info->entries[i]; +if (guid_equal (&module->uuid, uuid)) +return i; + } + +return -ENOENT ; +} + +/* Caller responsible for holding adev->modres_mutex. */ +static int avs_module_id_entry_index(struct avs_dev *adev, u32
module_id)sound/soc/intel/avs/utils.c new file +15
-0+{ +int i; + +for (i =0 ; i < adev->mods_info->count; i++) { +struct avs_module_entry *module; + + module = &adev->mods_info->entries[i]; +if (module->module_id == module_id) +return i; + } + +return -ENOENT ; +} + +int avs_get_module_entry(struct avs_dev *adev, const guid_t *uuid,struct
avs_module_entry*entry)sound/soc/intel/avs/utils.c new file +8
-0+{ +int idx; + +mutex_lock (&adev->modres_mutex); + + idx =avs_module_entry_index (adev, uuid); +if (idx >=0 ) + memcpy(entry, &adev->mods_info->entries[idx],
sizeof(*entry));sound/soc/intel/avs/utils.c new file +6
-0+ +mutex_unlock (&adev->modres_mutex); +return (idx <0 ) ? idx :0 ; +} + +int avs_get_module_id_entry(struct avs_dev *adev, u32 module_id,struct
avs_module_entry*entry)sound/soc/intel/avs/utils.c new file +8
-0+{ +int idx; + +mutex_lock (&adev->modres_mutex); + + idx =avs_module_id_entry_index (adev, module_id); +if (idx >=0 ) + memcpy(entry, &adev->mods_info->entries[idx],
sizeof(*entry));sound/soc/intel/avs/utils.c new file +44
-0+ +mutex_unlock (&adev->modres_mutex); +return (idx <0 ) ? idx :0 ; +} + +int avs_get_module_id (struct avs_dev *adev,const guid_t *uuid) +{ +struct avs_module_entry module; +int ret; + + ret =avs_get_module_entry (adev, uuid, &module); +return !ret ? module.module_id : -ENOENT ; +} + +bool avs_is_module_ida_empty (struct avs_dev *adev,u32 module_id) +{ +bool ret = false; +int idx; + +mutex_lock (&adev->modres_mutex); + + idx =avs_module_id_entry_index (adev, module_id); +if (idx >=0 ) + ret =ida_is_empty (adev->mod_idas[idx]); + +mutex_unlock (&adev->modres_mutex); +return ret; +} + +/* Caller responsible for holding adev->modres_mutex. */ +static void avs_module_ida_destroy (struct avs_dev *adev) +{ +int i = adev->mods_info ? adev->mods_info->count :0 ; + +while (i--) { +ida_destroy (adev->mod_idas[i]); +kfree (adev->mod_idas[i]); + } +kfree (adev->mod_idas); +} + +/* Caller responsible for holding adev->modres_mutex. */ +static int +avs_module_ida_alloc(struct avs_dev *adev, struct avs_mods_info*newinfo, bool purge)
sound/soc/intel/avs/utils.c new file +9
-0+{ +struct avs_mods_info *oldinfo = adev->mods_info; +struct ida **ida_ptrs; +u32 tocopy_count =0 ; +int i; + +if (!purge && oldinfo) { +if (oldinfo->count >= newinfo->count) + dev_warn(adev->dev, "refreshing %d modules infowith %d\n",
sound/soc/intel/avs/utils.c new file +5
-0+ oldinfo->count, newinfo->count); + tocopy_count = oldinfo->count; + } + + ida_ptrs = kcalloc(newinfo->count, sizeof(*ida_ptrs),
GFP_KERNEL);sound/soc/intel/avs/utils.c new file +5
-0+if (!ida_ptrs) +return -ENOMEM ; + +if (tocopy_count) + memcpy(ida_ptrs, adev->mod_idas, tocopy_count *
sizeof(*ida_ptrs));sound/soc/intel/avs/utils.c new file +38
-0+ +for (i = tocopy_count; i < newinfo->count; i++) { + ida_ptrs[i] =kzalloc (sizeof (**ida_ptrs),GFP_KERNEL ); +if (!ida_ptrs[i]) { +while (i--) +kfree (ida_ptrs[i]); + +kfree (ida_ptrs); +return -ENOMEM ; + } + +ida_init (ida_ptrs[i]); + } + +/* If old elements have been reused, don't wipe them. */ +if (tocopy_count) +kfree (adev->mod_idas); +else +avs_module_ida_destroy (adev); + + adev->mod_idas = ida_ptrs; +return 0 ; +} + +int avs_module_info_init (struct avs_dev *adev,bool purge) +{ +struct avs_mods_info *info; +int ret; + + ret =avs_ipc_get_modules_info (adev, &info); +if (ret) +return AVS_IPC_RET (ret); + +mutex_lock (&adev->modres_mutex); + + ret =avs_module_ida_alloc (adev, info, purge); +if (ret <0 ) { + dev_err(adev->dev, "initialize module idas failed:%d\n", ret);
sound/soc/intel/avs/utils.c new file +21
-0+ goto exit; + } + +/* Refresh current information with newly received table. */ +kfree (adev->mods_info); + adev->mods_info = info; + +exit: +mutex_unlock (&adev->modres_mutex); +return ret; +} + +void avs_module_info_free (struct avs_dev *adev) +{ +mutex_lock (&adev->modres_mutex); + +avs_module_ida_destroy (adev); +kfree (adev->mods_info); + adev->mods_info =NULL ; + +mutex_unlock (&adev->modres_mutex);
sound/soc/intel/avs/utils.c line 200
Quoted 10 lines
sound/soc/intel/avs/utils.c new file +10
-0+} + +int avs_module_id_alloc (struct avs_dev *adev,u16 module_id) +{ +int ret, idx, max_id; + +mutex_lock (&adev->modres_mutex); + + idx =avs_module_id_entry_index (adev, module_id); +if (idx == -ENOENT ) {
Can you please help me understand when this can happen? If all modules required by the topology are already initialized, will this ever happen?
Thanks,
Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 11/17] ASoC: Intel: avs: Firmware resources management utilities
Quoted 16 lines · Ranjani Sridharan
Quoted 6 lines · Cezary Rojewski
/*
* structavs_dev- Intel HD-Audio driver data
*
* @dev: PCI device
* @dsp_ba: DSP bar address
* @spec: platform-specific descriptorQuoted 8 lines
+ * @fw_cfg: Firmware configuration, obtained through
FW_CONFIGmessage
+ * @hw_cfg: Hardware configuration, obtained throughHW_CONFIGmessage
+ * @mods_info: Available module-types, obtained throughMODULES_INFOmessage
+ * @mod_idas: Module instance ID pool, one per module-type
+ * @modres_mutex: For synchronizing any @mods_info updates
Quoted 2 lines
Is this mutex really necessary? Can you please elaborate under what circumstances your will have parallel module updates?
Yes, we believe modres_mutex is necessary. All information regarding modules exposed by the firmware are stored within ->mods_info cache.
That's just a snapshot though. When a new library gets loaded, new modules may be available for use and so the driver updates the ->mods_info cache to have the latest snapshot. As information found there is used when streaming (e.g.: instantiating modules), we enter a scenario when multiple threads could be reading/updating the ->mods_info at once. To prevent any unwanted behavior, mutex has been added.
Quoted 14 lines
Quoted 14 lines
sound/soc/intel/avs/utils.c new file +14
-0+void avs_module_info_free (struct avs_dev *adev) +{ +mutex_lock (&adev->modres_mutex); + +avs_module_ida_destroy (adev); +kfree (adev->mods_info); + adev->mods_info =NULL ; + +mutex_unlock (&adev->modres_mutex); +} + +int avs_module_id_alloc (struct avs_dev *adev,u16 module_id) +{ +int ret, idx, max_id;
Quoted 8 lines
sound/soc/intel/avs/utils.c line 200
Quoted 5 lines
sound/soc/intel/avs/utils.c new file +5
-0+ +mutex_lock (&adev->modres_mutex); + + idx =avs_module_id_entry_index (adev, module_id); +if (idx == -ENOENT ) {Can you please help me understand when this can happen? If all modules required by the topology are already initialized, will this ever happen?
I want to help! Just not understanding the meaning of: "all modules required by the topology are already initialized".
Will answer best I can though: topology carries just patterns, it may happen that module found within topology file is not actually exposed by the firmware. In such case, we drop an error. This keeps recovery scenarios sane too - when recovering, libraries may have to be re-loaded, depending on the firmware generation and whether basefw recovery was successful or not.
Regards,
Czarek
Re: [PATCH v3 11/17] ASoC: Intel: avs: Firmware resources management utilities
Quoted 19 lines
Quoted 3 lines
Quoted 1 line
+ * @modres_mutex: For synchronizing any @mods_info updates
Is this mutex really necessary? Can you please elaborate under what circumstances your will have parallel module updates?
Yes, we believe
modres_mutexis necessary. All information regardingmodules exposed by the firmware are stored within ->mods_info cache.
That's just a snapshot though. When a new library gets loaded, new
modules may be available for use and so the driver updates the
->mods_info cache to have the latest snapshot. As information found
Quoted 7 lines
there is used when streaming (e.g.: instantiating modules), we enter a
scenario when multiple threads could be reading/updating the ->mods_info
at once. To prevent any unwanted behavior, mutex has been added.
This is the part that's hard to follow without seeing the actual code where this new library is loaded. When does a libray get loaded? When you start streaming and you realize that the stream requires a module that is not built into the base FW? Can this be done during topology loading instead?
Thanks,
Rnajani
Cezary Rojewski
maintainerRe: [PATCH v3 11/17] ASoC: Intel: avs: Firmware resources management utilities
Quoted 25 lines · Ranjani Sridharan
Quoted 25 lines
Quoted 3 lines
Quoted 1 line
+ * @modres_mutex: For synchronizing any @mods_info updates
Is this mutex really necessary? Can you please elaborate under what circumstances your will have parallel module updates?
Yes, we believe
modres_mutexis necessary. All information regardingmodules exposed by the firmware are stored within ->mods_info cache.
That's just a snapshot though. When a new library gets loaded, new
modules may be available for use and so the driver updates the
->mods_info cache to have the latest snapshot. As information found
there is used when streaming (e.g.: instantiating modules), we enter a
scenario when multiple threads could be reading/updating the ->mods_info
Quoted 6 lines
Quoted 1 line
at once. To prevent any unwanted behavior, mutex has been added.
This is the part that's hard to follow without seeing the actual code where this new library is loaded. When does a libray get loaded? When you start streaming and you realize that the stream requires a module that is not built into the base FW? Can this be done during topology loading instead?
But that's already done during topology load! If there is no topology telling the driver: "hey, load this lib for me!", nothing gets loaded regardless of how your /lib/firmware looks like. Libraries get loaded during soc-component's (platform component) ->probe(). This is place where snd_soc_tplg_component_load() is called.
However, if platform has no IMR capability, driver has to re-load libraries for all platform components of bound sound cards on every pm_runtime_resume().
Regards,
Czarek
Re: [PATCH v3 11/17] ASoC: Intel: avs: Firmware resources management utilities
Quoted 26 lines · Cezary Rojewski
Quoted 9 lines
This is the part that's hard to follow without seeing the actual code
where this new library is loaded. When does a libray get loaded? When
you start streaming and you realize that the stream requires a module
that is not built into the base FW? Can this be done during topology
loading instead?But that's already done during topology load! If there is no topology
telling the driver: "hey, load this lib for me!", nothing gets loaded
regardless of how your
/lib/firmwarelooks like. Libraries get loadedduring soc-component's (platform component) ->probe(). This is place
where
snd_soc_tplg_component_load()is called.
Quoted 5 lines
However, if platform has no IMR capability, driver has to re-load
libraries for all platform components of bound sound cards on every
pm_runtime_resume().
And if it done during pm_runtime_resume(), where would the problem with synchronizing arise from? userspace apps do not get resumed until after the PCI device is resumed isnt it?
Thanks,
Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 11/17] ASoC: Intel: avs: Firmware resources management utilities
Quoted 29 lines · Ranjani Sridharan
Quoted 28 lines · Cezary Rojewski
Quoted 9 lines
This is the part that's hard to follow without seeing the actual code
where this new library is loaded. When does a libray get loaded? When
you start streaming and you realize that the stream requires a module
that is not built into the base FW? Can this be done during topology
loading instead?But that's already done during topology load! If there is no topology
telling the driver: "hey, load this lib for me!", nothing gets loaded
regardless of how your
/lib/firmwarelooks like. Libraries get loadedduring soc-component's (platform component) ->probe(). This is place
where
snd_soc_tplg_component_load()is called.However, if platform has no IMR capability, driver has to re-load
Quoted 7 lines
Quoted 3 lines
libraries for all platform components of bound sound cards on every
pm_runtime_resume().And if it done during
pm_runtime_resume(), where would the problem with synchronizing arise from? userspace apps do not get resumed until after the PCI device is resumed isnt it?
Scenario you describe is correct and does not prompt the need for the mutex.
However, ->mods_info is accessed through getters found in utils.c (this very patch) during stream creation too. That fragment is part of path management series though - it was requested to split those bits away.
So, there is a possibility for a platform-soc-component to have its ->probe() called - and thus triggering ->mods_info update - while a stream is being opened on a different sound card simultaneously. To avoid unwanted behavior e.g.: looping through ->mods_info while it's being updated in separate thread, we lock the array.
Regards,
Czarek
Re: [PATCH v3 11/17] ASoC: Intel: avs: Firmware resources management utilities
Quoted 17 lines · Cezary Rojewski
Scenario you describe is correct and does not prompt the need for the mutex.
However, ->mods_info is accessed through getters found in
utils.c(thisvery patch) during stream creation too. That fragment is part of path
management series though - it was requested to split those bits away.
So, there is a possibility for a platform-soc-component to have its
Quoted 7 lines
->probe() called - and thus triggering ->mods_info update - while a
stream is being opened on a different sound card simultaneously. To
avoid unwanted behavior e.g.: looping through ->mods_info while it's
being updated in separate thread, we lock the array.
Keeping in mind that this driver is meant for older platforms, how likely are you to support multiple sound cards with those topologies?
Thanks,
Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 11/17] ASoC: Intel: avs: Firmware resources management utilities
Quoted 20 lines · Ranjani Sridharan
Quoted 19 lines · Cezary Rojewski
Scenario you describe is correct and does not prompt the need for the mutex.
However, ->mods_info is accessed through getters found in
utils.c(thisvery patch) during stream creation too. That fragment is part of path
management series though - it was requested to split those bits away.
So, there is a possibility for a platform-soc-component to have its
->probe() called - and thus triggering ->mods_info update - while a
Quoted 8 lines
Quoted 5 lines
stream is being opened on a different sound card simultaneously. To
avoid unwanted behavior e.g.: looping through ->mods_info while it's
being updated in separate thread, we lock the array.
Keeping in mind that this driver is meant for older platforms, how likely are you to support multiple sound cards with those topologies?
Not sure what's the question here. Age of the platform has nothing to do with the subject. There is not a single DSP-capable platform that Intel has shipped that would not contain more one audio device onboard. At least I'm not aware of any.
Regards,
Czarek
Re: [PATCH v3 11/17] ASoC: Intel: avs: Firmware resources management utilities
Quoted 8 lines · Cezary Rojewski
Quoted 3 lines
Keeping in mind that this driver is meant for older platforms, how likely are you to support multiple sound cards with those topologies?
Not sure what's the question here. Age of the platform has nothing to do
Quoted 6 lines
with the subject. There is not a single DSP-capable platform that Intel
has shipped that would not contain more one audio device onboard. At
least I'm not aware of any.
My question was related to your comment about multiple sound cards. What I asked was do you plan to support multiple topologies with modules spread across then with multiple sound component drivers with the AVS driver and firmware? Does this mean you will need multiple topology files and machine driver? And what is the rationale for this?
If not, there's no need for the mutex.
Thanks,
Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 11/17] ASoC: Intel: avs: Firmware resources management utilities
Quoted 16 lines · Ranjani Sridharan
Quoted 8 lines · Cezary Rojewski
Quoted 3 lines
Keeping in mind that this driver is meant for older platforms, how likely are you to support multiple sound cards with those topologies?
Not sure what's the question here. Age of the platform has nothing to do
Quoted 6 lines
with the subject. There is not a single DSP-capable platform that Intel
has shipped that would not contain more one audio device onboard. At
least I'm not aware of any.
Quoted 7 lines
My question was related to your comment about multiple sound cards. What I asked was do you plan to support multiple topologies with modules spread across then with multiple sound component drivers with the AVS driver and firmware? Does this mean you will need multiple topology files and machine driver? And what is the rationale for this?
If not, there's no need for the mutex.
Yes, avs-driver embraces granular sound card approach as opposed to super card approach. There is one topology file per sound card.
That subject is not part of this patchset though.
Regards,
Czarek
Re: [PATCH v3 11/17] ASoC: Intel: avs: Firmware resources management utilities
Quoted 23 lines · Cezary Rojewski
Quoted 22 lines · Ranjani Sridharan
Quoted 8 lines · Cezary Rojewski
Quoted 3 lines
Keeping in mind that this driver is meant for older platforms, how likely are you to support multiple sound cards with those topologies?
Not sure what's the question here. Age of the platform has nothing to do
Quoted 6 lines
with the subject. There is not a single DSP-capable platform that Intel
has shipped that would not contain more one audio device onboard. At
least I'm not aware of any.
My question was related to your comment about multiple sound cards. What I asked was do you plan to support multiple topologies with modules spread across then with multiple sound component drivers with the AVS driver and firmware? Does this mean you will need multiple topology files and machine driver? And what is the rationale for this?
Quoted 5 lines
Quoted 1 line
If not, there's no need for the mutex.
Yes, avs-driver embraces granular sound card approach as opposed to super card approach. There is one topology file per sound card.
That subject is not part of this patchset though.
You would still need to clarify how the same set of modules might be accessed or configured when different cards are created, or if there is a 'clean' split with a 1:1 mapping between module and cards.
The more I think of this the less practical this 'granular' approach looks, e.g. if you want to route the same stream to different interfaces handled by different cards. An example is playing a notification on local speakers controlled by HDaudio and a Bluetooth headset using I2S. This could be really fun to represent even basic volume control to users: controls are card-specific and some parts may be handled in different cards and thus different UCM files.
I really think the best split of a DSP topology is between orthogonal parts. When muxers/demux are used, or multi-input modules such as AEC, the routing complexity outweighs the benefits of a simpler card design.
Cezary Rojewski
maintainerRe: [PATCH v3 11/17] ASoC: Intel: avs: Firmware resources management utilities
Quoted 1 line · Pierre-Louis Bossart
On 3/8/22 12:31, Cezary Rojewski wrote:
...
Quoted 9 lines
Quoted 3 lines
Yes, avs-driver embraces granular sound card approach as opposed to super card approach. There is one topology file per sound card.
That subject is not part of this patchset though.
You would still need to clarify how the same set of modules might be accessed or configured when different cards are created, or if there is a 'clean' split with a 1:1 mapping between module and cards.
The more I think of this the less practical this 'granular' approach looks, e.g. if you want to route the same stream to different interfaces handled by different cards. An example is playing a notification on local speakers controlled by HDaudio and a Bluetooth headset using I2S. This could be really fun to represent even basic volume control to users: controls are card-specific and some parts may be handled in different cards and thus different UCM files.
I really think the best split of a DSP topology is between orthogonal parts. When muxers/demux are used, or multi-input modules such as AEC, the routing complexity outweighs the benefits of a simpler card design.
There is a clean split - for all the typical scenarios, topology tied to given sound card defines the stream patterns completely.
Even when considering "functional" split as you mention in third paragraph, multiple sound cards are still there. So, as I have described earlier, to prevent any unwanted behaviour, cached module information in form of ->mods_info, is being locked with help of a mutex. We do not duplicate such information per sound card as that would be a waste of memory. No matter how many libraries are mentioned by the topology files and loaded throughout the lifetime of a driver, there is always just one base firmware we sent MODULE_INFO to.
In regard to advanced scenarios and more complex routing, it would be good to have that conversation as a part of dedicated patchset which is going to follow this one (sooner or later).
Regards,
Czarek
Cezary Rojewski
maintainerPATCH v3 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
@@ -678,3 +678,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
Re: [PATCH v3 12/17] ASoC: Intel: avs: Declare module configuration types
Quoted 108 lines · Cezary Rojewski
Declare 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_FORMATruntime for COPIER module which allows for configuration of output pin other than the default one (0).Signed-off-by: Amadeusz Sławiński <
[email protected]>Signed-off-by Cezary Rojewski <[email protected]>--- 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 +2
-0@@ -678,3 +678,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,sound/soc/intel/avs/messages.c +2
-0+ u8 instance_id, u32 sink_id, + const struct avs_audio_format
*src_fmt,sound/soc/intel/avs/messages.c +1
-0+ const struct avs_audio_format
*sink_fmt)sound/soc/intel/avs/messages.c +11
-0+{ +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.c +1
-0+}sound/soc/intel/avs/messages.h +4
-0@@ -498,4 +498,256 @@ static inline bool avs_module_entry_is_loaded(struct avs_module_entry *mentry) int avs_ipc_get_modules_info(struct avs_dev *adev, structavs_mods_info **info); +/* Module configuration */ + +#define AVS_MIXIN_MOD_UUID \ + GUID_INIT(0x39656EB2, 0x3B71, 0x4049, 0x8D, 0x3F, 0xF9, 0x2C,
0xD5,0xC4,0x3C,0x09)sound/soc/intel/avs/messages.h +3
-0+ +#define AVS_MIXOUT_MOD_UUID \ + GUID_INIT(0x3C56505A, 0x24D7, 0x418F, 0xBD, 0xDC, 0xC1, 0xF5,
0xA3,0xAC,0x2A,0xE0)sound/soc/intel/avs/messages.h +3
-0+ +#define AVS_COPIER_MOD_UUID \ + GUID_INIT(0x9BA00C83, 0xCA12, 0x4A83, 0x94, 0x3C, 0x1F, 0xA2,
0xE8,0x2F,0x9D,0xDA)sound/soc/intel/avs/messages.h +3
-0+ +#define AVS_KPBUFF_MOD_UUID \ + GUID_INIT(0xA8A0CB32, 0x4A77, 0x4DB1, 0x85, 0xC7, 0x53, 0xD7,
0xEE,0x07,0xBC,0xE6)sound/soc/intel/avs/messages.h +3
-0+ +#define AVS_MICSEL_MOD_UUID \ + GUID_INIT(0x32FE92C1, 0x1E17, 0x4FC2, 0x97, 0x58, 0xC7, 0xF3,
0x54,0x2E,0x98,0x0A)sound/soc/intel/avs/messages.h +3
-0+ +#define AVS_MUX_MOD_UUID \ + GUID_INIT(0x64CE6E35, 0x857A, 0x4878, 0xAC, 0xE8, 0xE2, 0xA2,
0xF4,0x2e,0x30,0x69)sound/soc/intel/avs/messages.h +3
-0+ +#define AVS_UPDWMIX_MOD_UUID \ + GUID_INIT(0x42F8060C, 0x832F, 0x4DBF, 0xB2, 0x47, 0x51, 0xE9,
0x61,0x99,0x7b,0x35)sound/soc/intel/avs/messages.h +3
-0+ +#define AVS_SRCINTC_MOD_UUID \ + GUID_INIT(0xE61BB28D, 0x149A, 0x4C1F, 0xB7, 0x09, 0x46, 0x82,
0x3E,0xF5,0xF5,0xAE)sound/soc/intel/avs/messages.h +3
-0+ +#define AVS_PROBE_MOD_UUID \ + GUID_INIT(0x7CAD0808, 0xAB10, 0xCD23, 0xEF, 0x45, 0x12, 0xAB,
0x34,0xCD,0x56,0xEF)sound/soc/intel/avs/messages.h +3
-0+ +#define AVS_AEC_MOD_UUID \ + GUID_INIT(0x46CB87FB, 0xD2C9, 0x4970, 0x96, 0xD2, 0x6D, 0x7E,
0x61,0x4B,0xB6,0x05)sound/soc/intel/avs/messages.h +3
-0+ +#define AVS_ASRC_MOD_UUID \ + GUID_INIT(0x66B4402D, 0xB468, 0x42F2, 0x81, 0xA7, 0xB3, 0x71,
0x21,0x86,0x3D,0xD4)sound/soc/intel/avs/messages.h +3
-0+ +#define AVS_INTELWOV_MOD_UUID \ + GUID_INIT(0xEC774FA9, 0x28D3, 0x424A, 0x90, 0xE4, 0x69, 0xF9,
Quoted 1 line
0x84,0xF1,0xEE,0xB7)
Why do you need to hard-code this? DOes the fw config info that you retrieve using get_large_config or even the FW manifest have it already?
Thanks,Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 12/17] ASoC: Intel: avs: Declare module configuration types
Quoted 8 lines · Ranjani Sridharan
Quoted 3 lines · Cezary Rojewski
(quoted diff) +2
-0+#define AVS_INTELWOV_MOD_UUID \ + GUID_INIT(0xEC774FA9, 0x28D3, 0x424A, 0x90, 0xE4, 0x69, 0xF9,
0x84,0xF1,0xEE,0xB7)Why do you need to hard-code this? DOes the fw config info that you retrieve using
get_large_configor even the FW manifest have it already?
While I can't get into the details, the problem lies within the firmware binary itself e.g.: copier may have module ID of 3 in case of firmware generation X, but ID of 4 in generation Y. The only sane option are the GUIDs - these have never changed.
Even when reading manifest, driver has to have some kind of method to understand what is it reading. If one cannot trust any enum or constant, then one won't know it is reading copier anyway. GUID list is the necessary evil here as we have no options of repairing all the firmware generations.
We do make a snapshot of modules info data through LARGE_CONFIG_GET and store it within ->mods_info for later use, yes (stream runtime).
Regards,
Czarek
Cezary Rojewski
maintainerPATCH v3 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 | 170 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 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;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 +170 -0
174 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v3 13/17] ASoC: Intel: avs: Dynamic firmware resources management
Quoted 20 lines · Cezary Rojewski
Wrap 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.Signed-off-by: Amadeusz Sławiński <
[email protected]>Signed-off-by Cezary Rojewski <[email protected]>--- sound/soc/intel/avs/avs.h | 10 +++ sound/soc/intel/avs/dsp.c | 170 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+)sound/soc/intel/avs/avs.h +0
-0
sound/soc/intel/avs/avs.h struct avs_dev { · line 92
Quoted 4 lines
sound/soc/intel/avs/avs.h +1
-0@@ -89,6 +89,7 @@ struct avs_dev {struct mutex modres_mutex;struct ida ppl_ida;struct list_head fw_list; +int *core_refs;
Is this a per core ref_count? a comment or explicitly calling it core_ref_count would help.
Thanks,Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 13/17] ASoC: Intel: avs: Dynamic firmware resources management
Quoted 16 lines · Ranjani Sridharan
Quoted 15 lines · Cezary Rojewski
Wrap 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.Signed-off-by: Amadeusz Sławiński <
[email protected]>Signed-off-by Cezary Rojewski <[email protected]>--- sound/soc/intel/avs/avs.h | 10 +++ sound/soc/intel/avs/dsp.c | 170 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+)
Quoted 12 lines
sound/soc/intel/avs/avs.h struct avs_dev { · line 92
Quoted 9 lines
sound/soc/intel/avs/avs.h +1
-0@@ -89,6 +89,7 @@ struct avs_dev {struct mutex modres_mutex;struct ida ppl_ida;struct list_head fw_list; +int *core_refs;Is this a per core
ref_count? a comment or explicitly calling itcore_ref_countwould help.
Hmm.. That's bit of a nitpick. Isn't a 's' enough here? I.e.: here we have an array of core references. Array, as the number of elements is retrieved dynamically via LARGE_CONFIG_GET and only then the array gets allocated.
Regards,
Czarek
Cezary Rojewski
maintainerPATCH v3 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 | 18 +++ sound/soc/intel/avs/core.c | 62 +++++++++ sound/soc/intel/avs/dsp.c | 26 ++++ sound/soc/intel/avs/loader.c | 237 ++++++++++++++++++++++++++++++++ sound/soc/intel/avs/registers.h | 6 + 6 files changed, 350 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 +18 -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,10 @@ 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 +52,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 +98,7 @@ struct avs_dev {struct ida ppl_ida;struct list_head fw_list;int *core_refs; +char **lib_names;struct completion fw_ready; };
@@ -215,4 +224,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 +62 -0
62 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 +237 -0
237 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
Re: [PATCH v3 14/17] ASoC: Intel: avs: General code loading flow
Quoted 344 lines · Cezary Rojewski
Code 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.Signed-off-by: Amadeusz Sławiński <
[email protected]>Signed-off-by Cezary Rojewski <[email protected]>--- sound/soc/intel/avs/Makefile | 2 +- sound/soc/intel/avs/avs.h | 18 +++ sound/soc/intel/avs/core.c | 62 +++++++++ sound/soc/intel/avs/dsp.c | 26 ++++ sound/soc/intel/avs/loader.c | 237 ++++++++++++++++++++++++++++++++ sound/soc/intel/avs/registers.h | 6 + 6 files changed, 350 insertions(+), 1 deletion(-) create mode 100644 sound/soc/intel/avs/core.c create mode 100644 sound/soc/intel/avs/loader.csound/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.osound/soc/intel/avs/avs.h +7
-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,10 @@ 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, ...)\sound/soc/intel/avs/avs.h +1
-0@@ -45,6 +52,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 */
sound/soc/intel/avs/avs.h +0
-0const u32 core_init_mask;/* used during DSP boot */ const u64 attributes;/* bitmask of AVS_PLATATTR_* */
sound/soc/intel/avs/avs.h +10
-0@@ -90,6 +98,7 @@ struct avs_dev {struct ida ppl_ida;struct list_head fw_list;int *core_refs; +char **lib_names;struct completion fw_ready; };@@ -215,4 +224,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 +22
-0@@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright(c) 2021 Intel Corporation. All rights reserved. +// +// Authors: Cezary Rojewski <[email protected]> +// Amadeusz Slawinski <[email protected]> +// +// Special thanks to: +// Krzysztof Hejmowski <[email protected]> +// Michal Sienkiewicz <[email protected]> +// Filip Proborszcz +// +// for sharing Intel AudioDSP expertise and helping shape the very +// foundation of this driver +// + +#include <linux/pci.h> +#include <sound/hdaudio.h> +#include "avs.h" + +static void +avs_hda_update_config_dword(struct hdac_bus *bus, u32 reg, u32 mask,u32 value)
sound/soc/intel/avs/core.c new file +20
-0+{ +struct pci_dev *pci =to_pci_dev (bus->dev); +u32 data; + +pci_read_config_dword (pci, reg, &data); + data &= ~mask; + data |= (value & mask); +pci_write_config_dword (pci, reg, data); +} + +void avs_hda_power_gating_enable (struct avs_dev *adev,bool enable) +{ +u32 value; + + value = enable ?0 :AZX_PGCTL_LSRMD_MASK ; +avs_hda_update_config_dword (&adev->base.core,AZX_PCIREG_PGCTL , +AZX_PGCTL_LSRMD_MASK , value); +} + +static void avs_hdac_clock_gating_enable(struct hdac_bus *bus, boolenable)
sound/soc/intel/avs/core.c new file +19
-0+{ +u32 value; + + value = enable ?AZX_CGCTL_MISCBDCGE_MASK :0 ; +avs_hda_update_config_dword (bus,AZX_PCIREG_CGCTL , +AZX_CGCTL_MISCBDCGE_MASK , value); +} + +void avs_hda_clock_gating_enable (struct avs_dev *adev,bool enable) +{ +avs_hdac_clock_gating_enable (&adev->base.core, enable); +} + +void avs_hda_l1sen_enable (struct avs_dev *adev,bool enable) +{ +u32 value; + + value = enable ?AZX_VS_EM2_L1SEN :0 ; + snd_hdac_chip_updatel(&adev->base.core, VS_EM2,
AZX_VS_EM2_L1SEN, value);sound/soc/intel/avs/core.c new file +1
-0+}sound/soc/intel/avs/dsp.c +1
-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;sound/soc/intel/avs/dsp.c +10
-0id =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);sound/soc/intel/avs/dsp.c +2
-0if (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:sound/soc/intel/avs/dsp.c +3
-0avs_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. */
sound/soc/intel/avs/dsp.c +3
-0if (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) {sound/soc/intel/avs/dsp.c +2
-0+if (avs_is_module_ida_empty (adev, module_id)) { + ret = avs_dsp_op(adev, transfer_mods, false,&mentry, 1);
sound/soc/intel/avs/dsp.c +2
-0+if (ret) + dev_err(adev->dev, "unload modulesfailed: %d\n", ret);
sound/soc/intel/avs/dsp.c +3
-0+ } + } +avs_dsp_put_core (adev, core_id); }sound/soc/intel/avs/loader.c new file +24
-0@@ -0,0 +1,237 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright(c) 2021 Intel Corporation. All rights reserved. +// +// Authors: Cezary Rojewski <[email protected]> +// Amadeusz Slawinski <[email protected]> +// + +#include <linux/firmware.h> +#include <linux/module.h> +#include <linux/slab.h> +#include "avs.h" +#include "messages.h" +#include "registers.h" + +#define AVS_FW_INIT_TIMEOUT_MS 3000 + +#define AVS_ROOT_DIR "intel/avs" +#define AVS_BASEFW_FILENAME "dsp_basefw.bin" +#define AVS_EXT_MANIFEST_MAGIC 0x31454124 +#define SKL_MANIFEST_MAGIC 0x00000006 +#define SKL_ADSPFW_OFFSET 0x284 + +/* Occasionally, engineering (release candidate) firmware is provided for testing. */
sound/soc/intel/avs/loader.c new file +2
-0+static bool debug_ignore_fw_version; +module_param_named(ignore_fw_version, debug_ignore_fw_version, bool,0444);
+MODULE_PARM_DESC(ignore_fw_version, "Verify FW version 0=yes (default), 1=no");sound/soc/intel/avs/loader.c new file +51
-0+ +#define AVS_LIB_NAME_SIZE 8 + +struct avs_fw_manifest { +u32 id; +u32 len; +char name[AVS_LIB_NAME_SIZE ]; +u32 preload_page_count; +u32 img_flags; +u32 feature_mask; +struct avs_fw_version version; +} __packed; + +struct avs_fw_ext_manifest { +u32 id; +u32 len; +u16 version_major; +u16 version_minor; +u32 entries; +} __packed; + +static int avs_fw_ext_manifest_strip (struct firmware *fw) +{ +struct avs_fw_ext_manifest *man; + +if (fw->size <sizeof (*man)) +return -EINVAL ; + + man = (struct avs_fw_ext_manifest *)fw->data; +if (man->id ==AVS_EXT_MANIFEST_MAGIC ) { + fw->data += man->len; + fw->size -= man->len; + } + +return 0 ; +} + +static int avs_fw_manifest_offset (struct firmware *fw) +{ +/* Header type found in first DWORD of fw binary. */ +u32 magic = *(u32 *)fw->data; + +switch (magic) { +case SKL_MANIFEST_MAGIC : +return SKL_ADSPFW_OFFSET ; +default : +return -EINVAL ; + } +} + +static int avs_fw_manifest_strip_verify(struct avs_dev *adev, structfirmware *fw,
sound/soc/intel/avs/loader.c new file +1
-0+ const struct avs_fw_version*min)
sound/soc/intel/avs/loader.c new file +12
-0+{ +struct avs_fw_manifest *man; +int offset, ret; + + ret =avs_fw_ext_manifest_strip (fw); +if (ret) +return ret; + + offset =avs_fw_manifest_offset (fw); +if (offset <0 ) +return offset; +
sound/soc/intel/avs/loader.c line 101
Quoted 10 lines
sound/soc/intel/avs/loader.c new file +10
-0+if (fw->size < offset +sizeof (*man)) +return -EINVAL ; +if (!min) +return 0 ; + + man = (struct avs_fw_manifest *)(fw->data + offset); +if (man->version.major != min->major || + man->version.minor != min->minor || + man->version.hotfix != min->hotfix || + man->version.build < min->build) {
Isnt this check a bit too strict? Isnt a check major enough?
Quoted 65 lines
sound/soc/intel/avs/loader.c new file +1
-0+ dev_warn(adev->dev, "bad FW version %d.%d.%d.%d,expected %d.%d.%d.%d or newer\n",
sound/soc/intel/avs/loader.c new file +3
-0+ man->version.major, man->version.minor, + man->version.hotfix, man->version.build, + min->major, min->minor, min->hotfix, min-Quoted 1 line
build);
sound/soc/intel/avs/loader.c new file +18
-0+ +if (!debug_ignore_fw_version) +return -EINVAL ; + } + +return 0 ; +} + +static int avs_dsp_load_basefw (struct avs_dev *adev) +{ +const struct avs_fw_version *min_req; +const struct avs_spec *const spec = adev->spec; +const struct firmware *fw; +struct firmware stripped_fw; +char *filename; +int ret; + + filename = kasprintf(GFP_KERNEL, "%s/%s/%s", AVS_ROOT_DIR,
spec->name,sound/soc/intel/avs/loader.c new file +8
-0+ AVS_BASEFW_FILENAME); +if (!filename) +return -ENOMEM ; + + ret =avs_request_firmware (adev, &fw, filename); +kfree (filename); +if (ret <0 ) { + dev_err(adev->dev, "request firmware failed: %d\n",ret);
sound/soc/intel/avs/loader.c new file +7
-0+return ret; + } + + stripped_fw = *fw; + min_req = &adev->spec->min_fw_version; + + ret = avs_fw_manifest_strip_verify(adev, &stripped_fw,
min_req);sound/soc/intel/avs/loader.c new file +13
-0+if (ret <0 ) { +dev_err (adev->dev,"invalid firmware data: %d\n" , ret); + goto release_fw; + } + + ret =avs_dsp_op (adev, load_basefw, &stripped_fw); +if (ret <0 ) { +dev_err (adev->dev,"basefw load failed: %d\n" , ret); + goto release_fw; + } + + ret = wait_for_completion_timeout(&adev->fw_ready, + msecs_to_jiffies(AVS_FW_INIT_
TIMEOUT_MS));sound/soc/intel/avs/loader.c new file +9
-0+if (!ret) { +dev_err (adev->dev,"firmware ready timeout\n" ); +avs_dsp_core_disable (adev,AVS_MAIN_CORE_MASK ); + ret = -ETIMEDOUT ; + goto release_fw; + } + +return 0 ; +
sound/soc/intel/avs/loader.c line 170
Quoted 10 lines
sound/soc/intel/avs/loader.c new file +10
-0+release_fw: +avs_release_last_firmware (adev); +return ret; +} + +int avs_dsp_boot_firmware (struct avs_dev *adev,bool purge) +{ +int ret, i; + +/* Full boot, clear cached data except for basefw (slot 0). */
Does this mean IMR restore is only available for base FW and not for module libraries? Do I understand this correctly?
Quoted 6 lines
sound/soc/intel/avs/loader.c new file +6
-0+for (i =1 ; i < adev->fw_cfg.max_libs_count; i++) +memset (adev->lib_names[i],0 ,AVS_LIB_NAME_SIZE ); + +avs_hda_clock_gating_enable (adev, false); +avs_hda_l1sen_enable (adev, false); +
sound/soc/intel/avs/loader.c line 186
Quoted 10 lines
sound/soc/intel/avs/loader.c new file +10
-0+ ret =avs_dsp_load_basefw (adev); + +avs_hda_l1sen_enable (adev, true); +avs_hda_clock_gating_enable (adev, true); + +if (ret <0 ) +return ret; + +/* With all code loaded, refresh module information. */ + ret =avs_module_info_init (adev, true);
It is not clear if this required only after first boot or after a suspend/resume as well.
Thanks,Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 14/17] ASoC: Intel: avs: General code loading flow
Quoted 1 line · Ranjani Sridharan
On Fri, 2022-03-04 at 15:57 +0100, Cezary Rojewski wrote:
...
Quoted 19 lines
Quoted 19 lines
+static int avs_fw_manifest_strip_verify(struct
avs_dev*adev, struct firmware *fw,(quoted diff) +1
-0+ const struct avs_fw_version*min)
sound/soc/intel/avs/loader.c new file +15
-0+{ +struct avs_fw_manifest *man; +int offset, ret; + + ret =avs_fw_ext_manifest_strip (fw); +if (ret) +return ret; + + offset =avs_fw_manifest_offset (fw); +if (offset <0 ) +return offset; + +if (fw->size < offset +sizeof (*man)) +return -EINVAL ; +if (!min)
Quoted 8 lines
sound/soc/intel/avs/loader.c line 101
Quoted 7 lines
sound/soc/intel/avs/loader.c new file +7
-0+return 0 ; + + man = (struct avs_fw_manifest *)(fw->data + offset); +if (man->version.major != min->major || + man->version.minor != min->minor || + man->version.hotfix != min->hotfix || + man->version.build < min->build) {Isnt this check a bit too strict? Isnt a check major enough?
Unfortunately not. I share the similar thinking but the build system has its history and several things which should not happen, had happened. There could be _large_ API changes without any meaningful version updates at all. To prevent any unwanted behavior, this check is as strict as it can get.
Quoted 13 lines
Quoted 13 lines
(quoted diff) +1
-0+ dev_warn(adev->dev, "bad FW version %d.%d.%d.%d,expected %d.%d.%d.%d or newer\n",
sound/soc/intel/avs/loader.c new file +3
-0+ man->version.major, man->version.minor, + man->version.hotfix, man->version.build, + min->major, min->minor, min->hotfix, min-Quoted 1 line
build);
sound/soc/intel/avs/loader.c new file +7
-0+ +if (!debug_ignore_fw_version) +return -EINVAL ; + } + +return 0 ; +}
...
Quoted 7 lines
sound/soc/intel/avs/loader.c line 170
Quoted 5 lines
sound/soc/intel/avs/loader.c new file +5
-0+int avs_dsp_boot_firmware (struct avs_dev *adev,bool purge) +{ +int ret, i; + +/* Full boot, clear cached data except for basefw (slot 0). */ Does this mean IMR restore is only available for base FW and not for module libraries? Do I understand this correctly?
Loop below just clears the data. The new snapshot will be received once the basefw and libraries get loaded. The execution of library loading is not part of this patch anymore as it is dependent on the avs-soc-component stuff. To make things easier to review, request was to split main series into chucks. I do believe it is easier to read and review indeed.
Quoted 10 lines
Quoted 10 lines
sound/soc/intel/avs/loader.c new file +10
-0+for (i =1 ; i < adev->fw_cfg.max_libs_count; i++) +memset (adev->lib_names[i],0 ,AVS_LIB_NAME_SIZE ); + +avs_hda_clock_gating_enable (adev, false); +avs_hda_l1sen_enable (adev, false); + + ret =avs_dsp_load_basefw (adev); + +avs_hda_l1sen_enable (adev, true); +avs_hda_clock_gating_enable (adev, true);
Quoted 8 lines
sound/soc/intel/avs/loader.c line 186
Quoted 6 lines
sound/soc/intel/avs/loader.c new file +6
-0+ +if (ret <0 ) +return ret; + +/* With all code loaded, refresh module information. */ + ret =avs_module_info_init (adev, true);It is not clear if this required only after first boot or after a suspend/resume as well.
avs_dsp_boot_firmware() and avs_dsp_first_boot_firmware() (found just below this one) are two separate functions. Only the latter has things done once. Anything else can happen several times throughout the lifetime of the avs-driver.
Regards,
Czarek
Cezary Rojewski
maintainerPATCH v3 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 | 317 ++++++++++++++++++++++++++++++++ sound/soc/intel/avs/cldma.h | 29 +++ sound/soc/intel/avs/registers.h | 2 + 4 files changed, 349 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 +317 -0
317 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 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 v3 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
@@ -44,6 +44,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)
@@ -233,4 +235,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 v3 17/17 ASoC: Intel: avs: Code loading over HDA
In reply to Cezary RojewskiCompared to SKL and KBL, younger 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 dummy 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 | 211 +++++++++++++++++++++++++++++++++++ 3 files changed, 217 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
@@ -45,6 +45,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)
@@ -239,5 +240,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 +211 -0
237 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v3 17/17] ASoC: Intel: avs: Code loading over HDA
Quoted 2 lines · Cezary Rojewski
Compared to SKL and KBL, younger cAVS platforms are meant to re-use one
Younger? you mean newer?
Quoted 7 lines
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 dummy as library and module code became inseparable in later firmware generations.
replace dummy with "stub" maybe? lets use inclusive terms
Quoted 116 lines
Signed-off-by: Amadeusz Sławiński <
[email protected]>Signed-off-by Cezary Rojewski <[email protected]>--- sound/soc/intel/Kconfig | 1 + sound/soc/intel/avs/avs.h | 5 + sound/soc/intel/avs/loader.c | 211 +++++++++++++++++++++++++++++++++++ 3 files changed, 217 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 andsound/soc/intel/avs/avs.h +1
-0@@ -45,6 +45,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)@@ -239,5 +240,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);sound/soc/intel/avs/avs.h +2
-0+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);
sound/soc/intel/avs/avs.h +2
-0+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 +34
-0@@ -9,6 +9,7 @@#include <linux/firmware.h> #include <linux/module.h> #include <linux/slab.h> +#include <sound/hdaudio.h> #include <sound/hdaudio_ext.h> #include "avs.h" #include "cldma.h" @@ -18,8 +19,11 @@#define AVS_ROM_STS_MASK 0xFF#define AVS_ROM_INIT_DONE 0x1#define SKL_ROM_BASEFW_ENTERED 0xF +#define APL_ROM_FW_ENTERED 0x5#define AVS_ROM_INIT_POLLING_US 5#define SKL_ROM_INIT_TIMEOUT_US 1000000 +#define APL_ROM_INIT_TIMEOUT_US 300000 +#define APL_ROM_INIT_RETRIES 3#define AVS_FW_INIT_POLLING_US 500#define AVS_FW_INIT_TIMEOUT_US 3000000@@ -261,6 +265,204 @@ int avs_cldma_transfer_modules(struct avs_dev *adev, bool load, return 0; } +static int +avs_hda_init_rom (struct avs_dev *adev,unsigned int dma_id,bool purge) +{ +const struct avs_spec *const spec = adev->spec; +unsigned int corex_mask, reg; +int ret; + + corex_mask = spec->core_init_mask & ~AVS_MAIN_CORE_MASK ; + + ret =avs_dsp_op (adev, power, spec->core_init_mask, true); +if (ret <0 ) + goto err; + + ret =avs_dsp_op (adev, reset,AVS_MAIN_CORE_MASK , false); +if (ret <0 ) + goto err; + +reinit_completion (&adev->fw_ready); +avs_dsp_op (adev, int_control, true); + +/* set boot config */ + ret =avs_ipc_set_boot_config (adev, dma_id, purge); +if (ret) { + ret =AVS_IPC_RET (ret); + goto err; + } + +/* await ROM init */ + ret =snd_hdac_adsp_readq_poll (adev, spec->rom_status, reg, + (reg & 0xF) == AVS_ROM_INIT_DONE||
sound/soc/intel/avs/loader.c +1
-0+ (reg & 0xF) ==
APL_ROM_FW_ENTERED,sound/soc/intel/avs/loader.c +1
-0+ AVS_ROM_INIT_POLLING_US,
APL_ROM_INIT_TIMEOUT_US);
sound/soc/intel/avs/loader.c int avs_cldma_transfer_modules(struct avs_dev *adev, bool load, · line 307
Quoted 8 lines
sound/soc/intel/avs/loader.c +8
-0+if (ret <0 ) { +dev_err (adev->dev,"rom init timeout: %d\n" , ret); + goto err; + } + +/* power down non-main cores */ +if (corex_mask) +avs_dsp_op (adev, power, corex_mask, false);
What if this fails?
Quoted 164 lines
sound/soc/intel/avs/loader.c +13
-0+ +return 0 ; + +err: +avs_dsp_core_disable (adev, spec->core_init_mask); +return ret; +} + +static int avs_imr_load_basefw (struct avs_dev *adev) +{ +int ret; + +/* DMA id ignored when flashing from IMR as no transfer occurs. */
sound/soc/intel/avs/loader.c +8
-0+ ret =avs_hda_init_rom (adev,0 , false); +if (ret <0 ) { +dev_err (adev->dev,"rom init failed: %d\n" , ret); +return ret; + } + + ret = wait_for_completion_timeout(&adev->fw_ready, + msecs_to_jiffies(AVS_FW_INIT_TIMEOUT_MS));
sound/soc/intel/avs/loader.c +24
-0+if (!ret) { +dev_err (adev->dev,"firmware ready timeout\n" ); +avs_dsp_core_disable (adev,AVS_MAIN_CORE_MASK ); +return -ETIMEDOUT ; + } + +return 0 ; +} + +int avs_hda_load_basefw (struct avs_dev *adev,struct firmware *fw) +{ +struct snd_pcm_substream substream; +struct snd_dma_buffer dmab; +struct hdac_ext_stream *estream; +struct hdac_stream *hstream; +struct hdac_bus *bus = &adev->base.core; +unsigned int sdfmt, reg; +int ret, i; + +/* configure hda dma */ +memset (&substream,0 ,sizeof (substream)); + substream.stream =SNDRV_PCM_STREAM_PLAYBACK ; + estream =snd_hdac_ext_stream_assign (bus, &substream, +HDAC_EXT_STREAM_TYPE_HOST );
sound/soc/intel/avs/loader.c +6
-0+if (!estream) +return -ENODEV ; + hstream =hdac_stream (estream); + +/* code loading performed with default format */ + sdfmt = snd_hdac_calc_stream_format(48000, 1,
SNDRV_PCM_FORMAT_S32_LE, 32, 0);sound/soc/intel/avs/loader.c +19
-0+ ret =snd_hdac_dsp_prepare (hstream, sdfmt, fw->size, &dmab); +if (ret <0 ) + goto release_stream; + +/* enable SPIB for hda stream */ +snd_hdac_ext_stream_spbcap_enable (bus, true, hstream->index); + ret =snd_hdac_ext_stream_set_spib (bus, estream, fw->size); +if (ret) + goto cleanup_resources; + +memcpy (dmab.area, fw->data, fw->size); + +for (i =0 ; i <APL_ROM_INIT_RETRIES ; i++) { +unsigned int dma_id = hstream->stream_tag -1 ; + + ret =avs_hda_init_rom (adev, dma_id, true); +if (!ret) +break ; + dev_info(adev->dev, "#%d rom init fail: %d\n", i + 1,ret);
sound/soc/intel/avs/loader.c +7
-0+ } +if (ret <0 ) + goto cleanup_resources; + +/* transfer firmware */ +snd_hdac_dsp_trigger (hstream, true); + ret = snd_hdac_adsp_readl_poll(adev, AVS_FW_REG_STATUS(adev),reg,
sound/soc/intel/avs/loader.c +1
-0+ (reg & AVS_ROM_STS_MASK) ==
APL_ROM_FW_ENTERED,sound/soc/intel/avs/loader.c +1
-0+ AVS_FW_INIT_POLLING_US,
AVS_FW_INIT_TIMEOUT_US);sound/soc/intel/avs/loader.c +14
-0+snd_hdac_dsp_trigger (hstream, false); +if (ret <0 ) { +dev_err (adev->dev,"transfer fw failed: %d\n" , ret); +avs_dsp_core_disable (adev,AVS_MAIN_CORE_MASK ); + } + +cleanup_resources: +/* disable SPIB for hda stream */ +snd_hdac_ext_stream_spbcap_enable (bus, false, hstream->index); +snd_hdac_ext_stream_set_spib (bus, estream,0 ); + +snd_hdac_dsp_cleanup (hstream, &dmab); +release_stream: + snd_hdac_ext_stream_release(estream,
HDAC_EXT_STREAM_TYPE_HOST);sound/soc/intel/avs/loader.c +5
-0+ +return ret; +} + +int avs_hda_load_library(struct avs_dev *adev, struct firmware *lib,u32 id)
sound/soc/intel/avs/loader.c +14
-0+{ +struct snd_pcm_substream substream; +struct snd_dma_buffer dmab; +struct hdac_ext_stream *estream; +struct hdac_stream *stream; +struct hdac_bus *bus = &adev->base.core; +unsigned int sdfmt; +int ret; + +/* configure hda dma */ +memset (&substream,0 ,sizeof (substream)); + substream.stream =SNDRV_PCM_STREAM_PLAYBACK ; + estream =snd_hdac_ext_stream_assign (bus, &substream, +HDAC_EXT_STREAM_TYPE_HOST );
sound/soc/intel/avs/loader.c +6
-0+if (!estream) +return -ENODEV ; + stream =hdac_stream (estream); + +/* code loading performed with default format */ + sdfmt = snd_hdac_calc_stream_format(48000, 1,
SNDRV_PCM_FORMAT_S32_LE, 32, 0);sound/soc/intel/avs/loader.c +16
-0+ ret =snd_hdac_dsp_prepare (stream, sdfmt, lib->size, &dmab); +if (ret <0 ) + goto release_stream; + +/* enable SPIB for hda stream */ +snd_hdac_ext_stream_spbcap_enable (bus, true, stream->index); +snd_hdac_ext_stream_set_spib (bus, estream, lib->size); + +memcpy (dmab.area, lib->data, lib->size); + +/* transfer firmware */ +snd_hdac_dsp_trigger (stream, true); + ret =avs_ipc_load_library (adev, stream->stream_tag -1 , id); +snd_hdac_dsp_trigger (stream, false); +if (ret) { + dev_err(adev->dev, "transfer lib %d failed: %d\n", id,ret);
sound/soc/intel/avs/loader.c +10
-0+ ret =AVS_IPC_RET (ret); + } + +/* disable SPIB for hda stream */ +snd_hdac_ext_stream_spbcap_enable (bus, false, stream->index); +snd_hdac_ext_stream_set_spib (bus, estream,0 ); + +snd_hdac_dsp_cleanup (stream, &dmab); +release_stream: + snd_hdac_ext_stream_release(estream,
HDAC_EXT_STREAM_TYPE_HOST);sound/soc/intel/avs/loader.c +6
-0+ +return ret; +} + +int avs_hda_transfer_modules (struct avs_dev *adev,bool load, + struct avs_module_entry *mods, u32
Quoted 1 line
num_mods)
What is the difference between transfer_modules and load_library?
Thanks,Ranjani
Cezary Rojewski
maintainerRe: [PATCH v3 17/17] ASoC: Intel: avs: Code loading over HDA
Quoted 4 lines · Ranjani Sridharan
Quoted 2 lines · Cezary Rojewski
Compared to SKL and KBL, younger cAVS platforms are meant to re-use one
Younger? you mean newer?
Isn't the meaning of the two quite similar in this context?
Quoted 8 lines
Quoted 7 lines
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 dummy as library and module code became inseparable in later firmware generations.
replace dummy with "stub" maybe? lets use inclusive terms
Is 'dummy' categorized as non-inclusive? We have several usages of 'dummy' even within /sound (e.g. soc-utils.c).
Quoted 37 lines
Quoted 37 lines
(quoted diff) +2
-0+static int +avs_hda_init_rom(struct avs_dev *adev, unsigned int dma_id, boolpurge)
sound/soc/intel/avs/loader.c +28
-0+{ +const struct avs_spec *const spec = adev->spec; +unsigned int corex_mask, reg; +int ret; + + corex_mask = spec->core_init_mask & ~AVS_MAIN_CORE_MASK ; + + ret =avs_dsp_op (adev, power, spec->core_init_mask, true); +if (ret <0 ) + goto err; + + ret =avs_dsp_op (adev, reset,AVS_MAIN_CORE_MASK , false); +if (ret <0 ) + goto err; + +reinit_completion (&adev->fw_ready); +avs_dsp_op (adev, int_control, true); + +/* set boot config */ + ret =avs_ipc_set_boot_config (adev, dma_id, purge); +if (ret) { + ret =AVS_IPC_RET (ret); + goto err; + } + +/* await ROM init */ + ret =snd_hdac_adsp_readq_poll (adev, spec->rom_status, reg, + (reg & 0xF) == AVS_ROM_INIT_DONE||
(quoted diff) +1
-0+ (reg & 0xF) ==
APL_ROM_FW_ENTERED,(quoted diff) +1
-0+ AVS_ROM_INIT_POLLING_US,
APL_ROM_INIT_TIMEOUT_US);(quoted diff) +1
-0+ if (ret < 0) {
Quoted 8 lines
sound/soc/intel/avs/loader.c int avs_cldma_transfer_modules(struct avs_dev *adev, bool load, · line 307
Quoted 7 lines
sound/soc/intel/avs/loader.c +7
-0+dev_err (adev->dev,"rom init timeout: %d\n" , ret); + goto err; + } + +/* power down non-main cores */ +if (corex_mask) +avs_dsp_op (adev, power, corex_mask, false);What if this fails?
We are still in happy path, worst thing could happen here is increased power consumption.
Quoted 8 lines
Quoted 8 lines
sound/soc/intel/avs/loader.c +8
-0+ +return 0 ; + +err: +avs_dsp_core_disable (adev, spec->core_init_mask); +return ret; +} +
...
Quoted 52 lines
Quoted 52 lines
+int
avs_hda_load_library(struct avs_dev *adev, struct firmware *lib, u32 id)sound/soc/intel/avs/loader.c +14
-0+{ +struct snd_pcm_substream substream; +struct snd_dma_buffer dmab; +struct hdac_ext_stream *estream; +struct hdac_stream *stream; +struct hdac_bus *bus = &adev->base.core; +unsigned int sdfmt; +int ret; + +/* configure hda dma */ +memset (&substream,0 ,sizeof (substream)); + substream.stream =SNDRV_PCM_STREAM_PLAYBACK ; + estream =snd_hdac_ext_stream_assign (bus, &substream, +HDAC_EXT_STREAM_TYPE_HOST );
sound/soc/intel/avs/loader.c +6
-0+if (!estream) +return -ENODEV ; + stream =hdac_stream (estream); + +/* code loading performed with default format */ + sdfmt = snd_hdac_calc_stream_format(48000, 1,
SNDRV_PCM_FORMAT_S32_LE, 32, 0);sound/soc/intel/avs/loader.c +16
-0+ ret =snd_hdac_dsp_prepare (stream, sdfmt, lib->size, &dmab); +if (ret <0 ) + goto release_stream; + +/* enable SPIB for hda stream */ +snd_hdac_ext_stream_spbcap_enable (bus, true, stream->index); +snd_hdac_ext_stream_set_spib (bus, estream, lib->size); + +memcpy (dmab.area, lib->data, lib->size); + +/* transfer firmware */ +snd_hdac_dsp_trigger (stream, true); + ret =avs_ipc_load_library (adev, stream->stream_tag -1 , id); +snd_hdac_dsp_trigger (stream, false); +if (ret) { + dev_err(adev->dev, "transfer lib %d failed: %d\n", id,ret);
sound/soc/intel/avs/loader.c +10
-0+ ret =AVS_IPC_RET (ret); + } + +/* disable SPIB for hda stream */ +snd_hdac_ext_stream_spbcap_enable (bus, false, stream->index); +snd_hdac_ext_stream_set_spib (bus, estream,0 ); + +snd_hdac_dsp_cleanup (stream, &dmab); +release_stream: + snd_hdac_ext_stream_release(estream,
HDAC_EXT_STREAM_TYPE_HOST);
Quoted 8 lines
Quoted 7 lines
sound/soc/intel/avs/loader.c +6
-0+ +return ret; +} + +int avs_hda_transfer_modules (struct avs_dev *adev,bool load, + struct avs_module_entry *mods, u32
num_mods)What is the difference between
transfer_modulesandload_library?
Libraries targeting SKL/KBL/AML platforms *are just manifests* - the actual module code is found in the separate file(s) and thus the need for separate handlers. The driver has to load both the manifest and the module code to have a working streaming scenario requiring module type exposed by said library.
Regards,
Czarek
Re: [PATCH v3 17/17] ASoC: Intel: avs: Code loading over HDA
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Compared to SKL and KBL, younger cAVS platforms are meant to re-use one
Younger? you mean newer?
Isn't the meaning of the two quite similar in this context?
younger doesn't sound quite right to me.
'cAVS platforms more recent that SKL and KBL...'
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
of HDAudio streams during boot procedure causing CLDMA to become obsolete. Once transferred, given stream is returned to pool available
for audio streaming.
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Module loading handler is dummy as library and module code became inseparable in later firmware generations.
replace dummy with "stub" maybe? lets use inclusive terms
Is 'dummy' categorized as non-inclusive? We have several usages of 'dummy' even within /sound (e.g.
soc-utils.c).
Intel and plenty of other companies recommend a different wording. mock-up, stub, placeholder, etc. see e.g.
https://developers.google.com/style/inclusive-documentation
Yes we have plenty of existing uses of 'dummy', but that doesn't mean we should add new ones.
Quoted 47 lines
Quoted 37 lines
Quoted 37 lines
(quoted diff) +2
-0+static int +avs_hda_init_rom(struct avs_dev *adev, unsigned int dma_id, boolpurge)
sound/soc/intel/avs/loader.c +28
-0+{ + const struct avs_spec *const spec = adev->spec; + unsigned int corex_mask, reg; + int ret; + + corex_mask = spec->core_init_mask & ~AVS_MAIN_CORE_MASK; + + ret = avs_dsp_op(adev, power, spec->core_init_mask, true); + if (ret < 0) + goto err; + + ret = avs_dsp_op(adev, reset, AVS_MAIN_CORE_MASK, false); + if (ret < 0) + goto err; + + reinit_completion(&adev->fw_ready); + avs_dsp_op(adev, int_control, true); + + /* set boot config */ + ret = avs_ipc_set_boot_config(adev, dma_id, purge); + if (ret) { + ret = AVS_IPC_RET(ret); + goto err; + } + + /* await ROM init */ + ret = snd_hdac_adsp_readq_poll(adev, spec->rom_status, reg, + (reg & 0xF) == AVS_ROM_INIT_DONE||
+ (reg &0xF) ==APL_ROM_FW_ENTERED,
+AVS_ROM_INIT_POLLING_US,APL_ROM_INIT_TIMEOUT_US);
+ if (ret < 0) {Quoted 8 lines
Quoted 7 lines
+
dev_err(adev->dev, "rom init timeout: %d\n", ret); + goto err;
+ }
+
+ /* power down non-main cores */
+ if (corex_mask)
+avs_dsp_op(adev, power, corex_mask, false);What if this fails?
Quoted 1 line
We are still in happy path, worst thing could happen here is increased power consumption.
'happy path'?
Cezary Rojewski
maintainerRe: [PATCH v3 17/17] ASoC: Intel: avs: Code loading over HDA
Quoted 11 lines · Pierre-Louis Bossart
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Compared to SKL and KBL, younger cAVS platforms are meant to re-use one
Younger? you mean newer?
Isn't the meaning of the two quite similar in this context?
younger doesn't sound quite right to me.
'cAVS platforms more recent that SKL and KBL...'
Sure, can reword.
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
Module loading handler is dummy as library and module code became inseparable in later firmware generations.
replace dummy with "stub" maybe? lets use inclusive terms
Quoted 7 lines
Quoted 1 line
Is 'dummy' categorized as non-inclusive? We have several usages of 'dummy' even within /sound (e.g.
soc-utils.c).Intel and plenty of other companies recommend a different wording. mock-up, stub, placeholder, etc. see e.g.
https://developers.google.com/style/inclusive-documentation
Yes we have plenty of existing uses of 'dummy', but that doesn't mean we should add new ones.
No problem with rewording this one in v4.
Quoted 47 lines
Quoted 47 lines
Quoted 45 lines
Quoted 36 lines
(quoted diff) +2
-0+static int +avs_hda_init_rom(struct avs_dev *adev, unsigned int dma_id, boolpurge)
sound/soc/intel/avs/loader.c +28
-0+{ + const struct avs_spec *const spec = adev->spec; + unsigned int corex_mask, reg; + int ret; + + corex_mask = spec->core_init_mask & ~AVS_MAIN_CORE_MASK; + + ret = avs_dsp_op(adev, power, spec->core_init_mask, true); + if (ret < 0) + goto err; + + ret = avs_dsp_op(adev, reset, AVS_MAIN_CORE_MASK, false); + if (ret < 0) + goto err; + + reinit_completion(&adev->fw_ready); + avs_dsp_op(adev, int_control, true); + + /* set boot config */ + ret = avs_ipc_set_boot_config(adev, dma_id, purge); + if (ret) { + ret = AVS_IPC_RET(ret); + goto err; + } + + /* await ROM init */ + ret = snd_hdac_adsp_readq_poll(adev, spec->rom_status, reg, + (reg & 0xF) == AVS_ROM_INIT_DONE||
+ (reg &0xF) ==APL_ROM_FW_ENTERED,
+AVS_ROM_INIT_POLLING_US,APL_ROM_INIT_TIMEOUT_US);Quoted 8 lines
+ if (ret < 0) {
+dev_err(adev->dev, "rom init timeout: %d\n", ret); + goto err;
+ }
+
+ /* power down non-main cores */
+ if (corex_mask)
+avs_dsp_op(adev, power, corex_mask, false);What if this fails?
Quoted 3 lines
Quoted 1 line
We are still in happy path, worst thing could happen here is increased power consumption.
'happy path'?
The question is whether we value user experience over error-checking this case. I've never seen this step failing and the step itself is quite.. extraordinary : ) It's also invoked on very limited number of cAVS platforms, for everything else it's just: 'return 0'.
Regards,
Czarek