ASoC: Intel: avs: Updates and cleanups
Subsystems (3)
Cezary Rojewski
maintainercover ASoC: Intel: avs: Updates and cleanups
Series consists of loosely connected patches and does not concentrate on one specific subject.
First, as generic HDAudio codec driver is now part of ASoC, avs-driver core is updated to register missing ext_bus operations. This completes driver's core implementation.
The next change adds the last missing piece for port descriptions coming from topology in formatted string format e.g.: ssp%d have full effect. To do that, the port value needs to be provided to respective copier configuration.
Third change relaxes core transition timings so that scenarios where modules are interfering with each other while being on separate cores are not occasionally causing trouble.
All other changes are addressing warnings, cleaning things up a little and protecting driver from invalid firmware behavior - while not expected in release binaries, does not hurt to add them.
Amadeusz Sławiński (2):
ASoC: Intel: avs: Set max DMA segment size
ASoC: Intel: avs: Use helper function to set up DMA
Cezary Rojewski (10):
ASoC: Intel: avs: Register HDAudio ext-bus operations
ASoC: Intel: avs: Assign I2S gateway when parsing topology
ASoC: Intel: avs: Relax DSP core transition timings
ASoC: Intel: avs: Copy only as many RX bytes as necessary
ASoC: Intel: avs: Shield LARGE_CONFIG_GETs against zero payload_size
ASoC: Intel: avs: Block IPC channel on suspend
ASoC: Intel: avs: Recognize FW_CFG_RESERVED
ASoC: Intel: avs: Replace hardcodes with SD_CTL_STREAM_RESET
ASoC: Intel: avs: Lower UNLOAD_MULTIPLE_MODULES IPC timeout
ASoC: Intel: avs: Update AVS_FW_INIT_TIMEOUT_US declaration
sound/soc/intel/Kconfig | 2 +- sound/soc/intel/avs/cldma.c | 12 ++++++------ sound/soc/intel/avs/core.c | 13 ++++++------- sound/soc/intel/avs/dsp.c | 11 +++++++++-- sound/soc/intel/avs/ipc.c | 1 + sound/soc/intel/avs/loader.c | 2 +- sound/soc/intel/avs/messages.c | 18 +++++++++++++----- sound/soc/intel/avs/topology.c | 27 +++++++++++++++++++++++++++ 8 files changed, 64 insertions(+), 22 deletions(-)
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 1/12 ASoC: Intel: avs: Register HDAudio ext-bus operations
With ASoC representation of HDAudio codec added, update bus initiazation to complete it.
--- sound/soc/intel/Kconfig | 2 +- sound/soc/intel/avs/core.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
sound/soc/intel/Kconfig +1 -1
@@ -216,7 +216,7 @@ config SND_SOC_INTEL_AVS depends on COMMON_CLK select SND_SOC_ACPI if ACPI select SND_SOC_TOPOLOGY - select SND_HDA + select SND_SOC_HDA select SND_HDA_EXT_CORE select SND_HDA_DSP_LOADER select SND_INTEL_DSP_CONFIG
sound/soc/intel/avs/core.c +2 -1
@@ -23,6 +23,7 @@#include <sound/hdaudio_ext.h> #include <sound/intel-dsp-config.h> #include <sound/intel-nhlt.h> +#include "../../codecs/hda.h" #include "avs.h" #include "cldma.h"
@@ -356,7 +357,7 @@ static int avs_bus_init(struct avs_dev *adev, struct pci_dev *pci, const structstruct device *dev = &pci->dev;int ret; - ret =snd_hdac_ext_bus_init (&bus->core, dev,NULL ,NULL ); + ret =snd_hdac_ext_bus_init (&bus->core, dev,NULL , &soc_hda_ext_bus_ops);if (ret <0 )return ret;
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 2/12 ASoC: Intel: avs: Assign I2S gateway when parsing topology
In reply to Cezary RojewskiFor formatted port - ssp%d - descriptions to have an effect, copier module templates need to be updated with specified port value. This value is later propagated to the firmware when module instances are being instantiated.
--- sound/soc/intel/avs/topology.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
sound/soc/intel/avs/topology.c +27 -0
@@ -808,6 +808,30 @@ static const struct avs_tplg_token_parser pin_format_parsers[] = { }, }; +static void +assign_copier_gtw_instance (struct snd_soc_component *comp,struct avs_tplg_modcfg_ext *cfg) +{ +struct snd_soc_acpi_mach *mach; + +if (!guid_equal (&cfg->type, &AVS_COPIER_MOD_UUID )) +return ; + +/* Only I2S boards assign port instance in ->i2s_link_mask. */ +switch (cfg->copier.dma_type) { +case AVS_DMA_I2S_LINK_OUTPUT : +case AVS_DMA_I2S_LINK_INPUT : +break ; +default : +return ; + } + + mach =dev_get_platdata (comp->card->dev); + +/* Automatic assignment only when board describes single SSP. */ +if (hweight_long (mach->mach_params.i2s_link_mask) ==1 && !cfg->copier.vindex.i2s.instance) + cfg->copier.vindex.i2s.instance =__ffs (mach->mach_params.i2s_link_mask); +} + static int avs_tplg_parse_modcfg_ext(struct snd_soc_component *comp, struct avs_tplg_modcfg_ext *cfg, struct snd_soc_tplg_vendor_array *tuples,
@@ -827,6 +851,9 @@ static int avs_tplg_parse_modcfg_ext(struct snd_soc_component *comp,if (ret)return ret; +/* Update copier gateway based on board's i2s_link_mask. */ +assign_copier_gtw_instance (comp, cfg); + block_size -= esize;/* Parse trailing in/out pin formats if any. */ if (block_size) {
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 3/12 ASoC: Intel: avs: Relax DSP core transition timings
In reply to Cezary RojewskiTo avoid any false positives when checking CPA after setting SPA, do a short wait. For stall operation, give HW more time to propagate the change before moving on.
--- sound/soc/intel/avs/dsp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
sound/soc/intel/avs/dsp.c +9 -2
@@ -13,6 +13,7 @@#define AVS_ADSPCS_INTERVAL_US 500#define AVS_ADSPCS_TIMEOUT_US 50000 +#define AVS_ADSPCS_DELAY_US 1000int avs_dsp_core_power (struct avs_dev *adev,u32 core_mask,bool power) {
@@ -26,6 +27,8 @@ int avs_dsp_core_power(struct avs_dev *adev, u32 core_mask, bool power) value = power ? mask :0 ;snd_hdac_adsp_updatel (adev,AVS_ADSP_REG_ADSPCS , mask, value); +/* Delay the polling to avoid false positives. */ +usleep_range (AVS_ADSPCS_DELAY_US ,2 *AVS_ADSPCS_DELAY_US ); mask =AVS_ADSPCS_CPA_MASK (core_mask); value = power ? mask :0 ;
@@ -82,11 +85,15 @@ int avs_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stall) reg, (reg & mask) == value,AVS_ADSPCS_INTERVAL_US , AVS_ADSPCS_TIMEOUT_US); -if (ret) +if (ret) {dev_err (adev->dev,"core_mask %d %sstall failed: %d\n" , core_mask, stall ?"" :"un" , ret); +return ret; + } -return ret; +/* Give HW time to propagate the change. */ +usleep_range (AVS_ADSPCS_DELAY_US ,2 *AVS_ADSPCS_DELAY_US ); +return 0 ; }int avs_dsp_core_enable (struct avs_dev *adev,u32 core_mask)
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 4/12 ASoC: Intel: avs: Copy only as many RX bytes as necessary
In reply to Cezary RojewskiThere is no need to copy number of bytes specified by IPC message caller if DSP firmware returned lower number. In consequence, LARGE_CONFIG_GET handler is simplified.
--- sound/soc/intel/avs/ipc.c | 1 + sound/soc/intel/avs/messages.c | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-)
sound/soc/intel/avs/ipc.c +1 -0
@@ -480,6 +480,7 @@ static int avs_dsp_do_send_msg(struct avs_dev *adev, struct avs_ipc_msg *request ret = ipc->rx.rsp.status;if (reply) { reply->header = ipc->rx.header; + reply->size = ipc->rx.size;if (reply->data && ipc->rx.size)memcpy (reply->data, ipc->rx.data, reply->size); }
sound/soc/intel/avs/messages.c +2 -4
@@ -378,7 +378,6 @@ int avs_ipc_get_large_config(struct avs_dev *adev, u16 module_id, u8 instance_idunion avs_module_msg msg =AVS_MODULE_REQUEST (LARGE_CONFIG_GET );struct avs_ipc_msg request;struct avs_ipc_msg reply = {{0 }}; -size_t size;void *buf;int ret;
@@ -406,15 +405,14 @@ int avs_ipc_get_large_config(struct avs_dev *adev, u16 module_id, u8 instance_idreturn ret; } - size = reply.rsp.ext.large_config.data_off_size; - buf =krealloc (reply.data, size,GFP_KERNEL ); + buf =krealloc (reply.data, reply.size,GFP_KERNEL );if (!buf) {kfree (reply.data);return -ENOMEM ; } *reply_data = buf; - *reply_size = size; + *reply_size = reply.size;return 0 ; }
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 5/12 ASoC: Intel: avs: Shield LARGE_CONFIG_GETs against zero payload_size
In reply to Cezary RojewskiSome LARGE_CONFIG_GETs are never expected to return payload of size 0. Check for such situation and collapse if met.
--- sound/soc/intel/avs/messages.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/soc/intel/avs/messages.c +9 -0
@@ -474,6 +474,9 @@ int avs_ipc_get_fw_config(struct avs_dev *adev, struct avs_fw_cfg *cfg) &payload, &payload_size);if (ret)return ret; +/* Non-zero payload expected for FIRMWARE_CONFIG. */ +if (!payload_size) +return -EREMOTEIO ;while (offset < payload_size) { tlv = (struct avs_tlv *)(payload + offset);
@@ -587,6 +590,9 @@ int avs_ipc_get_hw_config(struct avs_dev *adev, struct avs_hw_cfg *cfg) &payload, &payload_size);if (ret)return ret; +/* Non-zero payload expected for HARDWARE_CONFIG. */ +if (!payload_size) +return -EREMOTEIO ;while (offset < payload_size) { tlv = (struct avs_tlv *)(payload + offset);
@@ -670,6 +676,9 @@ int avs_ipc_get_modules_info(struct avs_dev *adev, struct avs_mods_info **info) &payload, &payload_size);if (ret)return ret; +/* Non-zero payload expected for MODULES_INFO. */ +if (!payload_size) +return -EREMOTEIO ; *info = (struct avs_mods_info *)payload;return 0 ;
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 6/12 ASoC: Intel: avs: Block IPC channel on suspend
In reply to Cezary RojewskiTo allow for driver's filesystem interfaces e.g.: debugfs, to be touched even when the device is asleep, mark IPC-channel as blocked when the device is suspended. This causes any invocation of said interfaces that do not toggle PM themselves to gracefully fail with "Operation not permitted" message.
--- sound/soc/intel/avs/core.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/intel/avs/core.c +1 -0
@@ -556,6 +556,7 @@ static int __maybe_unused avs_suspend_common(struct avs_dev *adev)return AVS_IPC_RET (ret); } +avs_ipc_block (adev->ipc);avs_dsp_op (adev, int_control, false);snd_hdac_ext_bus_ppcap_int_enable (bus, false);
Signature · 1 line
2.25.1
Mark Brown
maintainerRe: [PATCH 06/12] ASoC: Intel: avs: Block IPC channel on suspend
sound/soc/intel/avs/core.c static int __maybe_unused avs_suspend_common(struct avs_dev *adev) · line 561
Quoted 6 lines · Cezary Rojewski
sound/soc/intel/avs/core.c +1
-0return AVS_IPC_RET (ret); } +avs_ipc_block (adev->ipc);avs_dsp_op (adev, int_control, false);snd_hdac_ext_bus_ppcap_int_enable (bus, false);
The fact that there's no matching change to unblock is fine since there's already code the paths starting the DSP which does that.
Cezary Rojewski
maintainerRe: [PATCH 06/12] ASoC: Intel: avs: Block IPC channel on suspend
Quoted 11 lines · Mark Brown
sound/soc/intel/avs/core.c static int __maybe_unused avs_suspend_common(struct avs_dev *adev) · line 561
Quoted 6 lines · Cezary Rojewski
return AVS_IPC_RET(ret); }sound/soc/intel/avs/core.c +1
-0+avs_ipc_block (adev->ipc);avs_dsp_op (adev, int_control, false);snd_hdac_ext_bus_ppcap_int_enable (bus, false);The fact that there's no matching change to unblock is fine since there's already code the paths starting the DSP which does that.
True. While it may be questioned why this line wasn't here from the get go, in practice it was redundant - nothing was ever "asking" driver for anything while it was asleep.
One of the next series in line is debugfs-related one. We could either have every single file do PM manipulation on its own or allow for fileop to fail gracefully if the device was asleep. Lately we revisited the subject and decided to move away from the first option - not every fileop will be resuming the device.
Regards,
Czarek
Cezary Rojewski
maintainerPATCH 7/12 ASoC: Intel: avs: Set max DMA segment size
In reply to Cezary RojewskiFrom: Amadeusz Sławiński <[email protected]>
Apparently it is possible for code to allocate large buffers which may cause warnings as reported in [1]. This was fixed for HDA, SOF and skylake in patchset [2], fix it also for avs driver.
[1] https://github.com/thesofproject/linux/issues/3430
[2] https://lore.kernel.org/all/[email protected]/
--- sound/soc/intel/avs/core.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/intel/avs/core.c +1 -0
@@ -446,6 +446,7 @@ static int avs_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)dma_set_mask (dev,DMA_BIT_MASK (32 ));dma_set_coherent_mask (dev,DMA_BIT_MASK (32 )); } +dma_set_max_seg_size (dev,UINT_MAX ); ret =avs_hdac_bus_init_streams (bus);if (ret <0 ) {
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 8/12 ASoC: Intel: avs: Use helper function to set up DMA
In reply to Cezary RojewskiFrom: Amadeusz Sławiński <[email protected]>
dma_set_mask() and dma_set_coherent_mask() can be performed with one call to dma_set_mask_and_coherent(), which slightly reduces amount of code on our side.
--- sound/soc/intel/avs/core.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
sound/soc/intel/avs/core.c +2 -6
@@ -440,12 +440,8 @@ static int avs_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)if (bus->mlcap)snd_hdac_ext_bus_get_ml_capabilities (bus); -if (!dma_set_mask (dev,DMA_BIT_MASK (64 ))) { -dma_set_coherent_mask (dev,DMA_BIT_MASK (64 )); - }else { -dma_set_mask (dev,DMA_BIT_MASK (32 )); -dma_set_coherent_mask (dev,DMA_BIT_MASK (32 )); - } +if (!dma_set_mask_and_coherent (dev,DMA_BIT_MASK (64 ))) +dma_set_mask_and_coherent (dev,DMA_BIT_MASK (32 ));dma_set_max_seg_size (dev,UINT_MAX ); ret =avs_hdac_bus_init_streams (bus);
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 9/12 ASoC: Intel: avs: Recognize FW_CFG_RESERVED
In reply to Cezary RojewskiIf exposed by firmware, count RESERVED parameter as known one to avoid dumping noise in kernel logs.
--- sound/soc/intel/avs/messages.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/intel/avs/messages.c +1 -0
@@ -562,6 +562,7 @@ int avs_ipc_get_fw_config(struct avs_dev *adev, struct avs_fw_cfg *cfg)case AVS_FW_CFG_DMA_BUFFER_CONFIG :case AVS_FW_CFG_SCHEDULER_CONFIG :case AVS_FW_CFG_CLOCKS_CONFIG : +case AVS_FW_CFG_RESERVED :break ;default :
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 10/12 ASoC: Intel: avs: Replace hardcodes with SD_CTL_STREAM_RESET
In reply to Cezary RojewskiImprove readability of CLDMA reset operation by making use of already defined SD_CTL_STREAM_RESET.
--- sound/soc/intel/avs/cldma.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
sound/soc/intel/avs/cldma.c +6 -6
@@ -176,17 +176,17 @@ int hda_cldma_reset(struct hda_cldma *cl)return ret; } -snd_hdac_stream_updateb (cl,SD_CTL ,1 ,1 ); - ret =snd_hdac_stream_readb_poll (cl,SD_CTL , reg, (reg &1 ),AVS_CL_OP_INTERVAL_US , -AVS_CL_OP_TIMEOUT_US ); +snd_hdac_stream_updateb (cl,SD_CTL ,SD_CTL_STREAM_RESET ,SD_CTL_STREAM_RESET ); + ret =snd_hdac_stream_readb_poll (cl,SD_CTL , reg, (reg &SD_CTL_STREAM_RESET ), +AVS_CL_OP_INTERVAL_US ,AVS_CL_OP_TIMEOUT_US );if (ret <0 ) {dev_err (cl->dev,"cldma set SRST failed: %d\n" , ret);return ret; } -snd_hdac_stream_updateb (cl,SD_CTL ,1 ,0 ); - ret =snd_hdac_stream_readb_poll (cl,SD_CTL , reg, !(reg &1 ),AVS_CL_OP_INTERVAL_US , -AVS_CL_OP_TIMEOUT_US ); +snd_hdac_stream_updateb (cl,SD_CTL ,SD_CTL_STREAM_RESET ,0 ); + ret =snd_hdac_stream_readb_poll (cl,SD_CTL , reg, !(reg &SD_CTL_STREAM_RESET ), +AVS_CL_OP_INTERVAL_US ,AVS_CL_OP_TIMEOUT_US );if (ret <0 ) {dev_err (cl->dev,"cldma unset SRST failed: %d\n" , ret);return ret;
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 11/12 ASoC: Intel: avs: Lower UNLOAD_MULTIPLE_MODULES IPC timeout
In reply to Cezary RojewskiModule unloading operation performs memory unmapping and the weight of the opration does not different from any other standard IPC. There is no dependency on secondary task like in module loading scenario where larger message timeout is recommended.
--- sound/soc/intel/avs/messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/avs/messages.c +1 -1
@@ -59,7 +59,7 @@ int avs_ipc_unload_modules(struct avs_dev *adev, u16 *mod_ids, u32 num_mod_ids) 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 ); + ret =avs_dsp_send_msg (adev, &request,NULL );if (ret)avs_ipc_err (adev, &request,"unload multiple modules" , ret);
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 12/12 ASoC: Intel: avs: Update AVS_FW_INIT_TIMEOUT_US declaration
In reply to Cezary RojewskiTo reduce the number of places to update if timeouts would have to change, modify the constant declaration.
--- sound/soc/intel/avs/loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/avs/loader.c +1 -1
@@ -27,8 +27,8 @@#define APL_ROM_INIT_RETRIES 3#define AVS_FW_INIT_POLLING_US 500 -#define AVS_FW_INIT_TIMEOUT_US 3000000#define AVS_FW_INIT_TIMEOUT_MS 3000 +#define AVS_FW_INIT_TIMEOUT_US (AVS_FW_INIT_TIMEOUT_MS * 1000)#define AVS_CLDMA_START_DELAY_MS 100
Signature · 1 line
2.25.1
Mark Brown
maintainerQuoted 8 lines · Cezary Rojewski
Series consists of loosely connected patches and does not concentrate on one specific subject.
First, as generic HDAudio codec driver is now part of ASoC, avs-driver core is updated to register missing
ext_busoperations. This completes driver's core implementation.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/12] ASoC: Intel: avs: Register HDAudio ext-bus operations
commit: c50cea054e04769471d2f17a57fafd7c5dfe8df8
[02/12] ASoC: Intel: avs: Assign I2S gateway when parsing topology
commit: 5f267aa4adad13f764e0b00926c349f8728fce77
[03/12] ASoC: Intel: avs: Relax DSP core transition timings
commit: 8192d24cccfbd93dadefd2b7553ff15e41d0e680
[04/12] ASoC: Intel: avs: Copy only as many RX bytes as necessary
commit: 3c1923a119a61534f8ce221766041ddf470c9307
[05/12] ASoC: Intel: avs: Shield LARGE_CONFIG_GETs against zero payload_size
commit: 00566ad4ce9d394c6ebaacde12eda06eef4e5279
[06/12] ASoC: Intel: avs: Block IPC channel on suspend
commit: daa36bbcd78bca24db84e273bcafec9a8f81c767
[07/12] ASoC: Intel: avs: Set max DMA segment size
commit: 8544eebc78c96f1834a46b26ade3e7ebe785d10c
[08/12] ASoC: Intel: avs: Use helper function to set up DMA
commit: a5bbbde2b81e41cea7fa1b38911e88da5febc2d5
[09/12] ASoC: Intel: avs: Recognize FW_CFG_RESERVED
commit: 79c351fb50e7e37eacf93f55f1e7056148d0d814
[10/12] ASoC: Intel: avs: Replace hardcodes with SD_CTL_STREAM_RESET
commit: 4b38bd16ca6d8b16c1dc2cc4aa61663193b0b893
[11/12] ASoC: Intel: avs: Lower UNLOAD_MULTIPLE_MODULES IPC timeout
commit: 8758ae88f0f4ade16e6a1b709eb5ea7271f62320
[12/12] ASoC: Intel: avs: Update AVS_FW_INIT_TIMEOUT_US declaration
commit: f1eea11523e4394d6670f10a51356e9b7c8567a8All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark