Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: SOF: ipc4-topology: Allocate ref_params on stack

Currently the compiler (clang 19.1.7) is not happy about the size of
the stack frame in sof_ipc4_prepare_copier_module:

sound/soc/sof/ipc4-topology.c:1800:1: error: stack frame size (1288) exceeds limit (1024) in 'sof_ipc4_prepare_copier_module' [-Werror,-Wframe-larger-than]
1800 | sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
| ^

Work around this by allocating ref_params on stack, as it looks the biggest
variable on stack right now.

Note, this only happens when compile for 32-bit machines (x86_32 in my case).

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://patch.msgid.link/20250312160516.3864295-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Andy Shevchenko and committed by
Mark Brown
a935b3f9 87fa872a

+17 -8
+17 -8
sound/soc/sof/ipc4-topology.c
··· 7 7 // 8 8 // 9 9 #include <linux/bitfield.h> 10 + #include <linux/cleanup.h> 10 11 #include <uapi/sound/sof/tokens.h> 11 12 #include <sound/pcm_params.h> 12 13 #include <sound/sof/ext_manifest4.h> ··· 1808 1807 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); 1809 1808 struct sof_ipc4_copier_data *copier_data; 1810 1809 int input_fmt_index, output_fmt_index; 1811 - struct snd_pcm_hw_params ref_params; 1812 1810 struct sof_ipc4_copier *ipc4_copier; 1811 + struct snd_pcm_hw_params *ref_params __free(kfree) = NULL; 1813 1812 struct snd_sof_dai *dai; 1814 1813 u32 gtw_cfg_config_length; 1815 1814 u32 dma_config_tlv_size = 0; ··· 1886 1885 * for capture. 1887 1886 */ 1888 1887 if (dir == SNDRV_PCM_STREAM_PLAYBACK) 1889 - ref_params = *fe_params; 1888 + ref_params = kmemdup(fe_params, sizeof(*ref_params), GFP_KERNEL); 1890 1889 else 1891 - ref_params = *pipeline_params; 1890 + ref_params = kmemdup(pipeline_params, sizeof(*ref_params), GFP_KERNEL); 1891 + if (!ref_params) 1892 + return -ENOMEM; 1892 1893 1893 1894 copier_data->gtw_cfg.node_id &= ~SOF_IPC4_NODE_INDEX_MASK; 1894 1895 copier_data->gtw_cfg.node_id |= ··· 1927 1924 * In case of capture the ref_params returned will be used to 1928 1925 * find the input configuration of the copier. 1929 1926 */ 1930 - ref_params = *fe_params; 1931 - ret = sof_ipc4_prepare_dai_copier(sdev, dai, &ref_params, dir); 1927 + ref_params = kmemdup(fe_params, sizeof(*ref_params), GFP_KERNEL); 1928 + if (!ref_params) 1929 + return -ENOMEM; 1930 + 1931 + ret = sof_ipc4_prepare_dai_copier(sdev, dai, ref_params, dir); 1932 1932 if (ret < 0) 1933 1933 return ret; 1934 1934 ··· 1940 1934 * input configuration of the copier. 1941 1935 */ 1942 1936 if (dir == SNDRV_PCM_STREAM_PLAYBACK) 1943 - ref_params = *pipeline_params; 1937 + memcpy(ref_params, pipeline_params, sizeof(*ref_params)); 1944 1938 1945 1939 break; 1946 1940 } ··· 1952 1946 ipc4_copier = (struct sof_ipc4_copier *)swidget->private; 1953 1947 copier_data = &ipc4_copier->data; 1954 1948 available_fmt = &ipc4_copier->available_fmt; 1955 - ref_params = *pipeline_params; 1949 + 1950 + ref_params = kmemdup(pipeline_params, sizeof(*ref_params), GFP_KERNEL); 1951 + if (!ref_params) 1952 + return -ENOMEM; 1956 1953 1957 1954 break; 1958 1955 } ··· 1968 1959 /* set input and output audio formats */ 1969 1960 input_fmt_index = sof_ipc4_init_input_audio_fmt(sdev, swidget, 1970 1961 &copier_data->base_config, 1971 - &ref_params, available_fmt); 1962 + ref_params, available_fmt); 1972 1963 if (input_fmt_index < 0) 1973 1964 return input_fmt_index; 1974 1965