ASoC: Intel: AVS - Audio DSP for cAVS
Subsystems (3)
Cezary Rojewski
maintainercover 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 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 | 49 ++ include/sound/soc-dapm.h | 1 + sound/soc/intel/Kconfig | 15 + sound/soc/intel/Makefile | 1 + sound/soc/intel/avs/Makefile | 6 + sound/soc/intel/avs/avs.h | 226 ++++++++++ sound/soc/intel/avs/cldma.c | 328 ++++++++++++++ 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 | 410 +++++++++++++++++ sound/soc/intel/avs/loader.c | 594 +++++++++++++++++++++++++ sound/soc/intel/avs/messages.c | 642 +++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 762 ++++++++++++++++++++++++++++++++ sound/soc/intel/avs/registers.h | 75 ++++ sound/soc/intel/avs/utils.c | 282 ++++++++++++ sound/soc/soc-core.c | 1 + sound/soc/soc-dapm.c | 15 + 19 files changed, 3803 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 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 | 49 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 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 +49 -0
61 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 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 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 | 14 +++++ sound/soc/intel/Makefile | 1 + sound/soc/intel/avs/Makefile | 5 ++ sound/soc/intel/avs/avs.h | 64 +++++++++++++++++++ sound/soc/intel/avs/dsp.c | 107 ++++++++++++++++++++++++++++++++ sound/soc/intel/avs/registers.h | 22 +++++++ 6 files changed, 213 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 +14 -0
@@ -209,5 +209,19 @@ 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 + depends on SND_SOC_INTEL_SKYLAKE_FAMILY=n + default n + 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. This option is mutually exclusive with SKYLAKE + driver. + # 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 +64 -0
64 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 03/17] ASoC: Intel: Introduce AVS driver
sound/soc/intel/Kconfig config SND_SOC_INTEL_KEEMBAY · line 217
Quoted 9 lines
sound/soc/intel/Kconfig +6
-0+config SND_SOC_INTEL_AVS + tristate "Intel AVS driver" + depends on PCI && ACPI + depends on COMMON_CLK + depends on SND_SOC_INTEL_SKYLAKE_FAMILY=n + default n
default is already n
sound/soc/intel/Kconfig config SND_SOC_INTEL_KEEMBAY · line 224
Quoted 7 lines
sound/soc/intel/Kconfig +7
-0+ 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. This option is mutually exclusive with SKYLAKE + driver.
The feedback from the RFC was that this is not desirable if you want anyone to use this driver. The suggested solution was to use the intel_dspcfg layer with e.g. dsp_driver=4 for avs. That would allow distributions to build this solution for early adopters.
sound/soc/intel/avs/avs.h line 33
Quoted 5 lines
sound/soc/intel/avs/avs.h new file +5
-0+/* Platform specific descriptor */ +struct avs_spec { +const char *name; + +const struct avs_dsp_ops *const dops;
dsp_ops would be clearer. 'd' could refer to just about anything.
sound/soc/intel/avs/avs.h line 41
Quoted 7 lines
sound/soc/intel/avs/avs.h new file +7
-0+const u32 core_init_mask;/* used during DSP boot */ +const u64 attributes;/* bitmask of AVS_PLATATTR_* */ +}; + +struct avs_dev { +struct hda_bus base; +struct device *dev;
question: could you directly embed a struct device instead of a pointer, that would simplify the conversion through dev_get_drvdata below.
Unless this *dev is related to the PCI device, in which case you could add a comment.
Review
Quoted 2 lines
(quoted diff) +2
-0+ + void __iomem *adsp_ba;
I would guess 'ba' is base address? this could be added with comments or kernel-doc
Quoted 5 lines
sound/soc/intel/avs/avs.h new file +5
-0+const struct avs_spec *spec; +}; + +/* from hda_bus to avs_dev */ +#define hda_to_avs (hda) container_of(hda, struct avs_dev, base)
sound/soc/intel/avs/avs.h line 58
Quoted 10 lines
sound/soc/intel/avs/avs.h new file +10
-0+/* from hdac_bus to avs_dev */ +#define hdac_to_avs (hdac) hda_to_avs(to_hda_bus(hdac)) +/* from device to avs_dev */ +#define to_avs_dev (dev) \ +({ \ + struct hdac_bus *__bus = dev_get_drvdata(dev); \ + hdac_to_avs(__bus); \ +}) + +int avs_dsp_core_power (struct avs_dev *adev,u32 core_mask,bool active);
does this mean 'active' affects all bits in the core_mask? that doesn't seem very intuitive.
sound/soc/intel/avs/avs.h line 62
Quoted 4 lines
sound/soc/intel/avs/avs.h new file +4
-0+int avs_dsp_core_reset (struct avs_dev *adev,u32 core_mask,bool reset); +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);
it's a bit inconsistent to have enable/disable but a boolean for other functions?
sound/soc/intel/avs/dsp.c line 12
Quoted 4 lines
sound/soc/intel/avs/dsp.c new file +4
-0+#include <linux/module.h> +#include <sound/hdaudio_ext.h> +#include "avs.h" +#include "registers.h"
consider renaming as avs_registers.h?
sound/soc/intel/avs/dsp.c line 15
Quoted 3 lines
sound/soc/intel/avs/dsp.c new file +3
-0+ +#define AVS_ADSPCS_INTERVAL_US 500 +#define AVS_ADSPCS_TIMEOUT_US 10000
these values don't match with anything that was previously used for Intel platforms, where the values could be different depending on generations.
bxt-sst.c:#define BXT_BASEFW_TIMEOUT 3000 bxt-sst.c:#define BXT_ROM_INIT_TIMEOUT 70 cnl-sst.c:#define CNL_INIT_TIMEOUT 300 cnl-sst.c:#define CNL_BASEFW_TIMEOUT 3000
skl-sst-cldma.h:#define SKL_WAIT_TIMEOUT 500 /* 500
msec */
skl-sst-dsp.h:#define BXT_INIT_TIMEOUT 300
skl-sst-ipc.c:#define IPC_TIMEOUT_MSECS 3000
skl-sst.c:#define SKL_BASEFW_TIMEOUT 300
skl-sst.c:#define SKL_INIT_TIMEOUT 1000
please add a comment on how they were determined or align on hardware recommendations.
Quoted 10 lines
sound/soc/intel/avs/dsp.c new file +10
-0+int avs_dsp_core_power (struct avs_dev *adev,u32 core_mask,bool active) +{ +u32 value, mask, reg; +int ret; + + mask =AVS_ADSPCS_SPA_MASK (core_mask); + value = active ? mask :0 ; + +snd_hdac_adsp_updatel (adev,AVS_ADSP_REG_ADSPCS , mask, value); +
sound/soc/intel/avs/dsp.c line 36
Quoted 10 lines
sound/soc/intel/avs/dsp.c new file +10
-0+ mask =AVS_ADSPCS_CPA_MASK (core_mask); + value = active ? mask :0 ; + + ret =snd_hdac_adsp_readl_poll (adev,AVS_ADSP_REG_ADSPCS , + reg, (reg & mask) == value, +AVS_ADSPCS_INTERVAL_US , +AVS_ADSPCS_TIMEOUT_US ); +if (ret) +dev_err (adev->dev,"core_mask %d %spower failed: %d\n" , + core_mask, active ?"" :"un" , ret);
unpower is an odd wording.
Quoted 11 lines
sound/soc/intel/avs/dsp.c new file +11
-0+ +return ret; +} + +int avs_dsp_core_reset (struct avs_dev *adev,u32 core_mask,bool reset) +{ +u32 value, mask, reg; +int ret; + + mask =AVS_ADSPCS_CRST_MASK (core_mask); + value = reset ? mask :0 ;
sound/soc/intel/avs/dsp.c line 57
Quoted 10 lines
sound/soc/intel/avs/dsp.c new file +10
-0+ +snd_hdac_adsp_updatel (adev,AVS_ADSP_REG_ADSPCS , mask, value); + + ret =snd_hdac_adsp_readl_poll (adev,AVS_ADSP_REG_ADSPCS , + reg, (reg & mask) == value, +AVS_ADSPCS_INTERVAL_US , +AVS_ADSPCS_TIMEOUT_US ); +if (ret) +dev_err (adev->dev,"core_mask %d %sreset failed: %d\n" , + core_mask, reset ?"" :"un" , ret);
unreset is even more odd. enter reset or exit reset.
Quoted 11 lines
sound/soc/intel/avs/dsp.c new file +11
-0+ +return ret; +} + +int avs_dsp_core_stall (struct avs_dev *adev,u32 core_mask,bool stall) +{ +u32 value, mask, reg; +int ret; + + mask =AVS_ADSPCS_CSTALL_MASK (core_mask); + value = stall ? mask :0 ;
sound/soc/intel/avs/dsp.c line 78
Quoted 10 lines
sound/soc/intel/avs/dsp.c new file +10
-0+ +snd_hdac_adsp_updatel (adev,AVS_ADSP_REG_ADSPCS , mask, value); + + ret =snd_hdac_adsp_readl_poll (adev,AVS_ADSP_REG_ADSPCS , + reg, (reg & mask) == value, +AVS_ADSPCS_INTERVAL_US , +AVS_ADSPCS_TIMEOUT_US ); +if (ret) +dev_err (adev->dev,"core_mask %d %sstall failed: %d\n" , + core_mask, stall ?"" :"un" , ret);
that was probably a copy/paste of stall/unstall in the two cases above...this one works, the two above not so much.
Quoted 12 lines
sound/soc/intel/avs/dsp.c new file +12
-0+ +return ret; +} + +int avs_dsp_core_enable (struct avs_dev *adev,u32 core_mask) +{ +int ret; + + ret =avs_dsp_op (adev, power, core_mask, true); +if (ret) +return ret; +
sound/soc/intel/avs/dsp.c line 100
Quoted 10 lines
sound/soc/intel/avs/dsp.c new file +10
-0+ ret =avs_dsp_op (adev, reset, core_mask, false); +if (ret) +return ret; + +return avs_dsp_op (adev, stall, core_mask, false); +} + +int avs_dsp_core_disable (struct avs_dev *adev,u32 core_mask) +{ +/* Be permissive to allow for full DSP shutdown in disable path. */
that comment isn't very clear, what is permissive here?
sound/soc/intel/avs/dsp.c line 107
Quoted 7 lines
sound/soc/intel/avs/dsp.c new file +7
-0+avs_dsp_op (adev, stall, core_mask, true); +avs_dsp_op (adev, reset, core_mask, true); + +return avs_dsp_op (adev, power, core_mask, false); +} + +MODULE_LICENSE ("GPL v2" );
"GPL"
sound/soc/intel/avs/registers.h
Quoted 5 lines
sound/soc/intel/avs/registers.h new file +0
-0
avs_registers.h?
Quoted 23 lines
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 */
Cezary Rojewski
maintainerRe: [PATCH 03/17] ASoC: Intel: Introduce AVS driver
Quoted 8 lines · Pierre-Louis Bossart
sound/soc/intel/Kconfig config SND_SOC_INTEL_KEEMBAY · line 217
Quoted 6 lines
sound/soc/intel/Kconfig +6
-0+config SND_SOC_INTEL_AVS + tristate "Intel AVS driver" + depends on PCI && ACPI + depends on COMMON_CLK + depends on SND_SOC_INTEL_SKYLAKE_FAMILY=n + default ndefault is already n
Ack.
Quoted 4 lines
Quoted 4 lines
sound/soc/intel/Kconfig +4
-0+ select SND_SOC_ACPI + select SND_HDA_EXT_CORE + help + Enable support for Intel(R) cAVS 1.5 platforms with DSP
Quoted 8 lines
sound/soc/intel/Kconfig config SND_SOC_INTEL_KEEMBAY · line 224
Quoted 3 lines
sound/soc/intel/Kconfig +3
-0+ capabilities. This includes Skylake, Kabylake, Amberlake and + Apollolake. This option is mutually exclusive with SKYLAKE + driver.The feedback from the RFC was that this is not desirable if you want anyone to use this driver. The suggested solution was to use the
intel_dspcfglayer with e.g. dsp_driver=4 for avs. That would allow distributions to build this solution for early adopters.
Indeed, this description needs an update!
Quoted 7 lines
sound/soc/intel/avs/avs.h line 33
Quoted 5 lines
sound/soc/intel/avs/avs.h new file +5
-0+/* Platform specific descriptor */ +struct avs_spec { +const char *name; + +const struct avs_dsp_ops *const dops;
dsp_opswould be clearer. 'd' could refer to just about anything.
Ack.
Quoted 11 lines
sound/soc/intel/avs/avs.h line 41
Quoted 7 lines
sound/soc/intel/avs/avs.h new file +7
-0+const u32 core_init_mask;/* used during DSP boot */ +const u64 attributes;/* bitmask of AVS_PLATATTR_* */ +}; + +struct avs_dev { +struct hda_bus base; +struct device *dev;question: could you directly embed a struct device instead of a pointer, that would simplify the conversion through
dev_get_drvdatabelow.
Quoted 2 lines
Unless this *dev is related to the PCI device, in which case you could add a comment.
Pointer 'dev' translates to PCI device. No problem adding a comment.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + void __iomem *adsp_ba;I would guess 'ba' is base address? this could be added with comments or kernel-doc
Ack.
Quoted 10 lines
Quoted 10 lines
sound/soc/intel/avs/avs.h new file +10
-0+const struct avs_spec *spec; +}; + +/* from hda_bus to avs_dev */ +#define hda_to_avs (hda) container_of(hda, struct avs_dev, base) +/* from hdac_bus to avs_dev */ +#define hdac_to_avs (hdac) hda_to_avs(to_hda_bus(hdac)) +/* from device to avs_dev */ +#define to_avs_dev (dev) \ +({ \
Quoted 8 lines
sound/soc/intel/avs/avs.h line 58
Quoted 5 lines
sound/soc/intel/avs/avs.h new file +5
-0+struct hdac_bus *__bus =dev_get_drvdata (dev); \ +hdac_to_avs (__bus); \ +}) + +int avs_dsp_core_power (struct avs_dev *adev,u32 core_mask,bool active);does this mean 'active' affects all bits in the
core_mask? that doesn't seem very intuitive.
Can reword to 'power' to match its siblings.
Quoted 7 lines
sound/soc/intel/avs/avs.h line 62
Quoted 4 lines
sound/soc/intel/avs/avs.h new file +4
-0+int avs_dsp_core_reset (struct avs_dev *adev,u32 core_mask,bool reset); +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);it's a bit inconsistent to have enable/disable but a boolean for other functions?
While there may be a grain of inconsistency, the order of operations does not change for power/reset/stall regardless if the operation is "positive" or "negative". In _enable() and _disable() case, the order does matter with _disable() being the reverse of its counterpart. As functions calling either of these already know which one to use, we can avoid an if-statement by providing two separate handlers.
Quoted 6 lines
sound/soc/intel/avs/dsp.c line 12
Quoted 4 lines
sound/soc/intel/avs/dsp.c new file +4
-0+#include <linux/module.h> +#include <sound/hdaudio_ext.h> +#include "avs.h" +#include "registers.h" consider renaming as
avs_registers.h?
This header is for internal use only and is found within directory already named 'avs'. "avs.h" header covers a wider range of types and that's why its name is generic. All others are specific and thus are not prefixed with "avs_".
Quoted 7 lines
sound/soc/intel/avs/dsp.c line 15
Quoted 3 lines
sound/soc/intel/avs/dsp.c new file +3
-0+ +#define AVS_ADSPCS_INTERVAL_US 500 +#define AVS_ADSPCS_TIMEOUT_US 10000these values don't match with anything that was previously used for Intel platforms, where the values could be different depending on generations.
Im most cases I'm relying on closed-source equivalents.
Quoted 11 lines
bxt-sst.c:#define BXT_BASEFW_TIMEOUT 3000 bxt-sst.c:#define BXT_ROM_INIT_TIMEOUT 70 cnl-sst.c:#define CNL_INIT_TIMEOUT 300 cnl-sst.c:#define CNL_BASEFW_TIMEOUT 3000skl-sst-cldma.h:#define
SKL_WAIT_TIMEOUT500 /* 500
msec */
skl-sst-dsp.h:#defineBXT_INIT_TIMEOUT300
skl-sst-ipc.c:#defineIPC_TIMEOUT_MSECS3000
skl-sst.c:#defineSKL_BASEFW_TIMEOUT300
skl-sst.c:#defineSKL_INIT_TIMEOUT1000
Quoted 2 lines
please add a comment on how they were determined or align on hardware recommendations.
I'm unsure wheather the above is actually correct : )
e.g.: IPC timeout in skylake-drvier are inflated due to incorrect IPC protocol handling. Reply sent by firmware may be delayed due to unsoliciated notifications and the aforementioned driver did not take that into account extending IPC timeout to avoid the problems.
Quoted 14 lines
Quoted 14 lines
sound/soc/intel/avs/dsp.c new file +14
-0+int avs_dsp_core_power (struct avs_dev *adev,u32 core_mask,bool active) +{ +u32 value, mask, reg; +int ret; + + mask =AVS_ADSPCS_SPA_MASK (core_mask); + value = active ? mask :0 ; + +snd_hdac_adsp_updatel (adev,AVS_ADSP_REG_ADSPCS , mask, value); + + mask =AVS_ADSPCS_CPA_MASK (core_mask); + value = active ? mask :0 ; + + ret = snd_hdac_adsp_readl_poll(adev, AVS_ADSP_REG_ADSPCS,
Quoted 8 lines
sound/soc/intel/avs/dsp.c line 36
Quoted 6 lines
sound/soc/intel/avs/dsp.c new file +6
-0+ reg, (reg & mask) == value, +AVS_ADSPCS_INTERVAL_US , + AVS_ADSPCS_TIMEOUT_US); +if (ret) +dev_err (adev->dev,"core_mask %d %spower failed: %d\n" , + core_mask, active ?"" :"un" , ret);unpower is an odd wording.
Ack.
Quoted 15 lines
Quoted 15 lines
sound/soc/intel/avs/dsp.c new file +15
-0+ +return ret; +} + +int avs_dsp_core_reset (struct avs_dev *adev,u32 core_mask,bool reset) +{ +u32 value, mask, reg; +int ret; + + mask =AVS_ADSPCS_CRST_MASK (core_mask); + value = reset ? mask :0 ; + +snd_hdac_adsp_updatel (adev,AVS_ADSP_REG_ADSPCS , mask, value); + + ret = snd_hdac_adsp_readl_poll(adev, AVS_ADSP_REG_ADSPCS,
Quoted 8 lines
sound/soc/intel/avs/dsp.c line 57
Quoted 6 lines
sound/soc/intel/avs/dsp.c new file +6
-0+ reg, (reg & mask) == value, +AVS_ADSPCS_INTERVAL_US , + AVS_ADSPCS_TIMEOUT_US); +if (ret) +dev_err (adev->dev,"core_mask %d %sreset failed: %d\n" , + core_mask, reset ?"" :"un" , ret);unreset is even more odd. enter reset or exit reset.
Ack.
Quoted 16 lines
Quoted 16 lines
sound/soc/intel/avs/dsp.c new file +16
-0+ +return ret; +} + +int avs_dsp_core_stall (struct avs_dev *adev,u32 core_mask,bool stall) +{ +u32 value, mask, reg; +int ret; + + mask =AVS_ADSPCS_CSTALL_MASK (core_mask); + value = stall ? mask :0 ; + +snd_hdac_adsp_updatel (adev,AVS_ADSP_REG_ADSPCS , mask, value); + + ret = snd_hdac_adsp_readl_poll(adev, AVS_ADSP_REG_ADSPCS, + reg, (reg & mask) == value,
Quoted 8 lines
sound/soc/intel/avs/dsp.c line 78
Quoted 5 lines
sound/soc/intel/avs/dsp.c new file +5
-0+AVS_ADSPCS_INTERVAL_US , + AVS_ADSPCS_TIMEOUT_US); +if (ret) +dev_err (adev->dev,"core_mask %d %sstall failed: %d\n" , + core_mask, stall ?"" :"un" , ret);that was probably a copy/paste of stall/unstall in the two cases above...this one works, the two above not so much.
Yeah, that's a result of copy/paste. Agree, the wording can be improved.
Quoted 16 lines
Quoted 16 lines
sound/soc/intel/avs/dsp.c new file +16
-0+ +return ret; +} + +int avs_dsp_core_enable (struct avs_dev *adev,u32 core_mask) +{ +int ret; + + ret =avs_dsp_op (adev, power, core_mask, true); +if (ret) +return ret; + + ret =avs_dsp_op (adev, reset, core_mask, false); +if (ret) +return ret; +
Quoted 8 lines
sound/soc/intel/avs/dsp.c line 100
Quoted 6 lines
sound/soc/intel/avs/dsp.c new file +6
-0+return avs_dsp_op (adev, stall, core_mask, false); +} + +int avs_dsp_core_disable (struct avs_dev *adev,u32 core_mask) +{ +/* Be permissive to allow for full DSP shutdown in disable path. */ that comment isn't very clear, what is permissive here?
There is no error checking below.
Quoted 9 lines
sound/soc/intel/avs/dsp.c line 107
Quoted 7 lines
sound/soc/intel/avs/dsp.c new file +7
-0+avs_dsp_op (adev, stall, core_mask, true); +avs_dsp_op (adev, reset, core_mask, true); + +return avs_dsp_op (adev, power, core_mask, false); +} + +MODULE_LICENSE ("GPL v2" );"GPL"
Ack.
Re: [PATCH 03/17] ASoC: Intel: Introduce AVS driver
Quoted 14 lines
Quoted 6 lines
sound/soc/intel/avs/dsp.c line 100
Quoted 4 lines
sound/soc/intel/avs/dsp.c new file +3
-0+int avs_dsp_core_disable (struct avs_dev *adev,u32 core_mask) +{ + /* Be permissive to allow for full DSP shutdown in disable path. */that comment isn't very clear, what is permissive here?
There is no error checking below.
Quoted 4 lines
Quoted 4 lines
+
avs_dsp_op(adev, stall, core_mask, true); +avs_dsp_op(adev, reset, core_mask, true); +
+ returnavs_dsp_op(adev, power, core_mask, false);
consider adding a comment then, along the lines of 'we don't prevent suspend or shutdown with error checks' or something. 'permissive' was rather unclear to me.
Cezary Rojewski
maintainerRe: [PATCH 03/17] ASoC: Intel: Introduce AVS driver
Quoted 10 lines · Pierre-Louis Bossart
Quoted 10 lines
Quoted 6 lines
sound/soc/intel/avs/dsp.c line 100
Quoted 4 lines
sound/soc/intel/avs/dsp.c new file +3
-0+int avs_dsp_core_disable (struct avs_dev *adev,u32 core_mask) +{ + /* Be permissive to allow for full DSP shutdown in disable path. */that comment isn't very clear, what is permissive here?
There is no error checking below.
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
+
avs_dsp_op(adev, stall, core_mask, true); +avs_dsp_op(adev, reset, core_mask, true); +
+ returnavs_dsp_op(adev, power, core_mask, false);consider adding a comment then, along the lines of 'we don't prevent suspend or shutdown with error checks' or something. 'permissive' was rather unclear to me.
Rewording in v2 as suggested.
Cezary Rojewski
maintainerPATCH 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 boot process involving ROM-code requires specific handling with 'unstall' operations which are not required post-boot with normal IPC so separate set of send-message handlers is added for each of the usecases.
--- sound/soc/intel/avs/Makefile | 2 +- sound/soc/intel/avs/avs.h | 93 ++++++++ sound/soc/intel/avs/ipc.c | 404 ++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 170 ++++++++++++++ sound/soc/intel/avs/registers.h | 45 ++++ 5 files changed, 713 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 +93 -0
121 lines not on this page · raw message
sound/soc/intel/avs/ipc.c new file +404 -0
404 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 04/17] ASoC: Intel: avs: Inter process communication
Quoted 6 lines
The boot process involving ROM-code requires specific handling with 'unstall' operations which are not required post-boot with normal IPC so separate set of send-message handlers is added for each of the usecases.
consider splitting this long sentence and use simpler logic. It's quite unclear how you went from boot to use cases.
Quoted 1 line
+#include "
messages.h"
avs_messages.h?
sound/soc/intel/avs/avs.h struct avs_dsp_ops { · line 24
Quoted 10 lines
struct
avs_dev;sound/soc/intel/avs/avs.h +3
-0@@ -18,6 +19,9 @@ 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 );
kernel-doc or comments on what the last op might mean?
Quoted 9 lines
sound/soc/intel/avs/avs.h +2
-0};#define avs_dsp_op (adev, op, ...) \@@ -34,6 +38,18 @@ 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;
sound/soc/intel/avs/avs.h struct avs_spec { · line 52
Quoted 10 lines
sound/soc/intel/avs/avs.h +10
-0+ +const u32 rom_status; +const u32 hipc_req_offset; +const u32 hipc_req_ext_offset; +const u32 hipc_req_busy_mask; +const u32 hipc_ack_offset; +const u32 hipc_ack_done_mask; +const u32 hipc_rsp_offset; +const u32 hipc_rsp_busy_mask; +const u32 hipc_ctl_offset;
is this really desirable to describe the IPC registers, when we know there were 3 generations of Intel IPC registers. this is ipc-1.5 only.
Quoted 25 lines
sound/soc/intel/avs/avs.h +11
-0};struct avs_dev {@@ -42,6 +58,9 @@ struct avs_dev {void __iomem *adsp_ba;const struct avs_spec *spec; +struct avs_ipc *ipc; + +struct completion fw_ready; };/* from hda_bus to avs_dev */ @@ -61,4 +80,78 @@ 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; + };
sound/soc/intel/avs/avs.h int avs_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stall); · line 100
Quoted 10 lines
sound/soc/intel/avs/avs.h +10
-0+void *data; +size_t size; +}; + +struct avs_ipc { +struct device *dev; + +struct avs_ipc_msg rx; +u32 default_timeout_ms; +bool ready;
ready for what? This should be described or documented.
sound/soc/intel/avs/avs.h int avs_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stall); · line 104
Quoted 4 lines
sound/soc/intel/avs/avs.h +4
-0+ +bool rx_completed; +spinlock_t rx_lock; +struct mutex msg_mutex;
checkpatch would tell you to add a comment for spinlock and mutex. it's quite unclear what they might describe and if they are related.
Quoted 4 lines
sound/soc/intel/avs/avs.h +4
-0+struct completion done_completion; +struct completion busy_completion; +}; +
sound/soc/intel/avs/avs.h int avs_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stall); · line 118
Quoted 10 lines
sound/soc/intel/avs/avs.h +10
-0+#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. +*/ +#define AVS_IPC_RET (ret) \ + (((ret) <= 0) ? (ret) : -AVS_EIPC)
why not use -EREMOTEIO directly? -AVS_EIPC is not very useful for the reader.
And why -EREMOTEIO? I see that you used it in catpt but that's a very surprising code that no one else uses in sound/
Quoted 5 lines
sound/soc/intel/avs/avs.h +5
-0+ +static inline void avs_ipc_err (struct avs_dev *adev,struct avs_ipc_msg *tx, +const char *name,int error) +{ +/*
sound/soc/intel/avs/avs.h int avs_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stall); · line 133
Quoted 10 lines
sound/soc/intel/avs/avs.h +10
-0+* If IPC channel is blocked e.g.: due to ongoing recovery, +* -EPERM error code is expected and thus it's not an actual error. +*/ +if (error == -EPERM ) +dev_dbg (adev->dev,"%s 0x%08x 0x%08x failed: %d\n" , name, + tx->glb.primary, tx->glb.ext.val, error); +else +dev_err (adev->dev,"%s 0x%08x 0x%08x failed: %d\n" , name, + tx->glb.primary, tx->glb.ext.val, error); +}
we've used such functions before and the feedback, e.g. from GregKH and Mark Brown, has consistenly been that this is pushing the use of dev_dbg too far.
sound/soc/intel/avs/ipc.c line 15
Quoted 1 line
sound/soc/intel/avs/ipc.c new file +1
-0+#define AVS_IPC_TIMEOUT_MS 300
skl-sst-ipc.c:#define IPC_TIMEOUT_MSECS 3000
that's one order of magniture lower. please add a comment or align.
sound/soc/intel/avs/ipc.c line 25
Quoted 9 lines
sound/soc/intel/avs/ipc.c new file +9
-0+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; +if (!msg.status) +memcpy_fromio (ipc->rx.data,avs_uplink_addr (adev), + ipc->rx.size);
it wouldn't hurt to describe that the status determines whether additional information can be read from a mailbox.
sound/soc/intel/avs/ipc.c line 37
Quoted 12 lines
sound/soc/intel/avs/ipc.c new file +12
-0+} + +static void avs_dsp_process_notification (struct avs_dev *adev,u64 header) +{ +struct avs_notify_mod_data mod_data; +union avs_notify_msg msg =AVS_MSG (header); +size_t data_size =0 ; +void *data =NULL ; + +if (!adev->ipc->ready && msg.notify_msg_type !=AVS_NOTIFY_FW_READY ) { +dev_dbg (adev->dev,"FW not ready, skip notification: 0x%08x\n" , + msg.primary);
can this happen?
you should add a comment on what could be sent before the first 'real' sign of life from the DSP.
it's also unclear why this dev_dbg() when 'unknown notifications' below are handled as dev_warn()
Quoted 9 lines
sound/soc/intel/avs/ipc.c new file +9
-0+return ; + } + +/* Calculate notification payload size. */ +switch (msg.notify_msg_type) { +case AVS_NOTIFY_FW_READY : +break ; + +case AVS_NOTIFY_PHRASE_DETECTED :
sound/soc/intel/avs/ipc.c line 56
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+ 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 : +memcpy_fromio (&mod_data,avs_uplink_addr (adev),sizeof (mod_data)); + data_size =sizeof (mod_data) + mod_data.data_size;
it wouldn't hurt to describe the layout behing this formula.
Quoted 11 lines
sound/soc/intel/avs/ipc.c new file +11
-0+break ; + +default : +dev_warn (adev->dev,"unknown notification: 0x%08x\n" , + msg.primary); +break ; + } + +if (data_size) { + data =kmalloc (data_size,GFP_KERNEL ); +if (!data)
sound/soc/intel/avs/ipc.c line 77
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+return ; + +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;
avs->ipc->fw_ready?
Quoted 4 lines
sound/soc/intel/avs/ipc.c new file +4
-0+ complete(&adev->fw_ready);> + break; + +default : +break ;
sound/soc/intel/avs/ipc.c line 92
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+ } + +kfree (data); +} + +void avs_dsp_process_response (struct avs_dev *adev,u64 header) +{ +struct avs_ipc *ipc = adev->ipc; + +if (avs_msg_is_reply (header)) {
the naming is confusing, it's difficult for me to understand that a 'response' could not be a 'reply'. The two terms are synonyms, aren't they?
Quoted 33 lines
sound/soc/intel/avs/ipc.c new file +33
-0+/* 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; +const struct avs_spec *const spec = adev->spec; +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, spec->hipc_ack_offset); + hipc_rsp =snd_hdac_adsp_readl (adev, spec->hipc_rsp_offset); + +/* DSP acked host's request */ +if (hipc_ack & spec->hipc_ack_done_mask) { +/* mask done interrupt */ +snd_hdac_adsp_updatel (adev, spec->hipc_ctl_offset, +AVS_ADSP_HIPCCTL_DONE ,0 ); +
sound/soc/intel/avs/ipc.c line 135
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+complete (&ipc->done_completion); + +/* tell DSP it has our attention */ +snd_hdac_adsp_updatel (adev, spec->hipc_ack_offset, + spec->hipc_ack_done_mask, + spec->hipc_ack_done_mask); +/* unmask done interrupt */ +snd_hdac_adsp_updatel (adev, spec->hipc_ctl_offset, +AVS_ADSP_HIPCCTL_DONE , +AVS_ADSP_HIPCCTL_DONE );
does the order between the complete() and the next two register updates matter?
I would have updated the registers immediately and signal the completion later.
I am also not sure why it's necessary to mask the done interrupt then unmask it. There is nothing that seems to require this masking?
Or are you expecting the code blocked on wait_for_completion to be handled with interrupts masked, which could be quite racy?
Quoted 15 lines
sound/soc/intel/avs/ipc.c new file +14
-0+ ret =IRQ_HANDLED ; + } + +/* DSP sent new response to process */ +if (hipc_rsp & spec->hipc_rsp_busy_mask) { +/* mask busy interrupt */ +snd_hdac_adsp_updatel (adev, spec->hipc_ctl_offset, +AVS_ADSP_HIPCCTL_BUSY ,0 ); + + ret =IRQ_WAKE_THREAD ; + } + +return ret; +}
sound/soc/intel/avs/ipc.c line 197
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+static int avs_ipc_wait_busy_completion (struct avs_ipc *ipc,int timeout) +{ +int ret; + +again: + ret =wait_for_completion_timeout (&ipc->busy_completion, +msecs_to_jiffies (timeout)); +/* +* DSP could be unresponsive at this point e.g. manifested by +* EXCEPTION_CAUGHT notification. If so, no point in continuing.
EXCEPTION_CAUGHT doesn't seem to be described in this patchset, so not sure what this comment might mean.
sound/soc/intel/avs/ipc.c line 209
Quoted 12 lines
sound/soc/intel/avs/ipc.c new file +12
-0+*/ +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);
can you elaborate on why wait_for_completion() is not enough? I haven't seen the 'killable' attribute been used by anyone in sound/
sound/soc/intel/avs/ipc.c line 218
Quoted 9 lines
sound/soc/intel/avs/ipc.c new file +9
-0+ } + +/* Ongoing notification's bottom-half may cause early wakeup */ +spin_lock (&ipc->rx_lock); +if (!ipc->rx_completed) { +/* Reply delayed due to notification. */ +reinit_completion (&ipc->busy_completion); +spin_unlock (&ipc->rx_lock); + goto again;
shouldn't there be some counter to avoid potential infinite loops here?
Quoted 17 lines
sound/soc/intel/avs/ipc.c new file +16
-0+ } + +spin_unlock (&ipc->rx_lock); +return 0 ; +} +static int avs_dsp_do_send_msg (struct avs_dev *adev,struct avs_ipc_msg *request, +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); +
sound/soc/intel/avs/ipc.c line 269
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+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, rebooting dsp..\n" , + ret);
dev_crit() seems over the top if there is a recovery mechanism
Quoted 12 lines
sound/soc/intel/avs/ipc.c new file +12
-0+ +avs_ipc_block (ipc); + } + goto exit; + } + + ret = ipc->rx.rsp.status; +if (reply) { + reply->header = ipc->rx.header; +if (reply->data && ipc->rx.size) +memcpy (reply->data, ipc->rx.data, reply->size); + }
sound/soc/intel/avs/ipc.c line 291
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+ +exit: +mutex_unlock (&ipc->msg_mutex); +return ret; +} + +static int avs_dsp_send_msg_sequence (struct avs_dev *adev, +struct avs_ipc_msg *request, +struct avs_ipc_msg *reply,int timeout, +bool wake_d0i0,bool schedule_d0ix)
the last two arguments are not used. is this intentional?
Quoted 7 lines
sound/soc/intel/avs/ipc.c new file +7
-0+{ +return avs_dsp_do_send_msg (adev, request, reply, timeout); +} + +int avs_dsp_send_msg_timeout (struct avs_dev *adev,struct avs_ipc_msg *request, +struct avs_ipc_msg *reply,int timeout) +{
sound/soc/intel/avs/ipc.c line 308
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+return avs_dsp_send_msg_sequence (adev, request, reply, timeout, + false, false); +} + +int avs_dsp_send_msg (struct avs_dev *adev,struct avs_ipc_msg *request, +struct avs_ipc_msg *reply) +{ +return avs_dsp_send_msg_timeout (adev, request, reply, + adev->ipc->default_timeout_ms); +}
is there really a 4-level nesting in your helpers?
avs_dsp_send_msg
avs_dsp_send_msg_timeout
avs_dsp_send_msg_sequence
avs_dsp_do_send_msg
this seems complicated, no?
At the very least you should explain what a message and message sequence are, and why this is split this way.
sound/soc/intel/avs/ipc.c line 317
Quoted 9 lines
sound/soc/intel/avs/ipc.c new file +9
-0+ +int avs_dsp_send_pm_msg_timeout (struct avs_dev *adev, +struct avs_ipc_msg *request, +struct avs_ipc_msg *reply,int timeout, +bool wake_d0i0) +{ +return avs_dsp_send_msg_sequence (adev, request, reply, timeout, + wake_d0i0, false); +}
so the 'pm' means 'wake-d0i0'? that's far from intuitive.
avs_dsp_send_d0i0_msg_timeout() would better describe what you are trying to do.
In addition you need an explanation that d0i0 is a *firmware* concept without direct links to the *device* Dx status.
Quoted 15 lines
sound/soc/intel/avs/ipc.c new file +14
-0+int avs_dsp_send_pm_msg (struct avs_dev *adev, +struct avs_ipc_msg *request, +struct avs_ipc_msg *reply,bool wake_d0i0) +{ +return avs_dsp_send_pm_msg_timeout (adev, request, reply, + adev->ipc->default_timeout_ms, + wake_d0i0); +} +void avs_dsp_interrupt_control (struct avs_dev *adev,bool enable) +{ +const struct avs_spec *const spec = adev->spec; +u32 value; + + value = enable ?AVS_ADSP_ADSPIC_IPC :0 ;
sound/soc/intel/avs/ipc.c line 381
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+snd_hdac_adsp_updatel (adev,AVS_ADSP_REG_ADSPIC , +AVS_ADSP_ADSPIC_IPC , value); + + value = enable ?AVS_ADSP_HIPCCTL_DONE :0 ; +snd_hdac_adsp_updatel (adev, spec->hipc_ctl_offset, +AVS_ADSP_HIPCCTL_DONE , value); + + value = enable ?AVS_ADSP_HIPCCTL_BUSY :0 ; +snd_hdac_adsp_updatel (adev, spec->hipc_ctl_offset, +AVS_ADSP_HIPCCTL_BUSY , value);
does the order matter? please add a comment.
Cezary Rojewski
maintainerRe: [PATCH 04/17] ASoC: Intel: avs: Inter process communication
Quoted 6 lines · Pierre-Louis Bossart
Quoted 3 lines
The boot process involving ROM-code requires specific handling with 'unstall' operations which are not required post-boot with normal IPC so separate set of send-message handlers is added for each of the usecases.
consider splitting this long sentence and use simpler logic. It's quite unclear how you went from boot to use cases.
Agree, ack.
Quoted 3 lines
Quoted 1 line
+#include "
messages.h"
avs_messages.h?
Same as previously, this header is for internal use only and is found within directory already named 'avs'. "avs.h" header covers a wider range of types and that's why its name is generic. All others are specific and thus are not prefixed with "avs_".
Quoted 12 lines
sound/soc/intel/avs/avs.h struct avs_dsp_ops { · line 24
Quoted 10 lines
struct
avs_dev;sound/soc/intel/avs/avs.h +3
-0@@ -18,6 +19,9 @@ 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 );kernel-doc or comments on what the last op might mean?
Sure, will add a comment.
Quoted 14 lines
Quoted 14 lines
sound/soc/intel/avs/avs.h +7
-0};#define avs_dsp_op (adev, op, ...) \@@ -34,6 +38,18 @@ 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; +const u32 hipc_req_offset; +const u32 hipc_req_ext_offset; +const u32 hipc_req_busy_mask;
Quoted 8 lines
sound/soc/intel/avs/avs.h struct avs_spec { · line 52
Quoted 5 lines
sound/soc/intel/avs/avs.h +5
-0+const u32 hipc_ack_offset; +const u32 hipc_ack_done_mask; +const u32 hipc_rsp_offset; +const u32 hipc_rsp_busy_mask; +const u32 hipc_ctl_offset;is this really desirable to describe the IPC registers, when we know there were 3 generations of Intel IPC registers. this is ipc-1.5 only.
Indeed, this abstraction could be removed, ack.
Quoted 29 lines
Quoted 29 lines
sound/soc/intel/avs/avs.h +15
-0};struct avs_dev {@@ -42,6 +58,9 @@ struct avs_dev {void __iomem *adsp_ba;const struct avs_spec *spec; +struct avs_ipc *ipc; + +struct completion fw_ready; };/* from hda_bus to avs_dev */ @@ -61,4 +80,78 @@ 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; +}; +
Quoted 8 lines
sound/soc/intel/avs/avs.h int avs_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stall); · line 100
Quoted 6 lines
sound/soc/intel/avs/avs.h +6
-0+struct avs_ipc { +struct device *dev; + +struct avs_ipc_msg rx; +u32 default_timeout_ms; +bool ready;ready for what? This should be described or documented.
In the past this field was called "fw_ready" until we have decided to split struct avs_ipc from struct avs_dev. In my opinion "ipc->ready" looks very intuitive in the code, given that it translates to: inter process communication ready!
No problem with adding a comment though.
Quoted 7 lines
sound/soc/intel/avs/avs.h int avs_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stall); · line 104
Quoted 4 lines
sound/soc/intel/avs/avs.h +4
-0+ +bool rx_completed; +spinlock_t rx_lock; +struct mutex msg_mutex;checkpatch would tell you to add a comment for spinlock and mutex. it's quite unclear what they might describe and if they are related.
I'll add a kernel-doc for just like for the ->ready field.
Quoted 18 lines
Quoted 4 lines
sound/soc/intel/avs/avs.h +4
-0+struct completion done_completion; +struct completion busy_completion; +}; +sound/soc/intel/avs/avs.h int avs_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stall); · line 118
Quoted 10 lines
sound/soc/intel/avs/avs.h +10
-0+#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. +*/ +#define AVS_IPC_RET (ret) \ + (((ret) <= 0) ? (ret) : -AVS_EIPC)why not use
-EREMOTEIOdirectly? -AVS_EIPC is not very useful for the reader.
Quoted 2 lines
And why
-EREMOTEIO? I see that you used it in catpt but that's a very surprising code that no one else uses insound/
Well, the question: "Which kernel error should represent an error coming from remote process AKA audio firmware" needed an answer. EREMOTEIO fits the description and so it was chosen.
Quoted 11 lines
Quoted 11 lines
sound/soc/intel/avs/avs.h +11
-0+ +static inline void avs_ipc_err (struct avs_dev *adev,struct avs_ipc_msg *tx, +const char *name,int error) +{ +/* +* If IPC channel is blocked e.g.: due to ongoing recovery, +* -EPERM error code is expected and thus it's not an actual error. +*/ +if (error == -EPERM ) +dev_dbg (adev->dev,"%s 0x%08x 0x%08x failed: %d\n" , name, + tx->glb.primary, tx->glb.ext.val, error);
Quoted 8 lines
sound/soc/intel/avs/avs.h int avs_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stall); · line 133
Quoted 4 lines
sound/soc/intel/avs/avs.h +4
-0+else +dev_err (adev->dev,"%s 0x%08x 0x%08x failed: %d\n" , name, + tx->glb.primary, tx->glb.ext.val, error); +}we've used such functions before and the feedback, e.g. from GregKH and Mark Brown, has consistenly been that this is pushing the use of
dev_dbgtoo far.
In basically all cases the outcome is going to be dev_err(). dev_dbg() is here to help keep DSP-recovery scenario viewer-friendly when checking dmesg. Ideally, there should be no DSP-recoveries to begin with : )
Quoted 6 lines
sound/soc/intel/avs/ipc.c line 15
Quoted 1 line
sound/soc/intel/avs/ipc.c new file +1
-0+#define AVS_IPC_TIMEOUT_MS 300skl-sst-ipc.c:#define
IPC_TIMEOUT_MSECS3000that's one order of magniture lower. please add a comment or align.
Quoted 12 lines
sound/soc/intel/avs/ipc.c line 25
Quoted 9 lines
sound/soc/intel/avs/ipc.c new file +9
-0+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; +if (!msg.status) +memcpy_fromio (ipc->rx.data,avs_uplink_addr (adev), + ipc->rx.size);it wouldn't hurt to describe that the status determines whether additional information can be read from a mailbox.
Isn't that consisted with the behaviour of typical API function? Do not copy memory and return it to the caller if something went wrong along the way?
Quoted 15 lines
sound/soc/intel/avs/ipc.c line 37
Quoted 12 lines
sound/soc/intel/avs/ipc.c new file +12
-0+} + +static void avs_dsp_process_notification (struct avs_dev *adev,u64 header) +{ +struct avs_notify_mod_data mod_data; +union avs_notify_msg msg =AVS_MSG (header); +size_t data_size =0 ; +void *data =NULL ; + +if (!adev->ipc->ready && msg.notify_msg_type !=AVS_NOTIFY_FW_READY ) { +dev_dbg (adev->dev,"FW not ready, skip notification: 0x%08x\n" , + msg.primary);can this happen?
Quoted 5 lines
you should add a comment on what could be sent before the first 'real' sign of life from the DSP.
it's also unclear why this
dev_dbg()when 'unknown notifications' below are handled asdev_warn()
I would like to say: "no, this situation cannot happen" very much, but that's simply not true. Any notification could be sent prior to FW_READY as the internal queue may not always get flushed between the firmware restoring.
Ack on the s/warn/info/ part.
Quoted 13 lines
Quoted 13 lines
sound/soc/intel/avs/ipc.c new file +13
-0+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 :
Quoted 8 lines
sound/soc/intel/avs/ipc.c line 56
Quoted 6 lines
sound/soc/intel/avs/ipc.c new file +6
-0+ data_size =sizeof (struct avs_notify_res_data ); +break ; + +case AVS_NOTIFY_MODULE_EVENT : +memcpy_fromio (&mod_data,avs_uplink_addr (adev),sizeof (mod_data)); + data_size =sizeof (mod_data) + mod_data.data_size;it wouldn't hurt to describe the layout behing this formula.
The layout is kind of implied by the structure itself but a comment wouldn't hurt, agree.
Quoted 15 lines
Quoted 15 lines
sound/soc/intel/avs/ipc.c new file +15
-0+break ; + +default : +dev_warn (adev->dev,"unknown notification: 0x%08x\n" , + msg.primary); +break ; + } + +if (data_size) { + data =kmalloc (data_size,GFP_KERNEL ); +if (!data) +return ; + +memcpy_fromio (data,avs_uplink_addr (adev), data_size); + }
Quoted 8 lines
sound/soc/intel/avs/ipc.c line 77
Quoted 6 lines
sound/soc/intel/avs/ipc.c new file +6
-0+ +/* 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;
avs->ipc->fw_ready?
As I have explained earlier, this was the case until we have separated struct avs_ipc from struct avs_dev. I'll provide a kernel-doc instead.
Quoted 9 lines
Quoted 9 lines
sound/soc/intel/avs/ipc.c new file +9
-0+ complete(&adev->fw_ready);> + break; + +default : +break ; + } + +kfree (data); +} +
Quoted 8 lines
sound/soc/intel/avs/ipc.c line 92
Quoted 5 lines
sound/soc/intel/avs/ipc.c new file +5
-0+void avs_dsp_process_response (struct avs_dev *adev,u64 header) +{ +struct avs_ipc *ipc = adev->ipc; + +if (avs_msg_is_reply (header)) {the naming is confusing, it's difficult for me to understand that a 'response' could not be a 'reply'. The two terms are synonyms, aren't they?
Those two are not the same from the firmware's point of view and thus they are not the same here. Response is either a reply or a notification. Replies are solicited, a request has been sent beforehand. Notifications are unsolicited, you are not sure when exactly and if at all they arrive.
Just so I'm not called a heretic later: yes, from English dictionary point of view these two words are synonyms. In general, wording found in this drivers matches firmware equivalents wherever possible to allow developers to switch between these two worlds with minimal adaptation period possible.
Quoted 20 lines
Quoted 6 lines
sound/soc/intel/avs/ipc.c new file +6
-0+/* DSP acked host's request */ +if (hipc_ack & spec->hipc_ack_done_mask) { +/* mask done interrupt */ +snd_hdac_adsp_updatel (adev, spec->hipc_ctl_offset, +AVS_ADSP_HIPCCTL_DONE ,0 ); +sound/soc/intel/avs/ipc.c line 135
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+complete (&ipc->done_completion); + +/* tell DSP it has our attention */ +snd_hdac_adsp_updatel (adev, spec->hipc_ack_offset, + spec->hipc_ack_done_mask, + spec->hipc_ack_done_mask); +/* unmask done interrupt */ +snd_hdac_adsp_updatel (adev, spec->hipc_ctl_offset, +AVS_ADSP_HIPCCTL_DONE , +AVS_ADSP_HIPCCTL_DONE );does the order between the
complete()and the next two register updates matter?
Quoted 8 lines
I would have updated the registers immediately and signal the completion later.
I am also not sure why it's necessary to mask the done interrupt then unmask it. There is nothing that seems to require this masking?
Or are you expecting the code blocked on
wait_for_completionto be handled with interrupts masked, which could be quite racy?
Given how the things turned out in cAVS, some steps are not always required. Here, we have very strict implementation and so interrupt are masked.
I'm unsure if relocating complete() to the bottom would bring any consequences. And no, the code waiting_for_completion is not expecting interrupts to be masked as there is no reply for ROM messages.
Quoted 15 lines
Quoted 14 lines
sound/soc/intel/avs/ipc.c new file +14
-0+ ret =IRQ_HANDLED ; + } + +/* DSP sent new response to process */ +if (hipc_rsp & spec->hipc_rsp_busy_mask) { +/* mask busy interrupt */ +snd_hdac_adsp_updatel (adev, spec->hipc_ctl_offset, +AVS_ADSP_HIPCCTL_BUSY ,0 ); + + ret =IRQ_WAKE_THREAD ; + } + +return ret; +}
Quoted 13 lines
sound/soc/intel/avs/ipc.c line 197
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+static int avs_ipc_wait_busy_completion (struct avs_ipc *ipc,int timeout) +{ +int ret; + +again: + ret =wait_for_completion_timeout (&ipc->busy_completion, +msecs_to_jiffies (timeout)); +/* +* DSP could be unresponsive at this point e.g. manifested by +* EXCEPTION_CAUGHT notification. If so, no point in continuing.
EXCEPTION_CAUGHTdoesn't seem to be described in this patchset, so not sure what this comment might mean.
Comment describes the circumstances for the communication failures and arrival of EXCEPTION_CAUGHT notification is one of them.
Quoted 7 lines
Quoted 7 lines
sound/soc/intel/avs/ipc.c new file +7
-0+*/ +if (!ipc->ready) +return -EPERM ; + +if (!ret) { +if (!avs_ipc_is_busy (ipc)) +return -ETIMEDOUT ;
Quoted 8 lines
sound/soc/intel/avs/ipc.c line 209
Quoted 5 lines
sound/soc/intel/avs/ipc.c new file +5
-0+/* +* Firmware did its job, either notification or reply +* has been received - now wait until it's processed. +*/ +wait_for_completion_killable (&ipc->busy_completion);can you elaborate on why
wait_for_completion()is not enough? I haven't seen the 'killable' attribute been used by anyone insound/
This is connected to how firmware handles messaging i.e. via queue. you may get BUSY interrupt caused by a notification while waiting for the reply for your request. Being 'disturbed' by a notification does not mean firmware is dead, it's just busy and so we wait until previous response is processed entirely.
Quoted 11 lines
sound/soc/intel/avs/ipc.c line 218
Quoted 9 lines
sound/soc/intel/avs/ipc.c new file +9
-0+ } + +/* Ongoing notification's bottom-half may cause early wakeup */ +spin_lock (&ipc->rx_lock); +if (!ipc->rx_completed) { +/* Reply delayed due to notification. */ +reinit_completion (&ipc->busy_completion); +spin_unlock (&ipc->rx_lock); + goto again;shouldn't there be some counter to avoid potential infinite loops here?
This is not a bad idea although the counter is going to be high e.g.: 128. With DEBUG-level logs enabled you can get ton of messages before your reply gets finally sent.
Quoted 21 lines
Quoted 21 lines
sound/soc/intel/avs/ipc.c new file +20
-0+ } + +spin_unlock (&ipc->rx_lock); +return 0 ; +} +static int avs_dsp_do_send_msg (struct avs_dev *adev,struct avs_ipc_msg *request, +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);
Quoted 8 lines
sound/soc/intel/avs/ipc.c line 269
Quoted 6 lines
sound/soc/intel/avs/ipc.c new file +6
-0+ + ret =avs_ipc_wait_busy_completion (ipc, timeout); +if (ret) { +if (ret == -ETIMEDOUT ) { +dev_crit (adev->dev,"communication severed: %d, rebooting dsp..\n" , + ret);
dev_crit()seems over the top if there is a recovery mechanism
There is just one dev_crit() within entire driver and it's there for a reason - communication failure is critical and in practice, should never occur in any scenario on the production hardware.
Quoted 16 lines
Quoted 16 lines
sound/soc/intel/avs/ipc.c new file +16
-0+ +avs_ipc_block (ipc); + } + goto exit; + } + + ret = ipc->rx.rsp.status; +if (reply) { + reply->header = ipc->rx.header; +if (reply->data && ipc->rx.size) +memcpy (reply->data, ipc->rx.data, reply->size); + } + +exit: +mutex_unlock (&ipc->msg_mutex); +return ret;
Quoted 8 lines
sound/soc/intel/avs/ipc.c line 291
Quoted 6 lines
sound/soc/intel/avs/ipc.c new file +6
-0+} + +static int avs_dsp_send_msg_sequence (struct avs_dev *adev, +struct avs_ipc_msg *request, +struct avs_ipc_msg *reply,int timeout, +bool wake_d0i0,bool schedule_d0ix)the last two arguments are not used. is this intentional?
Used by the d0ix implementation that is not part of this part. Can relocate.
Quoted 25 lines
Quoted 7 lines
sound/soc/intel/avs/ipc.c new file +7
-0+{ +return avs_dsp_do_send_msg (adev, request, reply, timeout); +} + +int avs_dsp_send_msg_timeout (struct avs_dev *adev,struct avs_ipc_msg *request, +struct avs_ipc_msg *reply,int timeout) +{sound/soc/intel/avs/ipc.c line 308
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+return avs_dsp_send_msg_sequence (adev, request, reply, timeout, + false, false); +} + +int avs_dsp_send_msg (struct avs_dev *adev,struct avs_ipc_msg *request, +struct avs_ipc_msg *reply) +{ +return avs_dsp_send_msg_timeout (adev, request, reply, + adev->ipc->default_timeout_ms); +}is there really a 4-level nesting in your helpers?
avs_dsp_send_msg
avs_dsp_send_msg_timeout
avs_dsp_send_msg_sequence
avs_dsp_do_send_msg
Quoted 4 lines
this seems complicated, no?
At the very least you should explain what a message and message sequence are, and why this is split this way.
With d0ix handling added, it becomes clear why such separation exists. I left these parts here to reduce the delta in patches that update this code later on. Can simplify here and update the d0ix implementation accordingly.
Quoted 12 lines
sound/soc/intel/avs/ipc.c line 317
Quoted 9 lines
sound/soc/intel/avs/ipc.c new file +9
-0+ +int avs_dsp_send_pm_msg_timeout (struct avs_dev *adev, +struct avs_ipc_msg *request, +struct avs_ipc_msg *reply,int timeout, +bool wake_d0i0) +{ +return avs_dsp_send_msg_sequence (adev, request, reply, timeout, + wake_d0i0, false); +}so the 'pm' means 'wake-d0i0'? that's far from intuitive.
Quoted 5 lines
avs_dsp_send_d0i0_msg_timeout()would better describe what you are trying to do.In addition you need an explanation that d0i0 is a *firmware* concept without direct links to the *device* Dx status.
This goes for both, Dx and D0ix related messages.
Quoted 10 lines
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+void avs_dsp_interrupt_control (struct avs_dev *adev,bool enable) +{ +const struct avs_spec *const spec = adev->spec; +u32 value; + + value = enable ?AVS_ADSP_ADSPIC_IPC :0 ; +snd_hdac_adsp_updatel (adev,AVS_ADSP_REG_ADSPIC , +AVS_ADSP_ADSPIC_IPC , value); + + value = enable ?AVS_ADSP_HIPCCTL_DONE :0 ;
Quoted 8 lines
sound/soc/intel/avs/ipc.c line 381
Quoted 6 lines
sound/soc/intel/avs/ipc.c new file +6
-0+snd_hdac_adsp_updatel (adev, spec->hipc_ctl_offset, +AVS_ADSP_HIPCCTL_DONE , value); + + value = enable ?AVS_ADSP_HIPCCTL_BUSY :0 ; +snd_hdac_adsp_updatel (adev, spec->hipc_ctl_offset, +AVS_ADSP_HIPCCTL_BUSY , value);does the order matter? please add a comment.
interrupt_control() is only used during probing and teardown procedures so the order does not matter. You need all those bits up before firmware loading can even begin. And when you are done with firmware, you zero these out but and the order does not matter either as again, there's none to "talk" to.
Note: ADSPIC_IPC is higher in hierarchy than DONE and BUSY.
Re: [PATCH 04/17] ASoC: Intel: avs: Inter process communication
Quoted 22 lines
Quoted 12 lines
Quoted 12 lines
+static inline void avs_ipc_err(struct
avs_dev*adev, structavs_ipc_msg*tx,
+ const char *name, int error)
+{
+ /*
+ * If IPC channel is blocked e.g.: due to ongoing recovery, + *-EPERMerror code is expected and thus it's not an actual error. + */
+ if (error ==-EPERM)
+ dev_dbg(adev->dev, "%s 0x%08x 0x%08x failed: %d\n", name, +tx->glb.primary,tx->glb.ext.val, error);Quoted 8 lines
Quoted 4 lines
+ else
+ dev_err(adev->dev, "%s 0x%08x 0x%08x failed: %d\n", name, +tx->glb.primary,tx->glb.ext.val, error); +}we've used such functions before and the feedback, e.g. from GregKH and Mark Brown, has consistenly been that this is pushing the use of
dev_dbgtoo far.
Quoted 3 lines
In basically all cases the outcome is going to be
dev_err().dev_dbg()is here to help keep DSP-recovery scenario viewer-friendly when checking dmesg. Ideally, there should be no DSP-recoveries to begin with : )
I will refer you to this thread:
https://lore.kernel.org/alsa-devel/[email protected]/
Quoted 21 lines
Quoted 7 lines
Quoted 2 lines
+#define AVS_IPC_TIMEOUT_MS 300
skl-sst-ipc.c:#define IPC_TIMEOUT_MSECS 3000
that's one order of magniture lower. please add a comment or align.
Quoted 12 lines
sound/soc/intel/avs/ipc.c line 25
Quoted 9 lines
sound/soc/intel/avs/ipc.c new file +9
-0+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; + if (!msg.status) + memcpy_fromio(ipc->rx.data, avs_uplink_addr(adev), + ipc->rx.size);it wouldn't hurt to describe that the status determines whether additional information can be read from a mailbox.
Quoted 3 lines
Isn't that consisted with the behaviour of typical API function? Do not copy memory and return it to the caller if something went wrong along the way?
oh, I thought this was a case where the header contains all the information, and only in specific cases you need to read stuff from the mailbox.
You definitively need to add a comment on whether this is an error handling or a feature.
Quoted 11 lines
Quoted 9 lines
sound/soc/intel/avs/ipc.c line 92
Quoted 5 lines
sound/soc/intel/avs/ipc.c new file +5
-0+void avs_dsp_process_response (struct avs_dev *adev,u64 header) +{ + struct avs_ipc *ipc = adev->ipc; + + if (avs_msg_is_reply(header)) {the naming is confusing, it's difficult for me to understand that a 'response' could not be a 'reply'. The two terms are synonyms, aren't they?
Quoted 5 lines
Those two are not the same from the firmware's point of view and thus they are not the same here. Response is either a reply or a notification. Replies are solicited, a request has been sent beforehand. Notifications are unsolicited, you are not sure when exactly and if at all they arrive.
add a comment then.
Quoted 37 lines
Just so I'm not called a heretic later: yes, from English dictionary point of view these two words are synonyms. In general, wording found in this drivers matches firmware equivalents wherever possible to allow developers to switch between these two worlds with minimal adaptation period possible.
Quoted 20 lines
Quoted 6 lines
+ /* DSP acked host's request */
+ if (hipc_ack&spec->hipc_ack_done_mask) {
+ /* mask done interrupt */
+snd_hdac_adsp_updatel(adev, spec->hipc_ctl_offset, + AVS_ADSP_HIPCCTL_DONE, 0);sound/soc/intel/avs/ipc.c new file +1
-0+sound/soc/intel/avs/ipc.c line 135
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+ complete(&ipc->done_completion); + + /* tell DSP it has our attention */ + snd_hdac_adsp_updatel(adev, spec->hipc_ack_offset, + spec->hipc_ack_done_mask, + spec->hipc_ack_done_mask); + /* unmask done interrupt */ + snd_hdac_adsp_updatel(adev, spec->hipc_ctl_offset, + AVS_ADSP_HIPCCTL_DONE, + AVS_ADSP_HIPCCTL_DONE);does the order between the
complete()and the next two register updates matter?Quoted 8 lines
I would have updated the registers immediately and signal the completion later.
I am also not sure why it's necessary to mask the done interrupt then unmask it. There is nothing that seems to require this masking?
Or are you expecting the code blocked on
wait_for_completionto be handled with interrupts masked, which could be quite racy?
Quoted 7 lines
Given how the things turned out in cAVS, some steps are not always required. Here, we have very strict implementation and so interrupt are masked.
I'm unsure if relocating
complete()to the bottom would bring any consequences. And no, the codewaiting_for_completionis not expecting interrupts to be masked as there is no reply for ROM messages.
it would be just fine to add that the masking is added as an extra precaution, the order does not matter and the code executed after the complete() does not assume any masking.
Quoted 32 lines
Quoted 16 lines
Quoted 15 lines
+ ret =
IRQ_HANDLED;
+ }sound/soc/intel/avs/ipc.c new file +12
-0+ + /* DSP sent new response to process */ + if (hipc_rsp & spec->hipc_rsp_busy_mask) { + /* mask busy interrupt */ + snd_hdac_adsp_updatel(adev, spec->hipc_ctl_offset, + AVS_ADSP_HIPCCTL_BUSY, 0); + + ret = IRQ_WAKE_THREAD; + } + + return ret; +}Quoted 14 lines
sound/soc/intel/avs/ipc.c line 197
Quoted 11 lines
+static int
avs_ipc_wait_busy_completion(struct avs_ipc *ipc, int timeout)sound/soc/intel/avs/ipc.c new file +9
-0+{ + int ret; + +again: + ret = wait_for_completion_timeout(&ipc->busy_completion, + msecs_to_jiffies(timeout)); + /* +* DSP could be unresponsive at this point e.g. manifested by +* EXCEPTION_CAUGHT notification. If so, no point in continuing.
EXCEPTION_CAUGHTdoesn't seem to be described in this patchset, so not sure what this comment might mean.
Quoted 2 lines
Comment describes the circumstances for the communication failures and arrival of
EXCEPTION_CAUGHTnotification is one of them.
that detail is unnecessary for reviewers.
Quoted 18 lines
Quoted 14 lines
Quoted 13 lines
+ */
+ 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);Quoted 2 lines
can you elaborate on why
wait_for_completion()is not enough? I haven't seen the 'killable' attribute been used by anyone insound/
Quoted 5 lines
This is connected to how firmware handles messaging i.e. via queue. you may get BUSY interrupt caused by a notification while waiting for the reply for your request. Being 'disturbed' by a notification does not mean firmware is dead, it's just busy and so we wait until previous response is processed entirely.
this does not clarify why 'killable' is necessary?
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
+ }
+
+ /* Ongoing notification's bottom-half may cause early wakeup */ +spin_lock(&ipc->rx_lock);
+ if (!ipc->rx_completed) {
+ /* Reply delayed due to notification. */
+reinit_completion(&ipc->busy_completion);
+spin_unlock(&ipc->rx_lock);
+ goto again;
Quoted 6 lines
Quoted 1 line
shouldn't there be some counter to avoid potential infinite loops here?
This is not a bad idea although the counter is going to be high e.g.:
128. With DEBUG-level logs enabled you can get ton of messages before your reply gets finally sent.
dev_dbg() in interrupts is usually not very helpful. we're trying to move to traces instead.
Quoted 34 lines
Quoted 24 lines
Quoted 24 lines
+ }
sound/soc/intel/avs/ipc.c new file +5
-0+ + spin_unlock(&ipc->rx_lock); + return 0; +} +static int avs_dsp_do_send_msg(struct avs_dev *adev, struct
avs_ipc_msg*request,
+ structavs_ipc_msg*reply, int timeout)sound/soc/intel/avs/ipc.c new file +14
-0+{ + 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); +Quoted 8 lines
Quoted 6 lines
+ ret =
avs_ipc_wait_busy_completion(ipc, timeout); + if (ret) {
+ if (ret ==-ETIMEDOUT) {
+ dev_crit(adev->dev, "communication severed: %d, rebooting dsp..\n",
+ ret);
dev_crit()seems over the top if there is a recovery mechanism
Quoted 3 lines
There is just one
dev_crit()within entire driver and it's there for a reason - communication failure is critical and in practice, should never occur in any scenario on the production hardware.
git grep dev_crit shows mostly this being used for temperature and shorts in codec drivers. that seems more 'critical' than a communication failure that likely does not result in spontaneous combustion.
Cezary Rojewski
maintainerRe: [PATCH 04/17] ASoC: Intel: avs: Inter process communication
Quoted 22 lines · Pierre-Louis Bossart
Quoted 22 lines
Quoted 20 lines
Quoted 6 lines
+static inline void avs_ipc_err(struct
avs_dev*adev, structavs_ipc_msg*tx,
+ const char *name, int error)sound/soc/intel/avs/avs.h +2
-0+{ + /*sound/soc/intel/avs/avs.h int avs_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stall); · line 133
Quoted 10 lines
sound/soc/intel/avs/avs.h +10
-0+* If IPC channel is blocked e.g.: due to ongoing recovery, +* -EPERM error code is expected and thus it's not an actual error. +*/ + if (error == -EPERM) + dev_dbg(adev->dev, "%s 0x%08x 0x%08x failed: %d\n", name, + tx->glb.primary, tx->glb.ext.val, error); + else + dev_err(adev->dev, "%s 0x%08x 0x%08x failed: %d\n", name, + tx->glb.primary, tx->glb.ext.val, error); +}we've used such functions before and the feedback, e.g. from GregKH and Mark Brown, has consistenly been that this is pushing the use of
dev_dbgtoo far.
Quoted 7 lines
Quoted 3 lines
In basically all cases the outcome is going to be
dev_err().dev_dbg()is here to help keep DSP-recovery scenario viewer-friendly when checking dmesg. Ideally, there should be no DSP-recoveries to begin with : )I will refer you to this thread:
That's an interesting lecture, thanks for sharing the link.
Most of the time, we do want to dump an dev_err() if function fails for non-trivial reason. During recovery scenario though, we force-disconnect all the streams before attempting DSP reboot. That results in "wall of red" i.e. error messages. Since we know that all these errors are caused by the disconnection of the streams, there is no real value for flagging them as errors. It's debug-friendly (for a developer addressing the possible problem) to have only important marked as errors in dmesg.
Also, avs_ipc_err() has a very specific purpose and is used only by IPC handlers and nowhere else.
Quoted 25 lines
Quoted 21 lines
Quoted 7 lines
Quoted 2 lines
+#define AVS_IPC_TIMEOUT_MS 300
skl-sst-ipc.c:#define IPC_TIMEOUT_MSECS 3000
that's one order of magniture lower. please add a comment or align.
Quoted 12 lines
sound/soc/intel/avs/ipc.c line 25
Quoted 9 lines
sound/soc/intel/avs/ipc.c new file +9
-0+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; + if (!msg.status) + memcpy_fromio(ipc->rx.data, avs_uplink_addr(adev), + ipc->rx.size);it wouldn't hurt to describe that the status determines whether additional information can be read from a mailbox.
Quoted 3 lines
Isn't that consisted with the behaviour of typical API function? Do not copy memory and return it to the caller if something went wrong along the way?
Quoted 6 lines
oh, I thought this was a case where the header contains all the information, and only in specific cases you need to read stuff from the mailbox.
You definitively need to add a comment on whether this is an error handling or a feature.
Ack.
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
sound/soc/intel/avs/ipc.c line 92
Quoted 5 lines
sound/soc/intel/avs/ipc.c new file +5
-0+void avs_dsp_process_response (struct avs_dev *adev,u64 header) +{ + struct avs_ipc *ipc = adev->ipc; + + if (avs_msg_is_reply(header)) {the naming is confusing, it's difficult for me to understand that a 'response' could not be a 'reply'. The two terms are synonyms, aren't they?
Quoted 7 lines
Quoted 5 lines
Those two are not the same from the firmware's point of view and thus they are not the same here. Response is either a reply or a notification. Replies are solicited, a request has been sent beforehand. Notifications are unsolicited, you are not sure when exactly and if at all they arrive.
add a comment then.
Ack.
Quoted 41 lines
Quoted 41 lines
Just so I'm not called a heretic later: yes, from English dictionary point of view these two words are synonyms. In general, wording found in this drivers matches firmware equivalents wherever possible to allow developers to switch between these two worlds with minimal adaptation period possible.
Quoted 20 lines
Quoted 6 lines
+ /* DSP acked host's request */
+ if (hipc_ack&spec->hipc_ack_done_mask) {
+ /* mask done interrupt */
+snd_hdac_adsp_updatel(adev, spec->hipc_ctl_offset, + AVS_ADSP_HIPCCTL_DONE, 0);sound/soc/intel/avs/ipc.c new file +1
-0+sound/soc/intel/avs/ipc.c line 135
Quoted 10 lines
sound/soc/intel/avs/ipc.c new file +10
-0+ complete(&ipc->done_completion); + + /* tell DSP it has our attention */ + snd_hdac_adsp_updatel(adev, spec->hipc_ack_offset, + spec->hipc_ack_done_mask, + spec->hipc_ack_done_mask); + /* unmask done interrupt */ + snd_hdac_adsp_updatel(adev, spec->hipc_ctl_offset, + AVS_ADSP_HIPCCTL_DONE, + AVS_ADSP_HIPCCTL_DONE);does the order between the
complete()and the next two register updates matter?Quoted 8 lines
I would have updated the registers immediately and signal the completion later.
I am also not sure why it's necessary to mask the done interrupt then unmask it. There is nothing that seems to require this masking?
Or are you expecting the code blocked on
wait_for_completionto be handled with interrupts masked, which could be quite racy?Given how the things turned out in cAVS, some steps are not always required. Here, we have very strict implementation and so interrupt are masked.
Quoted 7 lines
Quoted 3 lines
I'm unsure if relocating
complete()to the bottom would bring any consequences. And no, the codewaiting_for_completionis not expecting interrupts to be masked as there is no reply for ROM messages.it would be just fine to add that the masking is added as an extra precaution, the order does not matter and the code executed after the
complete()does not assume any masking.
Ack.
Quoted 32 lines
Quoted 32 lines
Quoted 30 lines
Quoted 18 lines
+ ret =
IRQ_HANDLED;
+ }sound/soc/intel/avs/ipc.c new file +13
-0+ + /* DSP sent new response to process */ + if (hipc_rsp & spec->hipc_rsp_busy_mask) { + /* mask busy interrupt */ + snd_hdac_adsp_updatel(adev, spec->hipc_ctl_offset, + AVS_ADSP_HIPCCTL_BUSY, 0); + + ret = IRQ_WAKE_THREAD; + } + + return ret; +} +static int avs_ipc_wait_busy_completion(struct avs_ipc *ipc, inttimeout)
sound/soc/intel/avs/ipc.c line 197
Quoted 9 lines
sound/soc/intel/avs/ipc.c new file +9
-0+{ + int ret; + +again: + ret = wait_for_completion_timeout(&ipc->busy_completion, + msecs_to_jiffies(timeout)); + /* +* DSP could be unresponsive at this point e.g. manifested by +* EXCEPTION_CAUGHT notification. If so, no point in continuing.
EXCEPTION_CAUGHTdoesn't seem to be described in this patchset, so not sure what this comment might mean.
Quoted 4 lines
Quoted 2 lines
Comment describes the circumstances for the communication failures and arrival of
EXCEPTION_CAUGHTnotification is one of them.that detail is unnecessary for reviewers.
Ack.
Quoted 18 lines
Quoted 18 lines
Quoted 16 lines
Quoted 13 lines
+ */
+ 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);can you elaborate on why
wait_for_completion()is not enough? I haven't seen the 'killable' attribute been used by anyone insound/
Quoted 7 lines
Quoted 5 lines
This is connected to how firmware handles messaging i.e. via queue. you may get BUSY interrupt caused by a notification while waiting for the reply for your request. Being 'disturbed' by a notification does not mean firmware is dead, it's just busy and so we wait until previous response is processed entirely.
this does not clarify why 'killable' is necessary?
Usage of 'killable' variant adheres to its documentation. Sys calls can terminate the waiter. More user friendly.
Quoted 14 lines
Quoted 14 lines
Quoted 12 lines
Quoted 10 lines
+ }
+
+ /* Ongoing notification's bottom-half may cause early wakeup */ +spin_lock(&ipc->rx_lock);
+ if (!ipc->rx_completed) {
+ /* Reply delayed due to notification. */
+reinit_completion(&ipc->busy_completion);
+spin_unlock(&ipc->rx_lock);
+ goto again;shouldn't there be some counter to avoid potential infinite loops here?
Quoted 6 lines
Quoted 3 lines
This is not a bad idea although the counter is going to be high e.g.:
128. With DEBUG-level logs enabled you can get ton of messages before your reply gets finally sent.
dev_dbg()in interrupts is usually not very helpful. we're trying to move to traces instead.
Wasn't precise enough, I appologize for that. By "DEBUG-level logs" I meant firmware logging, not dev_dbg() on kernel side. When enabled with log level DEBUG, you will get at least 1 message per sys tick, resulting in gigabyte logs in no time.
Quoted 34 lines
Quoted 34 lines
Quoted 32 lines
Quoted 28 lines
+ }
sound/soc/intel/avs/ipc.c new file +5
-0+ + spin_unlock(&ipc->rx_lock); + return 0; +} +static int avs_dsp_do_send_msg(struct avs_dev *adev, struct
avs_ipc_msg*request,
+ structavs_ipc_msg*reply, int timeout)sound/soc/intel/avs/ipc.c new file +18
-0+{ + 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 2 lines
rebooting dsp..\n",
+ ret);
dev_crit()seems over the top if there is a recovery mechanism
Quoted 7 lines
Quoted 3 lines
There is just one
dev_crit()within entire driver and it's there for a reason - communication failure is critical and in practice, should never occur in any scenario on the production hardware.git grep
dev_critshows mostly this being used for temperature and shorts in codec drivers. that seems more 'critical' than a communication failure that likely does not result in spontaneous combustion.
Few dev_crit()s can also be found in other components as well.
Without audio and graphics there is no real 'user experience'. Abrupt closure of communication between DSP firmware and kernel driver can, and usually is a consequence of either an undefined behaviour (in process running on DSP) or hardware issue. While I can't spare the details here for obvious reasons, not all situations can even be recovered with reboot. That usually depends in which power wells registers reside. The 100% confirmed solution for laptops is removing battery for a second or day to force G3.
Considering this, I believe having a single dev_crit() here is justified.
Regards,
Czarek
Cezary Rojewski
maintainerRe: [PATCH 04/17] ASoC: Intel: avs: Inter process communication
Quoted 3 lines · Cezary Rojewski
Few dev_crit()s can also be found in other components as well.
Without audio and graphics there is no real 'user experience'. Abrupt closure of communication between DSP firmware and kernel driver can, and usually is a consequence of either an undefined behaviour (in process running on DSP) or hardware issue. While I can't spare the details here for obvious reasons, not all situations can even be recovered with reboot. That usually depends in which power wells registers reside. The 100% confirmed solution for laptops is removing battery for a second or day to force G3.
s/second or day/second or two/
Hope people are not panicking after that typo =)
Quoted 1 line
Considering this, I believe having a single
dev_crit()here is justified.
Cezary Rojewski
maintainerPATCH 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
Re: [PATCH 05/17] ASoC: Intel: avs: Add code loading requests
Quoted 2 lines
+#define
AVS_CL_TIMEOUT_MS5000
it's not clear where this comes from, and it's also unclear why both types of code loading would have the same timeout when the hardware is so fundamentally different.
Quoted 31 lines
sound/soc/intel/avs/messages.c new file +31
-0+ +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 ); +struct avs_ipc_msg request; +int ret; + + msg.load_multi_mods.mod_cnt = num_mod_ids; + request.header = msg.val; + request.data = mod_ids; + request.size =sizeof (*mod_ids) * num_mod_ids; + + ret =avs_dsp_send_msg_timeout (adev, &request,NULL ,AVS_CL_TIMEOUT_MS ); +if (ret) +avs_ipc_err (adev, &request,"load multiple modules" , ret); + +return ret; +} + +int avs_ipc_unload_modules (struct avs_dev *adev,u16 *mod_ids,u32 num_mod_ids) +{ +union avs_global_msg msg =AVS_GLOBAL_REQUEST (UNLOAD_MULTIPLE_MODULES ); +struct avs_ipc_msg request; +int ret; + + msg.load_multi_mods.mod_cnt = num_mod_ids; + request.header = msg.val; + request.data = mod_ids; + request.size =sizeof (*mod_ids) * num_mod_ids; + + ret =avs_dsp_send_msg_timeout (adev, &request,NULL ,AVS_CL_TIMEOUT_MS );
sound/soc/intel/avs/messages.c line 53
Quoted 10 lines
sound/soc/intel/avs/messages.c new file +10
-0+if (ret) +avs_ipc_err (adev, &request,"unload multiple modules" , ret); + +return ret; +} + +int avs_ipc_load_library (struct avs_dev *adev,u32 dma_id,u32 lib_id) +{ +union avs_global_msg msg =AVS_GLOBAL_REQUEST (LOAD_LIBRARY ); +struct avs_ipc_msg request = {0 };
I've asked this before and I don't recall by this case requires an initialization to zero?
Quoted 11 lines
sound/soc/intel/avs/messages.c new file +11
-0+int ret; + + msg.load_lib.dma_id = dma_id; + msg.load_lib.lib_id = lib_id; + request.header = msg.val; + + ret =avs_dsp_send_msg_timeout (adev, &request,NULL ,AVS_CL_TIMEOUT_MS ); +if (ret) +avs_ipc_err (adev, &request,"load library" , ret); + +return ret;
Cezary Rojewski
maintainerRe: [PATCH 05/17] ASoC: Intel: avs: Add code loading requests
Quoted 6 lines · Pierre-Louis Bossart
Quoted 2 lines
+#define
AVS_CL_TIMEOUT_MS5000it's not clear where this comes from, and it's also unclear why both types of code loading would have the same timeout when the hardware is so fundamentally different.
I can re-check but most often than not, I'm basing these on proven, working, close-source equivalent.
Quoted 7 lines
sound/soc/intel/avs/messages.c line 53
Quoted 4 lines
sound/soc/intel/avs/messages.c new file +4
-0+int avs_ipc_load_library (struct avs_dev *adev,u32 dma_id,u32 lib_id) +{ +union avs_global_msg msg =AVS_GLOBAL_REQUEST (LOAD_LIBRARY ); +struct avs_ipc_msg request = {0 };I've asked this before and I don't recall by this case requires an initialization to zero?
Fields 'data' and 'size' are also part of struct avs_ipc_msg. We zero them out here as there is no payload to be sent for LOAD_LIBRARY IPC.
Quoted 12 lines
Quoted 11 lines
sound/soc/intel/avs/messages.c new file +11
-0+int ret; + + msg.load_lib.dma_id = dma_id; + msg.load_lib.lib_id = lib_id; + request.header = msg.val; + + ret =avs_dsp_send_msg_timeout (adev, &request,NULL ,AVS_CL_TIMEOUT_MS ); +if (ret) +avs_ipc_err (adev, &request,"load library" , ret); + +return ret;
Cezary Rojewski
maintainerPATCH 6/17 ASoC: Intel: avs: Add pipeline management requests
In reply to Cezary RojewskiA 'Pipeline' represents both a container of module instances, and a scheduling entity. Multiple pipelines can be bound together to create an audio graph. The Pipeline state machine is entirely controlled by IPCs (creation, deletion and state changes).
--- sound/soc/intel/avs/messages.c | 76 ++++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 56 +++++++++++++++++++++++++ 2 files changed, 132 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 +56 -0
84 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH 06/17] ASoC: Intel: avs: Add pipeline management requests
Quoted 4 lines · Cezary Rojewski
A 'Pipeline' represents both a container of module instances, and a scheduling entity. Multiple pipelines can be bound together to create an audio graph. The Pipeline state machine is entirely controlled by IPCs (creation, deletion and state changes).
How are the module instances connected within a pipeline? You've said too much or too little here.
sound/soc/intel/avs/messages.c int avs_ipc_load_library(struct avs_dev *adev, u32 dma_id, u32 lib_id) · line 77
Quoted 11 lines
sound/soc/intel/avs/messages.c +11
-0+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;
you may want to describe what the concepts of 'priority', 'lp' and 'attributes' are and which entity defines the values (topology?)
Quoted 10 lines
sound/soc/intel/avs/messages.h +9
-0+ 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; +}
sound/soc/intel/avs/messages.h union avs_global_msg { · line 86
Quoted 10 lines
sound/soc/intel/avs/messages.h +9
-0u32 val; +/* pipeline management */ +struct { +u32 lp:1 ; +u32 rsvd:3 ; +u32 attributes:16 ; + } create_ppl; +struct { +u32 multi_ppl:1 ; +u32 sync_stop_start:1 ;
these two are not described at all?
Quoted 6 lines
sound/soc/intel/avs/messages.h +2
-0+ } set_ppl_state; } ext; }; } __packed; +/* Pipeline management messages */
sound/soc/intel/avs/messages.h int avs_ipc_load_modules(struct avs_dev *adev, u16 *mod_ids, u32 num_mod_ids); · line 237
Quoted 10 lines
sound/soc/intel/avs/messages.h +10
-0+enum avs_pipeline_state { +AVS_PPL_STATE_INVALID , +AVS_PPL_STATE_UNINITIALIZED , +AVS_PPL_STATE_RESET , +AVS_PPL_STATE_PAUSED , +AVS_PPL_STATE_RUNNING , +AVS_PPL_STATE_EOS , +AVS_PPL_STATE_ERROR_STOP , +AVS_PPL_STATE_SAVED , +AVS_PPL_STATE_RESTORED ,
can you describe that the last two enums might entail and what the purpose might be?
I can see how the firmware state could be saved in IMR for faster suspend/resume, but save/restore at the pipeline level doesn't seem to have an obvious match for an ASoC driver?
Cezary Rojewski
maintainerRe: [PATCH 06/17] ASoC: Intel: avs: Add pipeline management requests
Quoted 8 lines · Pierre-Louis Bossart
Quoted 4 lines · Cezary Rojewski
A 'Pipeline' represents both a container of module instances, and a scheduling entity. Multiple pipelines can be bound together to create an audio graph. The Pipeline state machine is entirely controlled by IPCs (creation, deletion and state changes).
How are the module instances connected within a pipeline? You've said too much or too little here.
Hmm.. I doubt commit messages is the place to bring up entire FW specification. A high level description is provided to give a maintainer/reviewer idea of what the pipeline is. Perhaps s/module instances/modules/ would suffice.
Quoted 6 lines
Quoted 6 lines
sound/soc/intel/avs/messages.c +6
-0+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;
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 77
Quoted 5 lines
sound/soc/intel/avs/messages.c +5
-0+ + 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;you may want to describe what the concepts of 'priority', 'lp' and 'attributes' are and which entity defines the values (topology?)
These fields match firmware equivalents 1:1 and are part of pipeline descriptor excepted by firmware when initializing a pipeline. Handlers found in messages.c are responsible for one and only one task only: sending a concrete message. Part of the driver that implements PCM operations (not part of this series) cares about the topology (where these values actually come from) and invokes the necessary IPCs.
Quoted 10 lines
Quoted 9 lines
sound/soc/intel/avs/messages.c +9
-0+ 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; +}
Quoted 12 lines
sound/soc/intel/avs/messages.h union avs_global_msg { · line 86
Quoted 10 lines
u32 val;
sound/soc/intel/avs/messages.h +9
-0+/* pipeline management */ +struct { +u32 lp:1 ; +u32 rsvd:3 ; +u32 attributes:16 ; + } create_ppl; +struct { +u32 multi_ppl:1 ; +u32 sync_stop_start:1 ;these two are not described at all?
Ack.
Quoted 20 lines
Quoted 6 lines
sound/soc/intel/avs/messages.h +2
-0+ } set_ppl_state; } ext; }; } __packed; +/* Pipeline management messages */ sound/soc/intel/avs/messages.h int avs_ipc_load_modules(struct avs_dev *adev, u16 *mod_ids, u32 num_mod_ids); · line 237
Quoted 10 lines
sound/soc/intel/avs/messages.h +10
-0+enum avs_pipeline_state { +AVS_PPL_STATE_INVALID , +AVS_PPL_STATE_UNINITIALIZED , +AVS_PPL_STATE_RESET , +AVS_PPL_STATE_PAUSED , +AVS_PPL_STATE_RUNNING , +AVS_PPL_STATE_EOS , +AVS_PPL_STATE_ERROR_STOP , +AVS_PPL_STATE_SAVED , +AVS_PPL_STATE_RESTORED ,can you describe that the last two enums might entail and what the purpose might be?
Quoted 3 lines
I can see how the firmware state could be saved in IMR for faster suspend/resume, but save/restore at the pipeline level doesn't seem to have an obvious match for an ASoC driver?
The enum lists all available pipeline states. We're planning to move these to uapi later on to allow apps to monitor running pipelines states real-time.
Re: [PATCH 06/17] ASoC: Intel: avs: Add pipeline management requests
Quoted 7 lines · Cezary Rojewski
Quoted 6 lines · Pierre-Louis Bossart
Quoted 4 lines · Cezary Rojewski
A 'Pipeline' represents both a container of module instances, and a scheduling entity. Multiple pipelines can be bound together to create an audio graph. The Pipeline state machine is entirely controlled by IPCs (creation, deletion and state changes).
Quoted 8 lines
Quoted 2 lines
How are the module instances connected within a pipeline? You've said too much or too little here.
Hmm.. I doubt commit messages is the place to bring up entire FW specification. A high level description is provided to give a maintainer/reviewer idea of what the pipeline is. Perhaps s/module instances/modules/ would suffice.
No one is asking you to to provide the entire specification, just enough for reviewers with no access to that spec to understand what your intent is.
Quoted 18 lines
Quoted 16 lines
sound/soc/intel/avs/messages.c int avs_ipc_load_library(struct avs_dev *adev, u32 dma_id, u32 lib_id) · line 77
Quoted 13 lines
+int avs_ipc_create_pipeline(struct
avs_dev*adev, u16req_size, u8 priority,
+ u8instance_id, bool lp, u16 attributes)sound/soc/intel/avs/messages.c +9
-0+{ + 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;you may want to describe what the concepts of 'priority', 'lp' and 'attributes' are and which entity defines the values (topology?)
Quoted 6 lines
These fields match firmware equivalents 1:1 and are part of pipeline descriptor excepted by firmware when initializing a pipeline. Handlers found in
messages.care responsible for one and only one task only:
sending a concrete message. Part of the driver that implements PCM operations (not part of this series) cares about the topology (where these values actually come from) and invokes the necessary IPCs.
add a comment then that the driver is just relaying information found in the topology to the firmware.
Quoted 15 lines
Quoted 15 lines
sound/soc/intel/avs/messages.h int avs_ipc_load_modules(struct avs_dev *adev, u16 *mod_ids, u32 num_mod_ids); · line 237
Quoted 11 lines
sound/soc/intel/avs/messages.h +11
-0+/* Pipeline management messages */ +enum avs_pipeline_state { + AVS_PPL_STATE_INVALID, + AVS_PPL_STATE_UNINITIALIZED, + AVS_PPL_STATE_RESET, + AVS_PPL_STATE_PAUSED, + AVS_PPL_STATE_RUNNING, + AVS_PPL_STATE_EOS, + AVS_PPL_STATE_ERROR_STOP, + AVS_PPL_STATE_SAVED, + AVS_PPL_STATE_RESTORED,can you describe that the last two enums might entail and what the purpose might be?
Quoted 8 lines
Quoted 3 lines
I can see how the firmware state could be saved in IMR for faster suspend/resume, but save/restore at the pipeline level doesn't seem to have an obvious match for an ASoC driver?
The enum lists all available pipeline states. We're planning to move these to uapi later on to allow apps to monitor running pipelines states real-time.
That doesn't answer to my question. You are not using the last two in the rest of this patchset, so why create doubt in the confused brain on the reviewer?
Cezary Rojewski
maintainerRe: [PATCH 06/17] ASoC: Intel: avs: Add pipeline management requests
Quoted 12 lines · Pierre-Louis Bossart
Quoted 11 lines · Cezary Rojewski
Quoted 8 lines · Pierre-Louis Bossart
Quoted 4 lines · Cezary Rojewski
A 'Pipeline' represents both a container of module instances, and a scheduling entity. Multiple pipelines can be bound together to create an audio graph. The Pipeline state machine is entirely controlled by IPCs (creation, deletion and state changes).
How are the module instances connected within a pipeline? You've said too much or too little here.
Quoted 7 lines
Quoted 4 lines
Hmm.. I doubt commit messages is the place to bring up entire FW specification. A high level description is provided to give a maintainer/reviewer idea of what the pipeline is. Perhaps s/module instances/modules/ would suffice.
No one is asking you to to provide the entire specification, just enough for reviewers with no access to that spec to understand what your intent is.
Removed the confusing part of the message in v2.
Quoted 25 lines
Quoted 18 lines
Quoted 16 lines
sound/soc/intel/avs/messages.c int avs_ipc_load_library(struct avs_dev *adev, u32 dma_id, u32 lib_id) · line 77
Quoted 13 lines
+int avs_ipc_create_pipeline(struct
avs_dev*adev, u16req_size, u8 priority,
+ u8instance_id, bool lp, u16 attributes)sound/soc/intel/avs/messages.c +9
-0+{ + 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;you may want to describe what the concepts of 'priority', 'lp' and 'attributes' are and which entity defines the values (topology?)
Quoted 6 lines
These fields match firmware equivalents 1:1 and are part of pipeline descriptor excepted by firmware when initializing a pipeline. Handlers found in
messages.care responsible for one and only one task only:
sending a concrete message. Part of the driver that implements PCM operations (not part of this series) cares about the topology (where these values actually come from) and invokes the necessary IPCs.
Quoted 2 lines
add a comment then that the driver is just relaying information found in the topology to the firmware.
Ack.
Quoted 20 lines
Quoted 20 lines
Quoted 18 lines
sound/soc/intel/avs/messages.h int avs_ipc_load_modules(struct avs_dev *adev, u16 *mod_ids, u32 num_mod_ids); · line 237
Quoted 11 lines
sound/soc/intel/avs/messages.h +11
-0+/* Pipeline management messages */ +enum avs_pipeline_state { + AVS_PPL_STATE_INVALID, + AVS_PPL_STATE_UNINITIALIZED, + AVS_PPL_STATE_RESET, + AVS_PPL_STATE_PAUSED, + AVS_PPL_STATE_RUNNING, + AVS_PPL_STATE_EOS, + AVS_PPL_STATE_ERROR_STOP, + AVS_PPL_STATE_SAVED, + AVS_PPL_STATE_RESTORED,can you describe that the last two enums might entail and what the purpose might be?
I can see how the firmware state could be saved in IMR for faster suspend/resume, but save/restore at the pipeline level doesn't seem to have an obvious match for an ASoC driver?
Quoted 7 lines
Quoted 3 lines
The enum lists all available pipeline states. We're planning to move these to uapi later on to allow apps to monitor running pipelines states real-time.
That doesn't answer to my question. You are not using the last two in the rest of this patchset, so why create doubt in the confused brain on the reviewer?
Removed both in v2, thanks.
Cezary Rojewski
maintainerPATCH 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 | 208 +++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 53 +++++++++ 3 files changed, 268 insertions(+), 1 deletion(-)
sound/soc/intel/avs/ipc.c +7 -1
@@ -20,9 +20,15 @@ static void avs_dsp_receive_rx(struct avs_dev *adev, u64 header)union avs_reply_msg msg =AVS_MSG (header); ipc->rx.header = header; -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 +208 -0
217 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 07/17] ASoC: Intel: avs: Add module management requests
Review
Quoted 4 lines
(quoted diff) +2
-0+int avs_ipc_init_instance(struct avs_dev *adev, u16 module_id, u8 instance_id, + u8 ppl_id, u8 core_id, u8 domain,
you should explain the relationship between ppl_id and core_id. It seems that in the same pipeline different modules instances can be pegged to different cores, which isn't very intuitive given the previous explanation that a pipeline is a scheduling unit.
The domain as a u8 is not very clear either, I was under the impression there were only two domains (LL and EDF)?
Quoted 8 lines
sound/soc/intel/avs/messages.c +8
-0+ 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;
sound/soc/intel/avs/messages.c int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, · line 163
Quoted 10 lines
sound/soc/intel/avs/messages.c +10
-0+/* 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;
isn't there a need to check if the module can be initialized? there's got to be some dependency on pipeline state?
Quoted 13 lines
sound/soc/intel/avs/messages.c +13
-0+ + ret =avs_dsp_send_msg (adev, &request,NULL ); +if (ret) +avs_ipc_err (adev, &request,"init instance" , ret); + +return ret; +} + +int avs_ipc_delete_instance (struct avs_dev *adev,u16 module_id,u8 instance_id) +{ +union avs_module_msg msg =AVS_MODULE_REQUEST (DELETE_INSTANCE ); +struct avs_ipc_msg request = {0 }; +int ret;
sound/soc/intel/avs/messages.c int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, · line 186
Quoted 10 lines
sound/soc/intel/avs/messages.c +10
-0+ + 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;
same here, can this be used in any pipeline state?
sound/soc/intel/avs/messages.c int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, · line 191
Quoted 5 lines
sound/soc/intel/avs/messages.c +5
-0+} + +int avs_ipc_bind (struct avs_dev *adev,u16 module_id,u8 instance_id, +u16 dst_module_id,u8 dst_instance_id, +u8 dst_queue,u8 src_queue)
what does a queue represent?
Quoted 31 lines
sound/soc/intel/avs/messages.c +31
-0+{ +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; +} + +int avs_ipc_unbind (struct avs_dev *adev,u16 module_id,u8 instance_id, +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;
sound/soc/intel/avs/messages.c int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, · line 232
Quoted 10 lines
sound/soc/intel/avs/messages.c +10
-0+ 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;
can this be merged with the bind in a helper, the code looks quasi-identical with just two lines different.
Quoted 1 line
+}
Cezary Rojewski
maintainerRe: [PATCH 07/17] ASoC: Intel: avs: Add module management requests
Quoted 10 lines · Pierre-Louis Bossart
Review
Quoted 2 lines
(quoted diff) +2
-0+int avs_ipc_init_instance(struct avs_dev *adev, u16 module_id, u8 instance_id, + u8 ppl_id, u8 core_id, u8 domain,you should explain the relationship between
ppl_idandcore_id. It seems that in the same pipeline different modules instances can be pegged to different cores, which isn't very intuitive given the previous explanation that a pipeline is a scheduling unit.The domain as a u8 is not very clear either, I was under the impression there were only two domains (LL and EDF)?
Hmm.. such explanations are supposed to be part of HW or FW specifications. I don't believe kernel is a place for that. Fields found here are needed to provide all the necessary information firmware expects when requesting INIT_INSTANCE. What's possible and how's everything handled internally is for firmware to decide and explain. There are no if-statements in the driver's code that force ppl_id/core_id relation so I don't see why reader would get an impression there is some dependency. What's in the topology gets routed to firmware with help of above function.
Just to confirm: yes, you can have multiple cores engaged in servicing modules found in single pipelines.
In regard to field name/sizes: again, these match firmware equivalents 1:1 so it's easy to switch back and forth.
Quoted 13 lines
Quoted 13 lines
sound/soc/intel/avs/messages.c +13
-0+ 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;
Quoted 8 lines
sound/soc/intel/avs/messages.c int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, · line 163
Quoted 5 lines
sound/soc/intel/avs/messages.c +5
-0+ msg.ext.init_instance.proc_domain = domain; + + request.header = msg.val; + request.data = param; + request.size = param_size;isn't there a need to check if the module can be initialized? there's got to be some dependency on pipeline state?
IPC handlers found in message.c have one and only one purpose only: send a message. Firmware will return an error if arguments passed are invalid.
Also, note that ALSA/ASoC already have a working state machine for streaming. There is no reason to re-implement it here.
Quoted 17 lines
Quoted 17 lines
sound/soc/intel/avs/messages.c +17
-0+ + ret =avs_dsp_send_msg (adev, &request,NULL ); +if (ret) +avs_ipc_err (adev, &request,"init instance" , ret); + +return ret; +} + +int avs_ipc_delete_instance (struct avs_dev *adev,u16 module_id,u8 instance_id) +{ +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;
Quoted 8 lines
sound/soc/intel/avs/messages.c int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, · line 186
Quoted 6 lines
sound/soc/intel/avs/messages.c +6
-0+ + ret =avs_dsp_send_msg (adev, &request,NULL ); +if (ret) +avs_ipc_err (adev, &request,"delete instance" , ret); + +return ret;same here, can this be used in any pipeline state?
Ditto.
Quoted 7 lines
sound/soc/intel/avs/messages.c int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, · line 191
Quoted 5 lines
sound/soc/intel/avs/messages.c +5
-0+} + +int avs_ipc_bind (struct avs_dev *adev,u16 module_id,u8 instance_id, +u16 dst_module_id,u8 dst_instance_id, +u8 dst_queue,u8 src_queue)what does a queue represent?
In firmware's nomenclature pin/index/queue are synonyms when speaking about module instances.
Quoted 36 lines
Quoted 36 lines
sound/soc/intel/avs/messages.c +36
-0+{ +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; +} + +int avs_ipc_unbind (struct avs_dev *adev,u16 module_id,u8 instance_id, +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; +
Quoted 8 lines
sound/soc/intel/avs/messages.c int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, · line 232
Quoted 5 lines
sound/soc/intel/avs/messages.c +5
-0+ ret =avs_dsp_send_msg (adev, &request,NULL ); +if (ret) +avs_ipc_err (adev, &request,"unbind modules" , ret); + +return ret;can this be merged with the bind in a helper, the code looks quasi-identical with just two lines different.
We had these two coupled together in the past just like you mention. Lately we'd decided that having two if-statements (one for message type and the other for error message) just two reduce file by just few lines is not worth it. So we chose the readability over small file-size gain.
Re: [PATCH 07/17] ASoC: Intel: avs: Add module management requests
Quoted 10 lines · Cezary Rojewski
Quoted 9 lines · Pierre-Louis Bossart
Quoted 3 lines
+int avs_ipc_init_instance(struct
avs_dev*adev, u16module_id, u8instance_id,
+ u8ppl_id, u8core_id, u8 domain,you should explain the relationship between
ppl_idandcore_id. It seems that in the same pipeline different modules instances can be pegged to different cores, which isn't very intuitive given the previous explanation that a pipeline is a scheduling unit.
Quoted 6 lines
Quoted 2 lines
The domain as a u8 is not very clear either, I was under the impression there were only two domains (LL and EDF)?
Hmm.. such explanations are supposed to be part of HW or FW specifications. I don't believe kernel is a place for that. Fields found
how do you expect people with no access to those specs to understand this code then?
You have to describe the concepts in vague-enough terms that someone familiar with DSPs can understand.
Quoted 8 lines
here are needed to provide all the necessary information firmware expects when requesting
INIT_INSTANCE. What's possible and how's everything handled internally is for firmware to decide and explain. There are no if-statements in the driver's code that force ppl_id/core_id relation so I don't see why reader would get an impression there is some dependency. What's in the topology gets routed to firmware with help of above function.
Quoted 5 lines
Just to confirm: yes, you can have multiple cores engaged in servicing modules found in single pipelines.
In regard to field name/sizes: again, these match firmware equivalents 1:1 so it's easy to switch back and forth.
add comments then.
Quoted 24 lines
Quoted 14 lines
Quoted 14 lines
+ void *param, u32
param_size)sound/soc/intel/avs/messages.c +12
-0+{ + 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;Quoted 8 lines
Quoted 5 lines
+ msg.ext.init_instance.proc_domain = domain;
+
+ request.header = msg.val;
+ request.data = param;
+ request.size =param_size;isn't there a need to check if the module can be initialized? there's got to be some dependency on pipeline state?
Quoted 5 lines
IPC handlers found in
message.chave one and only one purpose only: send a message. Firmware will return an error if arguments passed are invalid.Also, note that ALSA/ASoC already have a working state machine for streaming. There is no reason to re-implement it here.
add a comment then.
Quoted 40 lines
Quoted 19 lines
Quoted 19 lines
sound/soc/intel/avs/messages.c +9
-0+ + ret = avs_dsp_send_msg(adev, &request, NULL); + if (ret) + avs_ipc_err(adev, &request, "init instance", ret); + + return ret; +} + +int avs_ipc_delete_instance(struct avs_dev *adev, u16 module_id, u8
instance_id)sound/soc/intel/avs/messages.c +8
-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;Quoted 8 lines
sound/soc/intel/avs/messages.c int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, · line 186
Quoted 6 lines
sound/soc/intel/avs/messages.c +6
-0+ + ret = avs_dsp_send_msg(adev, &request, NULL); + if (ret) + avs_ipc_err(adev, &request, "delete instance", ret); + + return ret;same here, can this be used in any pipeline state?
Ditto.
Quoted 7 lines
sound/soc/intel/avs/messages.c int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, · line 191
Quoted 5 lines
sound/soc/intel/avs/messages.c +5
-0+} + +int avs_ipc_bind (struct avs_dev *adev,u16 module_id,u8 instance_id, + u16 dst_module_id, u8 dst_instance_id, + u8 dst_queue, u8 src_queue)what does a queue represent?
Quoted 2 lines
In firmware's nomenclature pin/index/queue are synonyms when speaking about module instances.
well, that's worthy of a comment...
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
sound/soc/intel/avs/messages.c +19
-0+{ + 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; +}
Cezary Rojewski
maintainerRe: [PATCH 07/17] ASoC: Intel: avs: Add module management requests
Quoted 15 lines · Pierre-Louis Bossart
Quoted 14 lines · Cezary Rojewski
Quoted 11 lines · Pierre-Louis Bossart
Quoted 3 lines
+int avs_ipc_init_instance(struct
avs_dev*adev, u16module_id, u8instance_id,
+ u8ppl_id, u8core_id, u8 domain,you should explain the relationship between
ppl_idandcore_id. It seems that in the same pipeline different modules instances can be pegged to different cores, which isn't very intuitive given the previous explanation that a pipeline is a scheduling unit.The domain as a u8 is not very clear either, I was under the impression there were only two domains (LL and EDF)?
Quoted 8 lines
Quoted 2 lines
Hmm.. such explanations are supposed to be part of HW or FW specifications. I don't believe kernel is a place for that. Fields found
how do you expect people with no access to those specs to understand this code then?
You have to describe the concepts in vague-enough terms that someone familiar with DSPs can understand.
Added kernel-doc for said function to address this.
Quoted 8 lines
Quoted 8 lines
here are needed to provide all the necessary information firmware expects when requesting
INIT_INSTANCE. What's possible and how's everything handled internally is for firmware to decide and explain. There are no if-statements in the driver's code that force ppl_id/core_id relation so I don't see why reader would get an impression there is some dependency. What's in the topology gets routed to firmware with help of above function.
Quoted 7 lines
Quoted 5 lines
Just to confirm: yes, you can have multiple cores engaged in servicing modules found in single pipelines.
In regard to field name/sizes: again, these match firmware equivalents 1:1 so it's easy to switch back and forth.
add comments then.
Ack.
Quoted 24 lines
Quoted 24 lines
Quoted 22 lines
Quoted 9 lines
+ void *param, u32
param_size)sound/soc/intel/avs/messages.c +7
-0+{ + 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;sound/soc/intel/avs/messages.c int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, · line 163
Quoted 10 lines
sound/soc/intel/avs/messages.c +10
-0+ /* 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;isn't there a need to check if the module can be initialized? there's got to be some dependency on pipeline state?
Quoted 7 lines
Quoted 5 lines
IPC handlers found in
message.chave one and only one purpose only: send a message. Firmware will return an error if arguments passed are invalid.Also, note that ALSA/ASoC already have a working state machine for streaming. There is no reason to re-implement it here.
add a comment then.
Ack.
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
sound/soc/intel/avs/messages.c int avs_ipc_get_pipeline_state(struct avs_dev *adev, u8 instance_id, · line 191
Quoted 5 lines
sound/soc/intel/avs/messages.c +5
-0+} + +int avs_ipc_bind (struct avs_dev *adev,u16 module_id,u8 instance_id, + u16 dst_module_id, u8 dst_instance_id, + u8 dst_queue, u8 src_queue)what does a queue represent?
Quoted 4 lines
Quoted 2 lines
In firmware's nomenclature pin/index/queue are synonyms when speaking about module instances.
well, that's worthy of a comment...
Ack.
Cezary Rojewski
maintainerPATCH 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 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 | 43 ++++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 16 +++++++++++++ 2 files changed, 59 insertions(+)
sound/soc/intel/avs/messages.c +43 -0
@@ -347,3 +347,46 @@ 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); + +/* +* SET_D0 is sent for non-main cores only while SET_D3 is used to +* suspend for all of them. Both cases prevent any D0I3 transitions. +*/ + ret =avs_dsp_send_pm_msg (adev, &request,NULL , true); +if (ret) +avs_ipc_err (adev, &request,"set dx" , ret); + +return ret; +} + +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; + +/* Wake & streaming for < cAVS 2.0 */ + msg.ext.set_d0ix.wake = enable_pg; + msg.ext.set_d0ix.streaming = streaming; + + request.header = msg.val; + + ret =avs_dsp_send_pm_msg (adev, &request,NULL , false); +if (ret) +avs_ipc_err (adev, &request,"set d0ix" , ret); + +return ret; +}
sound/soc/intel/avs/messages.h +16 -0
@@ -101,6 +101,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, };
@@ -137,6 +139,11 @@ union avs_module_msg { u32 dst_queue:3; u32 src_queue:3; } bind_unbind; +struct { +/* cAVS < 2.0 */ +u32 wake:1 ; +u32 streaming:1 ; + } set_d0ix; } ext; }; } __packed;
@@ -298,4 +305,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; +u32 dx_mask; +} __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 08/17] ASoC: Intel: avs: Add power management requests
Quoted 4 lines
Audio DSP supports low power states i.e.: transitions between D0 and D3 and D0-substates in form of D0i3. That process is a combination of core
D0i0 and D0i3?
Quoted 24 lines
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 | 43 ++++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 16 +++++++++++++ 2 files changed, 59 insertions(+)sound/soc/intel/avs/messages.c +7
-0@@ -347,3 +347,46 @@ 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;
sound/soc/intel/avs/messages.c int avs_ipc_get_large_config(struct avs_dev *adev, u16 module_id, u8 instance_id · line 366
Quoted 10 lines
sound/soc/intel/avs/messages.c +10
-0+ + dx.core_mask = core_mask; + dx.dx_mask = powerup ? core_mask :0 ; + request.header = msg.val; + request.data = &dx; + request.size =sizeof (dx); + +/* +* SET_D0 is sent for non-main cores only while SET_D3 is used to +* suspend for all of them. Both cases prevent any D0I3 transitions.
The asymmetry in the comment isn't clear. Did you mean that the main code is in D0 when powered?
Quoted 5 lines
sound/soc/intel/avs/messages.c +5
-0+*/ + ret =avs_dsp_send_pm_msg (adev, &request,NULL , true); +if (ret) +avs_ipc_err (adev, &request,"set dx" , ret); +
sound/soc/intel/avs/messages.c int avs_ipc_get_large_config(struct avs_dev *adev, u16 module_id, u8 instance_id · line 381
Quoted 10 lines
sound/soc/intel/avs/messages.c +10
-0+return ret; +} + +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; + +/* Wake & streaming for < cAVS 2.0 */
I don't how anyone outside of Intel could understand this comment. Consider explaining what the two terms refer to.
sound/soc/intel/avs/messages.c int avs_ipc_get_large_config(struct avs_dev *adev, u16 module_id, u8 instance_id · line 382
Quoted 1 line
sound/soc/intel/avs/messages.c +1
-0+ msg.ext.set_d0ix.wake = enable_pg;
simplify the argument? Not sure anyone could understand what wake and enable_pg mean.
int avs_ipc_set_d0ix(struct avs_dev *adev, bool wake, bool streaming)
Quoted 24 lines
sound/soc/intel/avs/messages.c +10
-0+ msg.ext.set_d0ix.streaming = streaming; + + request.header = msg.val; + + ret =avs_dsp_send_pm_msg (adev, &request,NULL , false); +if (ret) +avs_ipc_err (adev, &request,"set d0ix" , ret); + +return ret; +}sound/soc/intel/avs/messages.h +2
-0@@ -101,6 +101,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, };
sound/soc/intel/avs/messages.h union avs_module_msg { · line 145
Quoted 7 lines
sound/soc/intel/avs/messages.h +4
-0@@ -137,6 +139,11 @@ union avs_module_msg { u32 dst_queue:3; u32 src_queue:3; } bind_unbind; +struct { +/* cAVS < 2.0 */ +u32 wake:1 ; +u32 streaming:1 ;
you probably want to explain how a 'streaming' flag is set at the module level? One would think all modules connected in a pipeline would need to use the same flag value.
sound/soc/intel/avs/messages.h int avs_ipc_get_large_config(struct avs_dev *adev, u16 module_id, u8 instance_id · line 311
Quoted 12 lines
sound/soc/intel/avs/messages.h +5
-0+ } set_d0ix; } ext; }; } __packed;@@ -298,4 +305,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; +u32 dx_mask;
what is the convention for D0 and D3 in the mask ? which one is 0 or 1?
Is this also handled in a hierarchical way where only the bits set in core_mask matter?
Quoted 6 lines
sound/soc/intel/avs/messages.h +5
-0+} __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 */
Cezary Rojewski
maintainerRe: [PATCH 08/17] ASoC: Intel: avs: Add power management requests
Quoted 4 lines · Pierre-Louis Bossart
Quoted 2 lines
Audio DSP supports low power states i.e.: transitions between D0 and D3 and D0-substates in form of D0i3. That process is a combination of core
D0i0 and D0i3?
Ack.
Quoted 29 lines
Quoted 29 lines
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 | 43 ++++++++++++++++++++++++++++++++++ sound/soc/intel/avs/messages.h | 16 +++++++++++++ 2 files changed, 59 insertions(+)sound/soc/intel/avs/messages.c +12
-0@@ -347,3 +347,46 @@ 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;
Quoted 8 lines
sound/soc/intel/avs/messages.c int avs_ipc_get_large_config(struct avs_dev *adev, u16 module_id, u8 instance_id · line 366
Quoted 5 lines
sound/soc/intel/avs/messages.c +5
-0+ request.size =sizeof (dx); + +/* +* SET_D0 is sent for non-main cores only while SET_D3 is used to +* suspend for all of them. Both cases prevent any D0I3 transitions. The asymmetry in the comment isn't clear. Did you mean that the main code is in D0 when powered?
Yes. There is no putting MAIN_CORE to D0 as we must be in D0 to begin with, if we're thinking about sending an IPC to the base firmware.
Quoted 10 lines
Quoted 10 lines
sound/soc/intel/avs/messages.c +10
-0+*/ + ret =avs_dsp_send_pm_msg (adev, &request,NULL , true); +if (ret) +avs_ipc_err (adev, &request,"set dx" , ret); + +return ret; +} + +int avs_ipc_set_d0ix (struct avs_dev *adev,bool enable_pg,bool streaming) +{
Quoted 8 lines
sound/soc/intel/avs/messages.c int avs_ipc_get_large_config(struct avs_dev *adev, u16 module_id, u8 instance_id · line 381
Quoted 5 lines
sound/soc/intel/avs/messages.c +5
-0+union avs_module_msg msg =AVS_MODULE_REQUEST (SET_D0IX ); +struct avs_ipc_msg request = {0 }; +int ret; + +/* Wake & streaming for < cAVS 2.0 */ I don't how anyone outside of Intel could understand this comment. Consider explaining what the two terms refer to.
Sure, will improve the wording.
Quoted 4 lines
sound/soc/intel/avs/messages.c int avs_ipc_get_large_config(struct avs_dev *adev, u16 module_id, u8 instance_id · line 382
Quoted 1 line
sound/soc/intel/avs/messages.c +1
-0+ msg.ext.set_d0ix.wake = enable_pg;simplify the argument? Not sure anyone could understand what wake and
enable_pgmean.
Well, CG and PG are popular shortcuts among Intel audio team and stand for clock gating and power gating respectively. 'wake' is firmware specific. I can provide a comment, but not all question are going to be answered by it. Firmware specification is the place to find the answer for most of these.
Quoted 25 lines
int
avs_ipc_set_d0ix(struct avs_dev *adev, bool wake, bool streaming)Quoted 23 lines
sound/soc/intel/avs/messages.c +10
-0+ msg.ext.set_d0ix.streaming = streaming; + + request.header = msg.val; + + ret =avs_dsp_send_pm_msg (adev, &request,NULL , false); +if (ret) +avs_ipc_err (adev, &request,"set d0ix" , ret); + +return ret; +}sound/soc/intel/avs/messages.h +2
-0@@ -101,6 +101,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, };
Quoted 12 lines
sound/soc/intel/avs/messages.h union avs_module_msg { · line 145
Quoted 8 lines
sound/soc/intel/avs/messages.h +4
-0@@ -137,6 +139,11 @@ union avs_module_msg { u32 dst_queue:3; u32 src_queue:3; } bind_unbind; +struct { +/* cAVS < 2.0 */ +u32 wake:1 ; +u32 streaming:1 ;you probably want to explain how a 'streaming' flag is set at the module level? One would think all modules connected in a pipeline would need to use the same flag value.
Some of the fields are confusing and I agree, but driver has to adhere to FW expectations if it wants to be a working one. I would like to avoid judging the firmware architecture here, regardless of how confusing we think it is.
'wake' and 'streaming' fields are part of SET_D0ix message is which part of MODULE-type message interface. Base firmware is, from architecture point of view, a module of type=0 (module_id) and instance id=0 (instance_id).
Quoted 15 lines
sound/soc/intel/avs/messages.h int avs_ipc_get_large_config(struct avs_dev *adev, u16 module_id, u8 instance_id · line 311
Quoted 12 lines
sound/soc/intel/avs/messages.h +5
-0+ } set_d0ix; } ext; }; } __packed;@@ -298,4 +305,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; +u32 dx_mask;what is the convention for D0 and D3 in the mask ? which one is 0 or 1?
Quoted 2 lines
Is this also handled in a hierarchical way where only the bits set in
core_maskmatter?
Can provide a short kernel-doc for these two, sure.
Re: [PATCH 08/17] ASoC: Intel: avs: Add power management requests
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
+ msg.ext.set_d0ix.wake =
enable_pg;simplify the argument? Not sure anyone could understand what wake and
enable_pgmean.
Quoted 5 lines
Well, CG and PG are popular shortcuts among Intel audio team and stand for clock gating and power gating respectively. 'wake' is firmware specific. I can provide a comment, but not all question are going to be answered by it. Firmware specification is the place to find the answer for most of these.
again please do not assume that anyone reviewing this code has access to the firmware specification.
Quoted 40 lines
Quoted 30 lines
int
avs_ipc_set_d0ix(struct avs_dev *adev, bool wake, bool streaming)Quoted 27 lines
+ msg.ext.set_d0ix.streaming = streaming;
sound/soc/intel/avs/messages.c +9
-0+ + request.header = msg.val; + + ret = avs_dsp_send_pm_msg(adev, &request, NULL, false); + if (ret) + avs_ipc_err(adev, &request, "set d0ix", ret); + + return ret; +}sound/soc/intel/avs/messages.h +2
-0@@ -101,6 +101,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, }; @@ -137,6 +139,11 @@ union avs_module_msg {u32 dst_queue:3;
u32 src_queue:3;
}bind_unbind;Quoted 8 lines
Quoted 4 lines
+ struct {
+ /* cAVS < 2.0 */
+ u32 wake:1;
+ u32 streaming:1;you probably want to explain how a 'streaming' flag is set at the module level? One would think all modules connected in a pipeline would need to use the same flag value.
Quoted 4 lines
Some of the fields are confusing and I agree, but driver has to adhere to FW expectations if it wants to be a working one. I would like to avoid judging the firmware architecture here, regardless of how confusing we think it is.
it's not about judging, just explaining what is expected on the firmware side and what the driver needs to do.
Quoted 26 lines
'wake' and 'streaming' fields are part of
SET_D0ixmessage is which part of MODULE-type message interface. Base firmware is, from architecture point of view, a module of type=0 (module_id) and instance id=0 (instance_id).Quoted 15 lines
Quoted 8 lines
+ }
set_d0ix;
} ext;
};
}__packed;sound/soc/intel/avs/messages.h +0
-0@@ -298,4 +305,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);Quoted 4 lines
+/* DSP cores and domains power management messages */ +struct
avs_dxstate_info{
+ u32core_mask;
+ u32dx_mask;what is the convention for D0 and D3 in the mask ? which one is 0 or 1?
Quoted 2 lines
Is this also handled in a hierarchical way where only the bits set in
core_maskmatter?Can provide a short kernel-doc for these two, sure.
Cezary Rojewski
maintainerRe: [PATCH 08/17] ASoC: Intel: avs: Add power management requests
Quoted 8 lines · Pierre-Louis Bossart
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
+ msg.ext.set_d0ix.wake =
enable_pg;simplify the argument? Not sure anyone could understand what wake and
enable_pgmean.
Quoted 8 lines
Quoted 5 lines
Well, CG and PG are popular shortcuts among Intel audio team and stand for clock gating and power gating respectively. 'wake' is firmware specific. I can provide a comment, but not all question are going to be answered by it. Firmware specification is the place to find the answer for most of these.
again please do not assume that anyone reviewing this code has access to the firmware specification.
Provided simple description for the SET_D0IX message.
Quoted 40 lines
Quoted 40 lines
Quoted 38 lines
int
avs_ipc_set_d0ix(struct avs_dev *adev, bool wake, bool streaming)Quoted 24 lines
+ msg.ext.set_d0ix.streaming = streaming;
sound/soc/intel/avs/messages.c +9
-0+ + request.header = msg.val; + + ret = avs_dsp_send_pm_msg(adev, &request, NULL, false); + if (ret) + avs_ipc_err(adev, &request, "set d0ix", ret); + + return ret; +}sound/soc/intel/avs/messages.h +2
-0@@ -101,6 +101,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, }; @@ -137,6 +139,11 @@ union avs_module_msg {Quoted 7 lines
u32 dst_queue:3;
u32 src_queue:3;
}bind_unbind;
+ struct {
+ /* cAVS < 2.0 */
+ u32 wake:1;
+ u32 streaming:1;you probably want to explain how a 'streaming' flag is set at the module level? One would think all modules connected in a pipeline would need to use the same flag value.
Quoted 7 lines
Quoted 4 lines
Some of the fields are confusing and I agree, but driver has to adhere to FW expectations if it wants to be a working one. I would like to avoid judging the firmware architecture here, regardless of how confusing we think it is.
it's not about judging, just explaining what is expected on the firmware side and what the driver needs to do.
Dropped all the "cavs < 2.0" unclear comments.
Quoted 21 lines
Quoted 21 lines
'wake' and 'streaming' fields are part of
SET_D0ixmessage is which part of MODULE-type message interface. Base firmware is, from architecture point of view, a module of type=0 (module_id) and instance id=0 (instance_id).Quoted 15 lines
sound/soc/intel/avs/messages.h int avs_ipc_get_large_config(struct avs_dev · line 311
Quoted 12 lines
+ }
set_d0ix;
} ext;
};
}__packed;sound/soc/intel/avs/messages.h +3
-0@@ -298,4 +305,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; + u32 dx_mask;what is the convention for D0 and D3 in the mask ? which one is 0 or 1?
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Is this also handled in a hierarchical way where only the bits set in
core_maskmatter?Can provide a short kernel-doc for these two, sure.
Provided a short comments instead.
Cezary Rojewski
maintainerPATCH 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 ;
@@ -260,6 +267,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 09/17] ASoC: Intel: avs: Add ROM requests
Quoted 3 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.
'can' is an imprecise term in technical documentation.
did you mean 'shall' (requirement), 'may' (permission) or 'should' (recommendation)?
It's my understanding that it's legal to redo a complete reboot from a clean-slate.
It's also unclear if the firmware can use this mechanism to prevent the use of IMR, e.g. if in some firmware builds state save/restore was disabled for some reason.
Cezary Rojewski
maintainerRe: [PATCH 09/17] ASoC: Intel: avs: Add ROM requests
Quoted 10 lines · Pierre-Louis Bossart
Quoted 3 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.
'can' is an imprecise term in technical documentation.
did you mean 'shall' (requirement), 'may' (permission) or 'should' (recommendation)?
Quoted 6 lines
It's my understanding that it's legal to redo a complete reboot from a clean-slate.
It's also unclear if the firmware can use this mechanism to prevent the use of IMR, e.g. if in some firmware builds state save/restore was disabled for some reason.
This is a very good feedback, indeed I miss out on the 'can' vs 'shall' (and similar) quite often when speaking about hw/fw procedures. Thank you for paying attention, Pierre.
Yes, in this case driver has total control over the procedure and chooses which method to use when booting the DSP.
While I can't say the details, closed-source firmware (from APL and onwards) is built with IMR in mind. By that I mean that it assumes IMR is always present. So I believe such scenario - having save/restore disabled - is not possible here.
Cezary Rojewski
maintainerPATCH 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
@@ -408,3 +408,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
Cezary Rojewski
maintainerPATCH 11/17 ASoC: Intel: avs: Firmware resources management utilities
In reply to Cezary RojewskiWith basefw runtime parameter handlers added, implement utility functions to ease pipeline and module allocation. IDA is enlisted to help with that. Also, as firmware is modular and multiple binaries can be loaded throughout the lifetime of a driver, custom firmware caching mechanism is added.
--- sound/soc/intel/avs/Makefile | 2 +- sound/soc/intel/avs/avs.h | 29 ++++ sound/soc/intel/avs/utils.c | 282 +++++++++++++++++++++++++++++++++++ 3 files changed, 312 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 +29 -0
@@ -52,6 +52,13 @@ struct avs_spec {const u32 hipc_ctl_offset; }; +struct avs_fw_entry { +char *name; +const struct firmware *fw; + +struct list_head node; +}; +struct avs_dev {struct hda_bus base;struct device *dev;
@@ -60,6 +67,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; };
@@ -154,4 +169,18 @@ 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_firmwares (struct avs_dev *adev); +#endif /* __SOUND_SOC_INTEL_AVS_H */
sound/soc/intel/avs/utils.c new file +282 -0
282 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH 11/17] ASoC: Intel: avs: Firmware resources management utilities
Quoted 5 lines · Cezary Rojewski
With basefw runtime parameter handlers added, implement utility functions to ease pipeline and module allocation. IDA is enlisted to help with that. Also, as firmware is modular and multiple binaries can be loaded throughout the lifetime of a driver, custom firmware caching mechanism is added.
It's not clear what the 'lifetime' refers to. Did you mean that the binaries can be loaded/unloaded on-demand depending on use cases without having to reboot the DSP, or that at each reboot a different set of binaries can be used.
Cezary Rojewski
maintainerRe: [PATCH 11/17] ASoC: Intel: avs: Firmware resources management utilities
Quoted 11 lines · Pierre-Louis Bossart
Quoted 5 lines · Cezary Rojewski
With basefw runtime parameter handlers added, implement utility functions to ease pipeline and module allocation. IDA is enlisted to help with that. Also, as firmware is modular and multiple binaries can be loaded throughout the lifetime of a driver, custom firmware caching mechanism is added.
It's not clear what the 'lifetime' refers to. Did you mean that the binaries can be loaded/unloaded on-demand depending on use cases without having to reboot the DSP, or that at each reboot a different set of binaries can be used.
Ack on improving the commit's message. Thanks for feedback!
Cezary Rojewski
maintainerPATCH 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
@@ -623,3 +623,20 @@ int avs_ipc_get_modules_info(struct avs_dev *adev, struct avs_mods_info **info) *info = (struct avs_mods_info *)payload;return 0 ; } + +int avs_ipc_copier_set_sink_format (struct avs_dev *adev,u16 module_id, +u8 instance_id,u32 sink_id, +const struct avs_audio_format *src_fmt, +const struct avs_audio_format *sink_fmt) +{ +struct avs_copier_sink_format cpr_fmt; + + cpr_fmt.sink_id = sink_id; +/* Firmware expects driver to resend copier's input format. */ + cpr_fmt.src_fmt = *src_fmt; + cpr_fmt.sink_fmt = *sink_fmt; + +return avs_ipc_set_large_config (adev, module_id, instance_id, +AVS_COPIER_SET_SINK_FORMAT , + (u8 *)&cpr_fmt,sizeof (cpr_fmt)); +}
sound/soc/intel/avs/messages.h +252 -0
256 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 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
@@ -74,6 +74,7 @@ struct avs_dev {struct mutex modres_mutex;struct ida ppl_ida;struct list_head fw_list; +int *core_refs;struct completion fw_ready; };
@@ -183,4 +184,13 @@ 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_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 13/17] ASoC: Intel: avs: Dynamic firmware resources management
sound/soc/intel/avs/dsp.c int avs_dsp_core_disable(struct avs_dev *adev, u32 core_mask) · line 116
Quoted 11 lines
sound/soc/intel/avs/dsp.c +10
-0+static int avs_dsp_enable (struct avs_dev *adev,u32 core_mask) +{ +u32 mask; +int ret; + + ret =avs_dsp_core_enable (adev, core_mask); +if (ret <0 ) +return ret; + + mask = core_mask & ~AVS_MAIN_CORE_MASK ;
so here BIT(MAIN_CORE) is zero in mask
sound/soc/intel/avs/dsp.c int avs_dsp_core_disable(struct avs_dev *adev, u32 core_mask) · line 120
Quoted 4 lines
sound/soc/intel/avs/dsp.c +4
-0+if (!mask) +/* +* without main core, fw is dead anyway +* so setting D0 for it is futile.
I don't get the comment, you explicitly discarded the main core with your logical AND above, so this test means that all other non-main cores are disabled.
Quoted 35 lines
sound/soc/intel/avs/dsp.c +35
-0+*/ +return 0 ; + + ret =avs_ipc_set_dx (adev, mask, true); +return AVS_IPC_RET (ret); +} + +static int avs_dsp_disable (struct avs_dev *adev,u32 core_mask) +{ +int ret; + + ret =avs_ipc_set_dx (adev, core_mask, false); +if (ret) +return AVS_IPC_RET (ret); + +return avs_dsp_core_disable (adev, core_mask); +} + +static int avs_dsp_get_core (struct avs_dev *adev,u32 core_id) +{ +u32 mask; +int ret; + + mask =BIT_MASK (core_id); +if (mask ==AVS_MAIN_CORE_MASK ) +/* nothing to do for main core */ +return 0 ; +if (core_id >= adev->hw_cfg.dsp_cores) { + ret = -EINVAL ; + goto err; + } + + adev->core_refs[core_id]++; +if (adev->core_refs[core_id] ==1 ) { + ret =avs_dsp_enable (adev, mask);
sound/soc/intel/avs/dsp.c int avs_dsp_core_disable(struct avs_dev *adev, u32 core_mask) · line 165
Quoted 10 lines
sound/soc/intel/avs/dsp.c +10
-0+if (ret) + goto err_enable_dsp; + } + +return 0 ; + +err_enable_dsp: + adev->core_refs[core_id]--; +err: +dev_err (adev->dev,"get core failed: %d\n" , ret);
you should log which core could not be enabled
Quoted 17 lines
sound/soc/intel/avs/dsp.c +17
-0+return ret; +} + +static int avs_dsp_put_core (struct avs_dev *adev,u32 core_id) +{ +u32 mask; +int ret; + + mask =BIT_MASK (core_id); +if (mask ==AVS_MAIN_CORE_MASK ) +/* nothing to do for main core */ +return 0 ; +if (core_id >= adev->hw_cfg.dsp_cores) { + ret = -EINVAL ; + goto err; + } +
sound/soc/intel/avs/dsp.c int avs_dsp_core_disable(struct avs_dev *adev, u32 core_mask) · line 192
Quoted 10 lines
sound/soc/intel/avs/dsp.c +10
-0+ adev->core_refs[core_id]--; +if (!adev->core_refs[core_id]) { + ret =avs_dsp_disable (adev, mask); +if (ret) + goto err; + } + +return 0 ; +err: +dev_err (adev->dev,"put core failed: %d\n" , ret);
put core %d
sound/soc/intel/avs/dsp.c int avs_dsp_core_disable(struct avs_dev *adev, u32 core_mask) · line 277
Quoted 4 lines
sound/soc/intel/avs/dsp.c +2
-0+return ret; +}MODULE_LICENSE ("GPL v2" );
"GPL"
Cezary Rojewski
maintainerRe: [PATCH 13/17] ASoC: Intel: avs: Dynamic firmware resources management
Quoted 13 lines · Pierre-Louis Bossart
sound/soc/intel/avs/dsp.c int avs_dsp_core_disable(struct avs_dev *adev, u32 core_mask) · line 116
Quoted 11 lines
sound/soc/intel/avs/dsp.c +10
-0+static int avs_dsp_enable (struct avs_dev *adev,u32 core_mask) +{ +u32 mask; +int ret; + + ret =avs_dsp_core_enable (adev, core_mask); +if (ret <0 ) +return ret; + + mask = core_mask & ~AVS_MAIN_CORE_MASK ;so here
BIT(MAIN_CORE)is zero in mask
What's wrong with AVS_MAIN_CORE_MASK being used explicitly?
Quoted 8 lines
sound/soc/intel/avs/dsp.c int avs_dsp_core_disable(struct avs_dev *adev, u32 core_mask) · line 120
Quoted 4 lines
sound/soc/intel/avs/dsp.c +4
-0+if (!mask) +/* +* without main core, fw is dead anyway +* so setting D0 for it is futile. I don't get the comment, you explicitly discarded the main core with your logical AND above, so this test means that all other non-main cores are disabled.
There is no setting D0 for MAIN_CORE as firmware is not operational without it. Firmware needs to be notified about D3 -> D0 transitions only in case of non-MAIN_COREs.
Quoted 39 lines
Quoted 39 lines
sound/soc/intel/avs/dsp.c +39
-0+*/ +return 0 ; + + ret =avs_ipc_set_dx (adev, mask, true); +return AVS_IPC_RET (ret); +} + +static int avs_dsp_disable (struct avs_dev *adev,u32 core_mask) +{ +int ret; + + ret =avs_ipc_set_dx (adev, core_mask, false); +if (ret) +return AVS_IPC_RET (ret); + +return avs_dsp_core_disable (adev, core_mask); +} + +static int avs_dsp_get_core (struct avs_dev *adev,u32 core_id) +{ +u32 mask; +int ret; + + mask =BIT_MASK (core_id); +if (mask ==AVS_MAIN_CORE_MASK ) +/* nothing to do for main core */ +return 0 ; +if (core_id >= adev->hw_cfg.dsp_cores) { + ret = -EINVAL ; + goto err; + } + + adev->core_refs[core_id]++; +if (adev->core_refs[core_id] ==1 ) { + ret =avs_dsp_enable (adev, mask); +if (ret) + goto err_enable_dsp; + } +
Quoted 8 lines
sound/soc/intel/avs/dsp.c int avs_dsp_core_disable(struct avs_dev *adev, u32 core_mask) · line 165
Quoted 6 lines
sound/soc/intel/avs/dsp.c +6
-0+return 0 ; + +err_enable_dsp: + adev->core_refs[core_id]--; +err: +dev_err (adev->dev,"get core failed: %d\n" , ret);you should log which core could not be enabled
Good catch! Ack.
Quoted 21 lines
Quoted 21 lines
sound/soc/intel/avs/dsp.c +21
-0+return ret; +} + +static int avs_dsp_put_core (struct avs_dev *adev,u32 core_id) +{ +u32 mask; +int ret; + + mask =BIT_MASK (core_id); +if (mask ==AVS_MAIN_CORE_MASK ) +/* nothing to do for main core */ +return 0 ; +if (core_id >= adev->hw_cfg.dsp_cores) { + ret = -EINVAL ; + goto err; + } + + adev->core_refs[core_id]--; +if (!adev->core_refs[core_id]) { + ret =avs_dsp_disable (adev, mask); +if (ret)
Quoted 8 lines
sound/soc/intel/avs/dsp.c int avs_dsp_core_disable(struct avs_dev *adev, u32 core_mask) · line 192
Quoted 6 lines
sound/soc/intel/avs/dsp.c +6
-0+ goto err; + } + +return 0 ; +err: +dev_err (adev->dev,"put core failed: %d\n" , ret);put core %d
Ack.
Quoted 6 lines
sound/soc/intel/avs/dsp.c int avs_dsp_core_disable(struct avs_dev *adev, u32 core_mask) · line 277
Quoted 4 lines
sound/soc/intel/avs/dsp.c +2
-0+return ret; +}MODULE_LICENSE ("GPL v2" );"GPL"
Ack.
Re: [PATCH 13/17] ASoC: Intel: avs: Dynamic firmware resources management
Quoted 24 lines
Quoted 15 lines
sound/soc/intel/avs/dsp.c int avs_dsp_core_disable(struct avs_dev *adev, u32 core_mask) · line 116
Quoted 13 lines
sound/soc/intel/avs/dsp.c +10
-0+static int avs_dsp_enable (struct avs_dev *adev,u32 core_mask) +{ + u32 mask; + int ret; + + ret = avs_dsp_core_enable(adev, core_mask); + if (ret < 0) + return ret; + + mask = core_mask & ~AVS_MAIN_CORE_MASK;so here
BIT(MAIN_CORE)is zero in maskWhat's wrong with
AVS_MAIN_CORE_MASKbeing used explicitly?Quoted 5 lines
Quoted 4 lines
+ if (!mask)
+ /*
+ * without main core, fw is dead anyway
+ * so setting D0 for it is futile.
Quoted 7 lines
Quoted 3 lines
I don't get the comment, you explicitly discarded the main core with your logical AND above, so this test means that all other non-main cores are disabled.
There is no setting D0 for
MAIN_COREas firmware is not operational without it. Firmware needs to be notified about D3 -> D0 transitions only in case of non-MAIN_COREs.
the comment was about 'without main core'.
This is difficult to follow, because you've discarded the main code in the if (!mask), so that's an always-true case, which makes the rest of the explanations not so clear.
Cezary Rojewski
maintainerRe: [PATCH 13/17] ASoC: Intel: avs: Dynamic firmware resources management
Quoted 29 lines · Pierre-Louis Bossart
Quoted 21 lines
Quoted 4 lines
Quoted 4 lines
sound/soc/intel/avs/dsp.c +4
-0+static int avs_dsp_enable (struct avs_dev *adev,u32 core_mask) +{ + u32 mask; + int ret;Quoted 8 lines
sound/soc/intel/avs/dsp.c int avs_dsp_core_disable(struct avs_dev *adev, u32 core_mask) · line 116
Quoted 6 lines
sound/soc/intel/avs/dsp.c +6
-0+ + ret = avs_dsp_core_enable(adev, core_mask); + if (ret < 0) + return ret; + + mask = core_mask & ~AVS_MAIN_CORE_MASK;so here
BIT(MAIN_CORE)is zero in maskWhat's wrong with
AVS_MAIN_CORE_MASKbeing used explicitly?Quoted 5 lines
Quoted 4 lines
+ if (!mask)
+ /*
+ * without main core, fw is dead anyway
+ * so setting D0 for it is futile.Quoted 7 lines
Quoted 3 lines
I don't get the comment, you explicitly discarded the main core with your logical AND above, so this test means that all other non-main cores are disabled.
There is no setting D0 for
MAIN_COREas firmware is not operational without it. Firmware needs to be notified about D3 -> D0 transitions only in case of non-MAIN_COREs.
Quoted 5 lines
the comment was about 'without main core'.
This is difficult to follow, because you've discarded the main code in the if (!mask), so that's an always-true case, which makes the rest of the explanations not so clear.
I'm afraid, not seeing the problem. It's clearly not always-true statement as 'mask' can be non-zero after discarding the MAIN_CORE.
Re: [PATCH 13/17] ASoC: Intel: avs: Dynamic firmware resources management
Quoted 33 lines · Cezary Rojewski
Quoted 32 lines · Pierre-Louis Bossart
Quoted 21 lines
Quoted 4 lines
Quoted 4 lines
sound/soc/intel/avs/dsp.c +4
-0+static int avs_dsp_enable (struct avs_dev *adev,u32 core_mask) +{ + u32 mask; + int ret;Quoted 8 lines
sound/soc/intel/avs/dsp.c int avs_dsp_core_disable(struct avs_dev *adev, u32 core_mask) · line 116
Quoted 6 lines
sound/soc/intel/avs/dsp.c +6
-0+ + ret = avs_dsp_core_enable(adev, core_mask); + if (ret < 0) + return ret; + + mask = core_mask & ~AVS_MAIN_CORE_MASK;so here
BIT(MAIN_CORE)is zero in maskWhat's wrong with
AVS_MAIN_CORE_MASKbeing used explicitly?Quoted 5 lines
Quoted 4 lines
+ if (!mask)
+ /*
+ * without main core, fw is dead anyway
+ * so setting D0 for it is futile.Quoted 8 lines
Quoted 4 lines
I don't get the comment, you explicitly discarded the main core with your logical AND above, so this test means that all other non-main cores
are disabled.There is no setting D0 for
MAIN_COREas firmware is not operational without it. Firmware needs to be notified about D3 -> D0 transitions only in case of non-MAIN_COREs.the comment was about 'without main core'.
Quoted 7 lines
Quoted 3 lines
This is difficult to follow, because you've discarded the main code in the if (!mask), so that's an always-true case, which makes the rest of the explanations not so clear.
I'm afraid, not seeing the problem. It's clearly not always-true statement as 'mask' can be non-zero after discarding the
MAIN_CORE.
mask = core_mask & ~AVS_MAIN_CORE_MASK;
-> main core is ignored.
comment says "without main core, fw is dead anyway"
since you ignored the main core, is fw dead in all cases?
Cezary Rojewski
maintainerPATCH 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 | 231 ++++++++++++++++++++++++++++++++ sound/soc/intel/avs/registers.h | 6 + 6 files changed, 344 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 ;
@@ -22,6 +25,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, ...) \
@@ -35,6 +42,7 @@ struct avs_spec {const char *name;const struct avs_dsp_ops *const dops; +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_* */
@@ -75,6 +83,7 @@ struct avs_dev {struct ida ppl_ida;struct list_head fw_list;int *core_refs; +char **lib_names;struct completion fw_ready; };
@@ -193,4 +202,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 +231 -0
231 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 14/17] ASoC: Intel: avs: General code loading flow
Quoted 3 lines
+#define
AVS_FW_INIT_TIMEOUT_MS3000
another timeout?
skl-sst.c:#define SKL_BASEFW_TIMEOUT 300 skl-sst.c:#define SKL_INIT_TIMEOUT 1000 bxt-sst.c:#define BXT_BASEFW_TIMEOUT 3000 cnl-sst.c:#define CNL_INIT_TIMEOUT 300 cnl-sst.c:#define CNL_BASEFW_TIMEOUT 3000
sound/soc/intel/avs/loader.c line 24
Quoted 7 lines
sound/soc/intel/avs/loader.c new file +7
-0+#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 + +static bool debug_ignore_fw_version_check;
this_is_a_very_long_variable_name_isn_t_it?
sound/soc/intel/avs/loader.c line 26
Quoted 2 lines
sound/soc/intel/avs/loader.c new file +2
-0+module_param_named (ignore_fw_version, debug_ignore_fw_version_check, bool,0444 ); +MODULE_PARM_DESC (ignore_fw_version,"Verify FW version 0=yes (default), 1=no" );
You should clarify the purpose of the version check, and why this driver needs different firmware binaries and versions than what was already released to linux-firmware.
Quoted 18 lines
sound/soc/intel/avs/loader.c new file +18
-0+static int avs_fw_manifest_strip_verify (struct avs_dev *adev,struct firmware *fw, +const struct avs_fw_version *min) +{ +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) +return 0 ;
sound/soc/intel/avs/loader.c line 104
Quoted 10 lines
sound/soc/intel/avs/loader.c new file +10
-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) { +dev_warn (adev->dev,"bad FW version %d.%d.%d.%d, expected %d.%d.%d.%d or newer\n" , + man->version.major, man->version.minor, + man->version.hotfix, man->version.build, + min->major, min->minor, min->hotfix, min->build);
usually when the relevant firmware is not found, the distributions and users like to see a message informing them of the location of the firmware binaries.
see thread with Bruce Perens and Jaroslav at
https://github.com/thesofproject/sof-bin/issues/22
Quoted 25 lines
sound/soc/intel/avs/loader.c new file +25
-0+ +if (!debug_ignore_fw_version_check) +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, +AVS_BASEFW_FILENAME ); +if (!filename) +return -ENOMEM ; + + ret =avs_request_firmware (adev, &fw, filename); +kfree (filename); +if (ret <0 ) {
sound/soc/intel/avs/loader.c line 139
Quoted 10 lines
sound/soc/intel/avs/loader.c new file +10
-0+dev_err (adev->dev,"request firmware failed: %d\n" , ret); +return ret; + } + + stripped_fw = *fw; + min_req = &adev->spec->min_fw_version; + + ret =avs_fw_manifest_strip_verify (adev, &stripped_fw, min_req); +if (ret <0 ) { +dev_err (adev->dev,"invalid firmware data: %d\n" , ret);
should you not release the firmware in all error cases?
if this is handled at a higher level, please add a comment.
Quoted 19 lines
sound/soc/intel/avs/loader.c new file +19
-0+return ret; + } + + ret =avs_dsp_op (adev, load_basefw, &stripped_fw); +if (ret <0 ) { +dev_err (adev->dev,"basefw load failed: %d\n" , ret); +return ret; + } + + ret =wait_for_completion_timeout (&adev->fw_ready, +msecs_to_jiffies (AVS_FW_INIT_TIMEOUT_MS )); +if (!ret) { +dev_err (adev->dev,"firmware ready timeout\n" ); +avs_dsp_core_disable (adev,AVS_MAIN_CORE_MASK ); +return -ETIMEDOUT ; + } + +return 0 ; +}
Cezary Rojewski
maintainerRe: [PATCH 14/17] ASoC: Intel: avs: General code loading flow
Quoted 5 lines · Pierre-Louis Bossart
Quoted 3 lines
+#define
AVS_FW_INIT_TIMEOUT_MS3000another timeout?
Different operation, different timeout. What's wrong with that? And we are not repeating it three times (skl/bxt/cnl) as it's done in skylake-driver!
Quoted 6 lines
skl-sst.c:#define SKL_BASEFW_TIMEOUT 300 skl-sst.c:#define SKL_INIT_TIMEOUT 1000 bxt-sst.c:#define BXT_BASEFW_TIMEOUT 3000 cnl-sst.c:#define CNL_INIT_TIMEOUT 300 cnl-sst.c:#define CNL_BASEFW_TIMEOUT 3000
Quoted 9 lines
sound/soc/intel/avs/loader.c line 24
Quoted 7 lines
sound/soc/intel/avs/loader.c new file +7
-0+#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 + +static bool debug_ignore_fw_version_check;
this_is_a_very_long_variable_name_isn_t_it?
Can drop "_check", dropping anything else makes this ambiguous. Also, this variable is used just once, in the very line below.
Quoted 6 lines
sound/soc/intel/avs/loader.c line 26
Quoted 2 lines
sound/soc/intel/avs/loader.c new file +2
-0+module_param_named (ignore_fw_version, debug_ignore_fw_version_check, bool,0444 ); +MODULE_PARM_DESC (ignore_fw_version,"Verify FW version 0=yes (default), 1=no" );You should clarify the purpose of the version check, and why this driver needs different firmware binaries and versions than what was already released to linux-firmware.
Ack. Indeed the name by itself may not be sufficient.
Quoted 33 lines
Quoted 18 lines
sound/soc/intel/avs/loader.c new file +18
-0+static int avs_fw_manifest_strip_verify (struct avs_dev *adev,struct firmware *fw, +const struct avs_fw_version *min) +{ +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) +return 0 ;sound/soc/intel/avs/loader.c line 104
Quoted 10 lines
sound/soc/intel/avs/loader.c new file +10
-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) { +dev_warn (adev->dev,"bad FW version %d.%d.%d.%d, expected %d.%d.%d.%d or newer\n" , + man->version.major, man->version.minor, + man->version.hotfix, man->version.build, + min->major, min->minor, min->hotfix, min->build);usually when the relevant firmware is not found, the distributions and users like to see a message informing them of the location of the firmware binaries.
Quoted 2 lines
see thread with Bruce Perens and Jaroslav at
https://github.com/thesofproject/sof-bin/issues/22
That's a helpful link and a good conversation, thank you. I see that Bruce mentions /lib/firmware as 3rd in presented order and that's where we intend to have firmware files. We are not planning to have a separate repo for base firmware/library binaries if that's the question.
Given the above, I'm not sure if we should be mentioning the need to update /lib/firmware explicitly as people already recognize it as one of the default locations to check.
Quoted 38 lines
Quoted 25 lines
sound/soc/intel/avs/loader.c new file +25
-0+ +if (!debug_ignore_fw_version_check) +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, +AVS_BASEFW_FILENAME ); +if (!filename) +return -ENOMEM ; + + ret =avs_request_firmware (adev, &fw, filename); +kfree (filename); +if (ret <0 ) {sound/soc/intel/avs/loader.c line 139
Quoted 10 lines
sound/soc/intel/avs/loader.c new file +10
-0+dev_err (adev->dev,"request firmware failed: %d\n" , ret); +return ret; + } + + stripped_fw = *fw; + min_req = &adev->spec->min_fw_version; + + ret =avs_fw_manifest_strip_verify (adev, &stripped_fw, min_req); +if (ret <0 ) { +dev_err (adev->dev,"invalid firmware data: %d\n" , ret);should you not release the firmware in all error cases?
Quoted 1 line
if this is handled at a higher level, please add a comment.
I'll sync with Amadeo regarding this. It seems it's cleared only on ->remove().
Quoted 20 lines
Quoted 19 lines
sound/soc/intel/avs/loader.c new file +19
-0+return ret; + } + + ret =avs_dsp_op (adev, load_basefw, &stripped_fw); +if (ret <0 ) { +dev_err (adev->dev,"basefw load failed: %d\n" , ret); +return ret; + } + + ret =wait_for_completion_timeout (&adev->fw_ready, +msecs_to_jiffies (AVS_FW_INIT_TIMEOUT_MS )); +if (!ret) { +dev_err (adev->dev,"firmware ready timeout\n" ); +avs_dsp_core_disable (adev,AVS_MAIN_CORE_MASK ); +return -ETIMEDOUT ; + } + +return 0 ; +}
Cezary Rojewski
maintainerPATCH 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 | 328 ++++++++++++++++++++++++++++++++ sound/soc/intel/avs/cldma.h | 29 +++ sound/soc/intel/avs/registers.h | 2 + 4 files changed, 360 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 +328 -0
328 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 *adsp_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
Re: [PATCH 15/17] ASoC: Intel: avs: Implement CLDMA transfer
sound/soc/intel/avs/cldma.c line 163
Quoted 11 lines
sound/soc/intel/avs/cldma.c new file +8
-0+int hda_cldma_stop (struct hda_cldma *cl) +{ +unsigned int reg; +int ret; + +/* disable interrupts */ +snd_hdac_adsp_updatel (cl,AVS_ADSP_REG_ADSPIC , +AVS_ADSP_ADSPIC_CLDMA ,0 );
single line?
sound/soc/intel/avs/cldma.c line 168
Quoted 5 lines
sound/soc/intel/avs/cldma.c new file +5
-0+snd_hdac_stream_updateb (cl,SD_CTL ,SD_INT_MASK |SD_CTL_DMA_START ,0 ); + +/* await DMA engine stop */ + ret = snd_hdac_stream_readb_poll(cl, SD_CTL, reg, + !(reg & SD_CTL_DMA_START),
move to previous line? we can use 100 chars these days, and that's what you do below.
Quoted 5 lines
sound/soc/intel/avs/cldma.c new file +5
-0+ AVS_CL_OP_INTERVAL_US, AVS_CL_OP_TIMEOUT_US); +cancel_delayed_work_sync (&cl->memcpy_work); + +return ret; +}
Cezary Rojewski
maintainerRe: [PATCH 15/17] ASoC: Intel: avs: Implement CLDMA transfer
Quoted 20 lines · Pierre-Louis Bossart
sound/soc/intel/avs/cldma.c line 163
Quoted 8 lines
sound/soc/intel/avs/cldma.c new file +8
-0+int hda_cldma_stop (struct hda_cldma *cl) +{ +unsigned int reg; +int ret; + +/* disable interrupts */ +snd_hdac_adsp_updatel (cl,AVS_ADSP_REG_ADSPIC , +AVS_ADSP_ADSPIC_CLDMA ,0 );single line?
sound/soc/intel/avs/cldma.c line 168
Quoted 5 lines
sound/soc/intel/avs/cldma.c new file +5
-0+snd_hdac_stream_updateb (cl,SD_CTL ,SD_INT_MASK |SD_CTL_DMA_START ,0 ); + +/* await DMA engine stop */ + ret = snd_hdac_stream_readb_poll(cl, SD_CTL, reg, + !(reg & SD_CTL_DMA_START),move to previous line? we can use 100 chars these days, and that's what you do below.
Quoted 5 lines
sound/soc/intel/avs/cldma.c line 173
Quoted 5 lines
sound/soc/intel/avs/cldma.c new file +5
-0+ AVS_CL_OP_INTERVAL_US, AVS_CL_OP_TIMEOUT_US); +cancel_delayed_work_sync (&cl->memcpy_work); + +return ret; +}
Ack on both.
Cezary Rojewski
maintainerPATCH 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 | 155 +++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+)
sound/soc/intel/avs/avs.h +7 -0
@@ -34,6 +34,8 @@ struct avs_dsp_ops {#define avs_dsp_op (adev, op, ...) \ ((adev)->spec->dops->op(adev, ## __VA_ARGS__)) +#define AVS_PLATATTR_CLDMA BIT_ULL(0) +#define avs_platattr_test (adev, attr) \ ((adev)->spec->attributes & AVS_PLATATTR_##attr)
@@ -211,4 +213,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 +155 -0
179 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH 16/17] ASoC: Intel: avs: Code loading over CLDMA
sound/soc/intel/avs/loader.c static int avs_fw_manifest_strip_verify(struct avs_dev *adev, struct firmware *f · line 187
Quoted 10 lines
sound/soc/intel/avs/loader.c +9
-0+int avs_cldma_load_library (struct avs_dev *adev,struct firmware *lib,u32 id) +{ +struct hda_cldma *cl = &code_loader; +int ret; + +hda_cldma_set_data (cl, (void *)lib->data, lib->size); +/* transfer modules manifest */ +hda_cldma_transfer (cl,msecs_to_jiffies (AVS_CLDMA_START_DELAY_MS )); +/* DMA id ignored as there is only ever one code-loader DMA */
consider adding new lines to make comments more readable. this is a bit of an eyesore.
Quoted 6 lines
sound/soc/intel/avs/loader.c +6
-0+ ret =avs_ipc_load_library (adev,0 , id); +hda_cldma_stop (cl); + +if (ret) { + ret =AVS_IPC_RET (ret); +dev_err (adev->dev,"transfer lib %d failed: %d\n" , id, ret);
sound/soc/intel/avs/loader.c static int avs_fw_manifest_strip_verify(struct avs_dev *adev, struct firmware *f · line 203
Quoted 10 lines
sound/soc/intel/avs/loader.c +10
-0+ } + +return ret; +} + +static int avs_cldma_load_module (struct avs_dev *adev,struct avs_module_entry *mentry) +{ +struct hda_cldma *cl = &code_loader; +const struct firmware *mod; +char mod_name[128 ];
use kasprintf?
Quoted 22 lines
sound/soc/intel/avs/loader.c +22
-0+int ret; + +snprintf (mod_name,sizeof (mod_name),"%s/%s/dsp_mod_%pUL.bin" , +AVS_ROOT_DIR , adev->spec->name, mentry->uuid.b); + + ret =avs_request_firmware (adev, &mod, mod_name); +if (ret <0 ) +return ret; + +hda_cldma_set_data (cl, (void *)mod->data, mod->size); +hda_cldma_transfer (cl,msecs_to_jiffies (AVS_CLDMA_START_DELAY_MS )); + ret =avs_ipc_load_modules (adev, &mentry->module_id,1 ); +hda_cldma_stop (cl); + +if (ret) { +dev_err (adev->dev,"load module %d failed: %d\n" , mentry->module_id, + ret); +return AVS_IPC_RET (ret); + } + +return 0 ; +}
Cezary Rojewski
maintainerRe: [PATCH 16/17] ASoC: Intel: avs: Code loading over CLDMA
Quoted 13 lines · Pierre-Louis Bossart
sound/soc/intel/avs/loader.c static int avs_fw_manifest_strip_verify(struct avs_dev *adev, struct firmware *f · line 187
Quoted 10 lines
sound/soc/intel/avs/loader.c +9
-0+int avs_cldma_load_library (struct avs_dev *adev,struct firmware *lib,u32 id) +{ +struct hda_cldma *cl = &code_loader; +int ret; + +hda_cldma_set_data (cl, (void *)lib->data, lib->size); +/* transfer modules manifest */ +hda_cldma_transfer (cl,msecs_to_jiffies (AVS_CLDMA_START_DELAY_MS )); +/* DMA id ignored as there is only ever one code-loader DMA */ consider adding new lines to make comments more readable. this is a bit of an eyesore.
Ack.
Quoted 10 lines
Quoted 10 lines
sound/soc/intel/avs/loader.c +10
-0+ ret =avs_ipc_load_library (adev,0 , id); +hda_cldma_stop (cl); + +if (ret) { + ret =AVS_IPC_RET (ret); +dev_err (adev->dev,"transfer lib %d failed: %d\n" , id, ret); + } + +return ret; +}
Quoted 8 lines
sound/soc/intel/avs/loader.c static int avs_fw_manifest_strip_verify(struct avs_dev *adev, struct firmware *f · line 203
Quoted 6 lines
sound/soc/intel/avs/loader.c +6
-0+ +static int avs_cldma_load_module (struct avs_dev *adev,struct avs_module_entry *mentry) +{ +struct hda_cldma *cl = &code_loader; +const struct firmware *mod; +char mod_name[128 ];use kasprintf?
Good idea, ack!
Quoted 23 lines
Quoted 22 lines
sound/soc/intel/avs/loader.c +22
-0+int ret; + +snprintf (mod_name,sizeof (mod_name),"%s/%s/dsp_mod_%pUL.bin" , +AVS_ROOT_DIR , adev->spec->name, mentry->uuid.b); + + ret =avs_request_firmware (adev, &mod, mod_name); +if (ret <0 ) +return ret; + +hda_cldma_set_data (cl, (void *)mod->data, mod->size); +hda_cldma_transfer (cl,msecs_to_jiffies (AVS_CLDMA_START_DELAY_MS )); + ret =avs_ipc_load_modules (adev, &mentry->module_id,1 ); +hda_cldma_stop (cl); + +if (ret) { +dev_err (adev->dev,"load module %d failed: %d\n" , mentry->module_id, + ret); +return AVS_IPC_RET (ret); + } + +return 0 ; +}
Cezary Rojewski
maintainerPATCH 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 | 208 +++++++++++++++++++++++++++++++++++ 3 files changed, 214 insertions(+)
sound/soc/intel/Kconfig +1 -0
@@ -217,6 +217,7 @@ config SND_SOC_INTEL_AVS default n 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
@@ -35,6 +35,7 @@ struct avs_dsp_ops { ((adev)->spec->dops->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)
@@ -217,5 +218,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 +208 -0
234 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerQuoted 14 lines · Cezary Rojewski
A continuation of cleanup work of Intel SST solutions found in
sound/soc/intel/. With two major chapters released last year catpt [1] and removal of haswell solution [2], time has come for Skylake-driver.Througout 2019, 2020 and 2021 Skylake-driver has had many fixes applied and even attempts of refactors as seen in fundamental overhaul [3], IPC flow adjustments [4] and
LARGE_CONFIGoverhaul [5] series. Unfortunately, story repeats itself - problems are found within the core of a driver. Painting it with different colors does not change the fact that is it still a house of cards. As changes needed to address those issues would make Skylake solution incompatible with its previous revisions, a decision has been made to provide a new solution instead. In time it would deprecate and replace Skylake-driver.
Quoted 7 lines
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.
Hello,
Despite HDA-series being updated to v2 [1], no changes are required on the side of this series.
Mark,
Should I resend this one regardless of the above?
Also, is there anything else I can help with or explain further regarding code-loading and IPC protocol which this series implements?
Regards,
Czarek
[1]: https://lore.kernel.org/alsa-devel/[email protected]/T/#t
Quoted 3 lines
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.
...
Quoted 7 lines
[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]/
Quoted 4 lines
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.
This series is much simpler indeed, see comments in patches, but that leaves the next steps completely open. It's not quite clear to me how the previous feedback on trying to up-level the DSP management functionality might be handled, and if/when you are planning to submit follow-up patchsets that would implement the required functionality to at least match what the Skylake driver can do today.
To repeat my previous points: the existing DPCM FE/BE split does not even being to represent how a DSP might be handled. The BE typically represents a physical DAI connected to a codec, and the FE pretty much everything else between a host DMA and the DAI. All the internal format conversions, mixers and processing are not really represented other than with DAPM logical widgets, and that's a big miss. There's room for a lot of improvements that would be of interest to all DSP users.
Cezary Rojewski
maintainerQuoted 12 lines · Pierre-Louis Bossart
Quoted 4 lines
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.
This series is much simpler indeed, see comments in patches, but that leaves the next steps completely open. It's not quite clear to me how the previous feedback on trying to up-level the DSP management functionality might be handled, and if/when you are planning to submit follow-up patchsets that would implement the required functionality to at least match what the Skylake driver can do today.
Quoted 7 lines
To repeat my previous points: the existing DPCM FE/BE split does not even being to represent how a DSP might be handled. The BE typically represents a physical DAI connected to a codec, and the FE pretty much everything else between a host DMA and the DAI. All the internal format conversions, mixers and processing are not really represented other than with DAPM logical widgets, and that's a big miss. There's room for a lot of improvements that would be of interest to all DSP users.
Thanks for taking time to provide round of review for the series!
The request was to split the initial series into smaller chunks and separate the driver-specific stuff from parts that _could_ get incorporated into the framework to level it up in regard to DSP management. Series: "Intel: avs: Topology and path management" [1] has been provided for such discussion.
Given the request, we are planning to upstream avs-driver in four chunks:
- IPC protocol and code loading (this one)
- Topology and path management [1]
- secondary flows e.g.: DSP recovery
- machine boards
In regard to DPCM FE/BE, ASoC already has DAI-link components: let codec operations stay with codec component, leaving DSP related operations as platform component responsibility. FE for DSP drivers typically comes from topology and drives the HOST DMA part whereas BE deals with LINK (hardware, data transfer interface such as PDM or I2S) side, including its configuration. I'm happy to continue the discussion regarding "path" in the dedicated series [1] as current series covers IPC protocol and code loading -only.
Regards,
Czarek
[1]: https://lore.kernel.org/alsa-devel/[email protected]/T/#t
Quoted 14 lines
The request was to split the initial series into smaller chunks and separate the driver-specific stuff from parts that _could_ get incorporated into the framework to level it up in regard to DSP management. Series: "Intel: avs: Topology and path management" [1] has been provided for such discussion.
Given the request, we are planning to upstream avs-driver in four chunks:
- IPC protocol and code loading (this one)
- Topology and path management [1]
- secondary flows e.g.: DSP recovery
- machine boards
Quoted 6 lines
In regard to DPCM FE/BE, ASoC already has DAI-link components: let codec operations stay with codec component, leaving DSP related operations as platform component responsibility. FE for DSP drivers typically comes from topology and drives the HOST DMA part whereas BE deals with LINK (hardware, data transfer interface such as PDM or I2S) side, including its configuration.
I respectfully disagree with your analysis, we cannot dissociate DSP and link management. The intersection between the BE dailink handling and the DSP management is the configuration of the cpu-dai on the host side.
When the DSP firmware programs the DAI registers, as we do on the Intel side for SSP, DMIC and ALH/SoundWire, then the format information needs to be exposed back to the DSP platform driver so that the codec can be informed of the configuration. Most interfaces can support multiple formats, and currently we don't have a good way to know what the firmware changes and how to match PCM hw_params with link configuration.
The current work-around we use is to rely on the dailink fixup to force the dailink to operate at a rate consistent with the topology, but that's really not good at all. What would be needed is that all format changes through the DSP graph are propagated all the way to the DAI and used for the dailink configuration. That would also enable us to remove unnecessary SRCs or format conversions, which I believe is a capability at the heart of your AVS path proposal.
That's really my point, you cannot really think of DSP management without factoring in DPCM.
It's not just me blabbering into the wind btw, others have voiced the need to improve FE->BE format handling and add constraints, see
https://lore.kernel.org/alsa-devel/[email protected]/
Quoted 2 lines
I'm happy to continue the discussion regarding "path" in the dedicated series [1] as current series covers IPC protocol and code loading -only.
this RFC series was not mentioned in the cover letter for this patchset, so it wouldn't be surprising if others also missed the connection.
Quoted 2 lines
[1]:
https://lore.kernel.org/alsa-devel/[email protected]/T/#t
Mark Brown
maintainerQuoted 5 lines · Pierre-Louis Bossart
leaves the next steps completely open. It's not quite clear to me how the previous feedback on trying to up-level the DSP management functionality might be handled, and if/when you are planning to submit follow-up patchsets that would implement the required functionality to at least match what the Skylake driver can do today.
I think it's fine that none of the complicated stuff is considered here, one of the objectives with splitting things up into multiple serieses is to ensure that the simpler stuff doesn't obscure the bits that need more attention paying to them.