ASoC: Intel: avs: Fixes and cleanups for 6.10
Subsystems (3)
Cezary Rojewski
maintainercover ASoC: Intel: avs: Fixes and cleanups for 6.10
Set of changes targeting the avs-driver only. No new features, patchset either fixes or fortifies existing code.
Patchset starts off with a fix for debugbility on ICL+ platforms which I have forgotten to fixup when providing support for these initially. The next two address copier module initialization, most importantly, silence the gcc 'field-spanning write' false-positive.
The following four:
6/13 ASoC: Intel: avs: Replace risky functions with safer variants 7/13 ASoC: Intel: avs: Fix potential integer overflow 8/13 ASoC: Intel: avs: Test result of avs_get_module_entry() 9/13 ASoC: Intel: avs: Remove dead code
address problems found out by Coverity static analysis tool.
The last two worth mentioning are: recommendation from the firmware team to wake subsystem from D0ix when starting any pipeline -and- shielding against invalid period/buffer sizes. Audio format shall be taken into consideration when calculating either of these.
Amadeusz Sławiński (2):
ASoC: Intel: avs: Restore stream decoupling on prepare
ASoC: Intel: avs: Add assert_static to guarantee ABI sizes
Cezary Rojewski (11):
ASoC: Intel: avs: Fix debug-slot offset calculation
ASoC: Intel: avs: Silence false-positive memcpy() warnings
ASoC: Intel: avs: Fix config_length for config-less copiers
ASoC: Intel: avs: Fix ASRC module initialization
ASoC: Intel: avs: Replace risky functions with safer variants
ASoC: Intel: avs: Fix potential integer overflow
ASoC: Intel: avs: Test result of avs_get_module_entry()
ASoC: Intel: avs: Remove dead code
ASoC: Intel: avs: Wake from D0ix when starting streaming
ASoC: Intel: avs: Init debugfs before booting firmware
ASoC: Intel: avs: Rule invalid buffer and period sizes out
sound/soc/intel/avs/avs.h | 1 + sound/soc/intel/avs/cldma.c | 2 +- sound/soc/intel/avs/core.c | 4 +-- sound/soc/intel/avs/icl.c | 12 ++++++--- sound/soc/intel/avs/loader.c | 6 +++-- sound/soc/intel/avs/messages.h | 47 ++++++++++++++++++++++++++++++++-- sound/soc/intel/avs/path.c | 13 ++++------ sound/soc/intel/avs/pcm.c | 34 +++++++++++++++++++++++- sound/soc/intel/avs/probes.c | 14 ++++++---- 9 files changed, 109 insertions(+), 24 deletions(-)
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 1/13 ASoC: Intel: avs: Restore stream decoupling on prepare
From: Amadeusz Sławiński <[email protected]>
Revert changes from commit b87b8f43afd5 ("ASoC: Intel: avs: Drop superfluous stream decoupling") to restore working streaming during S3.
--- sound/soc/intel/avs/pcm.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/soc/intel/avs/pcm.c +4 -0
@@ -356,6 +356,7 @@ static int avs_dai_hda_be_prepare(struct snd_pcm_substream *substream, struct sn stream_info->sig_bits); format_val =snd_hdac_stream_format (runtime->channels, bits, runtime->rate); +snd_hdac_ext_stream_decouple (bus, link_stream, true);snd_hdac_ext_stream_reset (link_stream);snd_hdac_ext_stream_setup (link_stream, format_val);
@@ -611,6 +612,7 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_sostruct avs_dev *adev =to_avs_dev (dai->dev);struct hdac_ext_stream *host_stream;unsigned int format_val; +struct hdac_bus *bus;unsigned int bits;int ret;
@@ -620,6 +622,8 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_soif (hdac_stream (host_stream)->prepared)return 0 ; + bus =hdac_stream (host_stream)->bus; +snd_hdac_ext_stream_decouple (bus, data->host_stream, true);snd_hdac_stream_reset (hdac_stream (host_stream)); stream_info =snd_soc_dai_get_pcm_stream (dai, substream->stream);
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 2/13 ASoC: Intel: avs: Fix debug-slot offset calculation
In reply to Cezary RojewskiFor resources with ID other than 0 the current calculus is incorrect.
--- sound/soc/intel/avs/icl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
sound/soc/intel/avs/icl.c +2 -3
@@ -66,7 +66,7 @@ struct avs_icl_memwnd2 {struct avs_icl_memwnd2_desc slot_desc[AVS_ICL_MEMWND2_SLOTS_COUNT ];u8 rsvd[PAGE_SIZE ]; }; -u8 slot_array[AVS_ICL_MEMWND2_SLOTS_COUNT ][PAGE_SIZE ]; +u8 slot_array[AVS_ICL_MEMWND2_SLOTS_COUNT ][SZ_4K ]; } __packed;#define AVS_ICL_SLOT_UNUSED \
@@ -89,8 +89,7 @@ static int avs_icl_slot_offset(struct avs_dev *adev, union avs_icl_memwnd2_slot_for (i =0 ; i <AVS_ICL_MEMWND2_SLOTS_COUNT ; i++)if (desc[i].slot_id.val == slot_type.val) -return offsetof(struct avs_icl_memwnd2 , slot_array) + -avs_skl_log_buffer_offset (adev, i); +return offsetof(struct avs_icl_memwnd2 , slot_array) + i *SZ_4K ;return -ENXIO ; }
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 3/13 ASoC: Intel: avs: Silence false-positive memcpy() warnings
In reply to Cezary RojewskiCommit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") enforced strict flex array declarations. This generates false-positive in form of:
"memcpy: detected field-spanning write". Avoid it by utilizing the DECLARE_FLEX_ARRAY() macro.
--- sound/soc/intel/avs/messages.h | 4 ++-- sound/soc/intel/avs/path.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
sound/soc/intel/avs/messages.h +2 -2
@@ -752,9 +752,9 @@ struct avs_copier_gtw_cfg {union avs_connector_node_id node_id;u32 dma_buffer_size;u32 config_length; -struct { +union {union avs_gtw_attributes attrs; -u32 blob[]; + DECLARE_FLEX_ARRAY(u32, blob); } config; } __packed;
sound/soc/intel/avs/path.c +1 -1
@@ -254,7 +254,7 @@ static int avs_copier_create(struct avs_dev *adev, struct avs_path_module *mod)/* config_length in DWORDs */ cfg->gtw_cfg.config_length =DIV_ROUND_UP (data_size,4 );if (data) -memcpy (&cfg->gtw_cfg.config, data, data_size); +memcpy (&cfg->gtw_cfg.config.blob, data, data_size); mod->gtw_attrs = cfg->gtw_cfg.config.attrs;
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 4/13 ASoC: Intel: avs: Fix config_length for config-less copiers
In reply to Cezary RojewskiCopier's config_length shall always be at least one even if there is no configuration payload to carry. While the firmware treats config_length=0 or 1 in the same manner, the driver shall initialize the module properly.
--- sound/soc/intel/avs/path.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
sound/soc/intel/avs/path.c +3 -5
@@ -148,11 +148,12 @@ static int avs_copier_create(struct avs_dev *adev, struct avs_path_module *mod)struct avs_copier_cfg *cfg;struct nhlt_specific_cfg *ep_blob;union avs_connector_node_id node_id = {0 }; -size_t cfg_size, data_size =0 ; +size_t cfg_size, data_size;void *data =NULL ;u32 dma_type;int ret; + data_size =sizeof (cfg->gtw_cfg.config); dma_type = t->cfg_ext->copier.dma_type; node_id.dma_type = dma_type;
@@ -233,10 +234,7 @@ static int avs_copier_create(struct avs_dev *adev, struct avs_path_module *mod)break ; } - cfg_size =sizeof (*cfg) + data_size; -/* Every config-BLOB contains gateway attributes. */ -if (data_size) - cfg_size -=sizeof (cfg->gtw_cfg.config.attrs); + cfg_size = offsetof(struct avs_copier_cfg, gtw_cfg.config) + data_size;if (cfg_size >AVS_MAILBOX_SIZE )return -EINVAL ;
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 5/13 ASoC: Intel: avs: Fix ASRC module initialization
In reply to Cezary RojewskiThe ASRC module configuration consists of several reserved fields. Zero them out when initializing the module to avoid sending invalid data.
--- sound/soc/intel/avs/path.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/intel/avs/path.c +1 -0
@@ -365,6 +365,7 @@ static int avs_asrc_create(struct avs_dev *adev, struct avs_path_module *mod)struct avs_tplg_module *t = mod->template;struct avs_asrc_cfg cfg; +memset (&cfg,0 ,sizeof (cfg)); cfg.base.cpc = t->cfg_base->cpc; cfg.base.ibs = t->cfg_base->ibs; cfg.base.obs = t->cfg_base->obs;
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 6/13 ASoC: Intel: avs: Replace risky functions with safer variants
In reply to Cezary Rojewskistrscpy() and snprintf() are the recommended equivalents of their riskier friends.
--- sound/soc/intel/avs/loader.c | 4 ++-- sound/soc/intel/avs/pcm.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
sound/soc/intel/avs/loader.c +2 -2
@@ -535,7 +535,7 @@ int avs_dsp_load_libraries(struct avs_dev *adev, struct avs_tplg_library *libs,if (ret)return ret; -strncpy (adev->lib_names[id], man->name,AVS_LIB_NAME_SIZE ); +strscpy (adev->lib_names[id], man->name,AVS_LIB_NAME_SIZE ); id++; next_lib: i++;
@@ -698,7 +698,7 @@ int avs_dsp_first_boot_firmware(struct avs_dev *adev) }/* basefw always occupies slot 0 */ -strcpy (&adev->lib_names[0 ][0 ],"BASEFW" ); +strscpy (adev->lib_names[0 ],"BASEFW" ,AVS_LIB_NAME_SIZE );ida_init (&adev->ppl_ida);
sound/soc/intel/avs/pcm.c +1 -1
@@ -1420,7 +1420,7 @@ static void avs_component_hda_unregister_dais(struct snd_soc_component *componen mach =dev_get_platdata (component->card->dev); codec = mach->pdata; -sprintf (name,"%s-cpu" ,dev_name (&codec->core.dev)); +snprintf (name,sizeof (name),"%s-cpu" ,dev_name (&codec->core.dev));for_each_component_dais_safe (component, dai, save) {int stream;
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 7/13 ASoC: Intel: avs: Fix potential integer overflow
In reply to Cezary RojewskiWhile stream_tag for CLDMA on SKL-based platforms is always 1, function hda_cldma_setup() uses AZX_SD_CTL_STRM() macro which does:
stream_tag << 20
what combined with stream_tag type of 'unsigned int' generates a potential overflow issue. Update the field type to fix that.
--- sound/soc/intel/avs/cldma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/avs/cldma.c +1 -1
@@ -35,7 +35,7 @@ struct hda_cldma {unsigned int buffer_size;unsigned int num_periods; -unsigned int stream_tag; +unsigned char stream_tag;void __iomem *sd_addr;struct snd_dma_buffer dmab_data;
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 8/13 ASoC: Intel: avs: Test result of avs_get_module_entry()
In reply to Cezary RojewskiWhile PROBE_MOD_UUID is always part of the base AudioDSP firmware manifest, from maintenance point of view it is better to check the result.
--- sound/soc/intel/avs/probes.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
sound/soc/intel/avs/probes.c +9 -5
@@ -19,8 +19,11 @@ static int avs_dsp_init_probe(struct avs_dev *adev, union avs_connector_node_idstruct avs_probe_cfg cfg = {{0 }};struct avs_module_entry mentry;u8 dummy; +int ret; -avs_get_module_entry (adev, &AVS_PROBE_MOD_UUID , &mentry); + ret =avs_get_module_entry (adev, &AVS_PROBE_MOD_UUID , &mentry); +if (ret) +return ret;/* * Probe module uses no cycles, audio data format and input and output
@@ -39,11 +42,12 @@ static int avs_dsp_init_probe(struct avs_dev *adev, union avs_connector_node_idstatic void avs_dsp_delete_probe (struct avs_dev *adev) {struct avs_module_entry mentry; +int ret; -avs_get_module_entry (adev, &AVS_PROBE_MOD_UUID , &mentry); - -/* There is only ever one probe module instance. */ -avs_dsp_delete_module (adev, mentry.module_id,0 ,INVALID_PIPELINE_ID ,0 ); + ret =avs_get_module_entry (adev, &AVS_PROBE_MOD_UUID , &mentry); +if (!ret) +/* There is only ever one probe module instance. */ +avs_dsp_delete_module (adev, mentry.module_id,0 ,INVALID_PIPELINE_ID ,0 ); }static inline struct hdac_ext_stream *avs_compr_get_host_stream (struct snd_compr_stream *cstream)
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 9/13 ASoC: Intel: avs: Remove dead code
In reply to Cezary RojewskiThe result of list_next_entry()/list_last_entry() is never null.
--- sound/soc/intel/avs/path.c | 2 -- 1 file changed, 2 deletions(-)
sound/soc/intel/avs/path.c +0 -2
@@ -709,8 +709,6 @@ static int avs_path_pipeline_arm(struct avs_dev *adev,/* bind current module to next module on list */ source = mod; sink =list_next_entry (mod, node); -if (!source || !sink) -return -EINVAL ; ret =avs_ipc_bind (adev, source->module_id, source->instance_id, sink->module_id, sink->instance_id,0 ,0 );
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 10/13 ASoC: Intel: avs: Wake from D0ix when starting streaming
In reply to Cezary RojewskiIt is recommended to keep the DSP domain in full-power when starting DMA engines.
--- sound/soc/intel/avs/icl.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/soc/intel/avs/icl.c +4 -0
@@ -109,6 +109,10 @@ int avs_icl_log_buffer_offset(struct avs_dev *adev, u32 core)bool avs_icl_d0ix_toggle (struct avs_dev *adev,struct avs_ipc_msg *tx,bool wake) { +/* Full-power when starting DMA engines. */ +if (tx->glb.set_ppl_state.state ==AVS_PPL_STATE_RUNNING ) +return true; +/* Payload-less IPCs do not take part in d0ix toggling. */ return tx->size; }
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 11/13 ASoC: Intel: avs: Init debugfs before booting firmware
In reply to Cezary RojewskiWhen bringing up setups it's vital to have access to debug functionality even if firmware boot fails. As order of probe()ing operations is changed, update remove() procedure accordingly.
--- sound/soc/intel/avs/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/intel/avs/core.c +2 -2
@@ -209,6 +209,7 @@ static void avs_hda_probe_work(struct work_struct *work)snd_hdac_ext_bus_ppcap_enable (bus, true);snd_hdac_ext_bus_ppcap_int_enable (bus, true); +avs_debugfs_init (adev); ret =avs_dsp_first_boot_firmware (adev);if (ret <0 )
@@ -217,7 +218,6 @@ static void avs_hda_probe_work(struct work_struct *work) adev->nhlt =intel_nhlt_init (adev->dev);if (!adev->nhlt)dev_info (bus->dev,"platform has no NHLT\n" ); -avs_debugfs_init (adev);avs_register_all_boards (adev);
@@ -548,9 +548,9 @@ static void avs_pci_remove(struct pci_dev *pci)avs_unregister_all_boards (adev); -avs_debugfs_exit (adev);if (adev->nhlt)intel_nhlt_free (adev->nhlt); +avs_debugfs_exit (adev);if (avs_platattr_test (adev,CLDMA ))hda_cldma_free (&code_loader);
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 12/13 ASoC: Intel: avs: Add assert_static to guarantee ABI sizes
In reply to Cezary RojewskiFrom: Amadeusz Sławiński <[email protected]>
In order to make sure that IPC interface is stable use assert_static to check union and struct sizes that describe communication interface.
--- sound/soc/intel/avs/avs.h | 1 + sound/soc/intel/avs/icl.c | 3 +++ sound/soc/intel/avs/loader.c | 2 ++ sound/soc/intel/avs/messages.h | 43 ++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+)
sound/soc/intel/avs/avs.h +1 -0
@@ -381,6 +381,7 @@ struct avs_apl_log_buffer_layout {u32 write_ptr;u8 buffer[]; } __packed; +static_assert (sizeof (struct avs_apl_log_buffer_layout ) ==8 );#define avs_apl_log_payload_size (adev) \ (avs_log_buffer_size(adev) - sizeof(struct avs_apl_log_buffer_layout))
sound/soc/intel/avs/icl.c +3 -0
@@ -52,12 +52,14 @@ union avs_icl_memwnd2_slot_type { u32 type:24; }; } __packed; +static_assert (sizeof (union avs_icl_memwnd2_slot_type ) ==4 );struct avs_icl_memwnd2_desc {u32 resource_id;union avs_icl_memwnd2_slot_type slot_id;u32 vma; } __packed; +static_assert (sizeof (struct avs_icl_memwnd2_desc ) ==12 );#define AVS_ICL_MEMWND2_SLOTS_COUNT 15
@@ -68,6 +70,7 @@ struct avs_icl_memwnd2 { };u8 slot_array[AVS_ICL_MEMWND2_SLOTS_COUNT ][SZ_4K ]; } __packed; +static_assert (sizeof (struct avs_icl_memwnd2 ) ==65536 );#define AVS_ICL_SLOT_UNUSED \ ((union avs_icl_memwnd2_slot_type) { 0x00000000U })
sound/soc/intel/avs/loader.c +2 -0
@@ -56,6 +56,7 @@ struct avs_fw_manifest {u32 feature_mask;struct avs_fw_version version; } __packed; +static_assert (sizeof (struct avs_fw_manifest ) ==36 );struct avs_fw_ext_manifest {u32 id;
@@ -64,6 +65,7 @@ struct avs_fw_ext_manifest {u16 version_minor;u32 entries; } __packed; +static_assert (sizeof (struct avs_fw_ext_manifest ) ==16 );static int avs_fw_ext_manifest_strip (struct firmware *fw) {
sound/soc/intel/avs/messages.h +43 -0
293 lines not on this page · raw message
Signature · 1 line
2.25.1
kernel test robot
build botRe: [PATCH 12/13] ASoC: Intel: avs: Add assert_static to guarantee ABI sizes
kernel test robot noticed the following build errors:
Hi Cezary,
kernel test robot noticed the following build errors:
[auto build test ERROR on broonie-sound/for-next]
[also build test ERROR on tiwai-sound/for-next tiwai-sound/for-linus linus/master v6.9-rc2 next-20240405] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Cezary-Rojewski/ASoC-Intel-avs-Restore-stream-decoupling-on-prepare/20240405-171544 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next patch link: https://lore.kernel.org/r/20240405090929.1184068-13-cezary.rojewski%40intel.com patch subject: [PATCH 12/13] ASoC: Intel: avs: Add assert_static to guarantee ABI sizes config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20240406/[email protected]/config) compiler: alpha-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240406/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from include/linux/init.h:5,
from include/linux/printk.h:6,
from include/asm-generic/bug.h:22,
from arch/alpha/include/asm/bug.h:23, from include/linux/bug.h:5,
from include/linux/thread_info.h:13, from include/asm-generic/preempt.h:5, from ./arch/alpha/include/generated/asm/preempt.h:1, from include/linux/preempt.h:79,
from include/linux/spinlock.h:56,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:7,
from include/linux/slab.h:16,
from sound/soc/intel/avs/icl.c:9:
>> include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct avs_icl_memwnd2) == 65536"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
sound/soc/intel/avs/icl.c:73:1: note: in expansion of macro 'static_assert'
73 | static_assert(sizeof(struct avs_icl_memwnd2) == 65536);
| ^~~~~~~~~~~~~vim +78 include/linux/build_bug.h
bc6245e5efd70c Ian Abbott 2017-07-10 60 6bab69c65013be Rasmus Villemoes 2019-03-07 61 /** 6bab69c65013be Rasmus Villemoes 2019-03-07 62 * static_assert - check integer constant expression at build time 6bab69c65013be Rasmus Villemoes 2019-03-07 63 * 6bab69c65013be Rasmus Villemoes 2019-03-07 64 * static_assert() is a wrapper for the C11 _Static_assert, with a 6bab69c65013be Rasmus Villemoes 2019-03-07 65 * little macro magic to make the message optional (defaulting to the 6bab69c65013be Rasmus Villemoes 2019-03-07 66 * stringification of the tested expression). 6bab69c65013be Rasmus Villemoes 2019-03-07 67 * 6bab69c65013be Rasmus Villemoes 2019-03-07 68 * Contrary to BUILD_BUG_ON(), static_assert() can be used at global 6bab69c65013be Rasmus Villemoes 2019-03-07 69 * scope, but requires the expression to be an integer constant 6bab69c65013be Rasmus Villemoes 2019-03-07 70 * expression (i.e., it is not enough that __builtin_constant_p() is 6bab69c65013be Rasmus Villemoes 2019-03-07 71 * true for expr). 6bab69c65013be Rasmus Villemoes 2019-03-07 72 * 6bab69c65013be Rasmus Villemoes 2019-03-07 73 * Also note that BUILD_BUG_ON() fails the build if the condition is 6bab69c65013be Rasmus Villemoes 2019-03-07 74 * true, while static_assert() fails the build if the expression is 6bab69c65013be Rasmus Villemoes 2019-03-07 75 * false. 6bab69c65013be Rasmus Villemoes 2019-03-07 76 */ 6bab69c65013be Rasmus Villemoes 2019-03-07 77 #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
6bab69c65013be Rasmus Villemoes 2019-03-07 @78 #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) 6bab69c65013be Rasmus Villemoes 2019-03-07 7907a368b3f55a79 Maxim Levitsky 2022-10-25 80
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Cezary Rojewski
maintainerPATCH 13/13 ASoC: Intel: avs: Rule invalid buffer and period sizes out
In reply to Cezary RojewskiWhile HDAudio controller supports buffer packets up to 128 bytes low, audio format shall be taken into consideration when calculating buffer and period sizes to avoid undesired xruns.
As *_size in ALSA terms means frames (channels times bit-depth-bytes), hw_rules can calculate minimal buffer and period sizes solely from sample rate and the number of milliseconds commonly used on the AudioDSP firmware side.
--- sound/soc/intel/avs/pcm.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
sound/soc/intel/avs/pcm.c +28 -0
@@ -457,6 +457,26 @@ static const struct snd_pcm_hw_constraint_list hw_rates = {const struct snd_soc_dai_ops avs_dai_fe_ops; +static int hw_rule_param_size (struct snd_pcm_hw_params *params,struct snd_pcm_hw_rule *rule) +{ +struct snd_interval *interval =hw_param_interval (params, rule->var); +struct snd_interval to; + +snd_interval_any (&to); + to.integer = interval->integer; + to.max = interval->max; +/* +* Commonly 2ms buffer size is used in HDA scenarios whereas 4ms is used +* when streaming through GPDMA. Align to the latter to account for both. +*/ + to.min =params_rate (params) /1000 *4 ; + +if (rule->var ==SNDRV_PCM_HW_PARAM_PERIOD_SIZE ) + to.min /=params_periods (params); + +return snd_interval_refine (interval, &to); +} +static int avs_dai_fe_startup (struct snd_pcm_substream *substream,struct snd_soc_dai *dai) {struct snd_pcm_runtime *runtime = substream->runtime;
@@ -492,6 +512,14 @@ static int avs_dai_fe_startup(struct snd_pcm_substream *substream, struct snd_soif (ret <0 ) goto err; +/* Adjust buffer and period size based on the audio format. */ +snd_pcm_hw_rule_add (runtime,0 ,SNDRV_PCM_HW_PARAM_BUFFER_SIZE , hw_rule_param_size,NULL , +SNDRV_PCM_HW_PARAM_FORMAT ,SNDRV_PCM_HW_PARAM_CHANNELS , +SNDRV_PCM_HW_PARAM_RATE ,-1 ); +snd_pcm_hw_rule_add (runtime,0 ,SNDRV_PCM_HW_PARAM_PERIOD_SIZE , hw_rule_param_size,NULL , +SNDRV_PCM_HW_PARAM_FORMAT ,SNDRV_PCM_HW_PARAM_CHANNELS , +SNDRV_PCM_HW_PARAM_RATE ,-1 ); +snd_pcm_set_sync (substream); dev_dbg(dai->dev, "%s fe STARTUP tag %d str %p",
Signature · 1 line
2.25.1
Mark Brown
maintainerQuoted 9 lines · Cezary Rojewski
Set of changes targeting the avs-driver only. No new features, patchset either fixes or fortifies existing code.
Patchset starts off with a fix for debugbility on ICL+ platforms which I have forgotten to fixup when providing support for these initially. The next two address copier module initialization, most importantly, silence the gcc 'field-spanning write' false-positive.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/13] ASoC: Intel: avs: Restore stream decoupling on prepare
commit: 680507581e025d16a0b6d3782603ca8c598fbe2b
[02/13] ASoC: Intel: avs: Fix debug-slot offset calculation
commit: c91b692781c1839fcc389b2a9120e46593c6424b
[03/13] ASoC: Intel: avs: Silence false-positive memcpy() warnings
commit: 6dd68c2da44d92c25b323bcc2603421463437a64
[04/13] ASoC: Intel: avs: Fix config_length for config-less copiers
commit: beeeee9686affef32ee04d8ae30db8c53cbc7aee
[05/13] ASoC: Intel: avs: Fix ASRC module initialization
commit: 9d2e26f31c7cc3fa495c423af9b4902ec0dc7be3
[06/13] ASoC: Intel: avs: Replace risky functions with safer variants
commit: 47714847592b574ff594ceca7ebe0ada70dbac3c
[07/13] ASoC: Intel: avs: Fix potential integer overflow
commit: c7e832cabe635df47c2bf6df7801e97bf3045b1e
[08/13] ASoC: Intel: avs: Test result of avs_get_module_entry()
commit: 41bf4525fadb3d8df3860420d6ac9025c51a3bac
[09/13] ASoC: Intel: avs: Remove dead code
commit: d58275f474b4a27b4e97839ffe8d9fe55c0cc40a
[10/13] ASoC: Intel: avs: Wake from D0ix when starting streaming
commit: 30df76bbcb59254ce646477e3e05f00021a10117
[11/13] ASoC: Intel: avs: Init debugfs before booting firmware
commit: ff0aefe2d217ce6fec6487b225737b2019eb88c0
[12/13] ASoC: Intel: avs: Add assert_static to guarantee ABI sizes
commit: c2b10acb62c195db2c976d614d9d8092ad6339ae
[13/13] ASoC: Intel: avs: Rule invalid buffer and period sizes out
commit: 9a385993504e47a0fd6fd34b5384827b4abdee60All 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