Skip to content

Commit a935b3f

Browse files
andy-shevbroonie
authored andcommitted
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 <[email protected]> Acked-by: Peter Ujfalusi <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 87fa872 commit a935b3f

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

sound/soc/sof/ipc4-topology.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88
//
99
#include <linux/bitfield.h>
10+
#include <linux/cleanup.h>
1011
#include <uapi/sound/sof/tokens.h>
1112
#include <sound/pcm_params.h>
1213
#include <sound/sof/ext_manifest4.h>
@@ -1807,8 +1808,8 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
18071808
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
18081809
struct sof_ipc4_copier_data *copier_data;
18091810
int input_fmt_index, output_fmt_index;
1810-
struct snd_pcm_hw_params ref_params;
18111811
struct sof_ipc4_copier *ipc4_copier;
1812+
struct snd_pcm_hw_params *ref_params __free(kfree) = NULL;
18121813
struct snd_sof_dai *dai;
18131814
u32 gtw_cfg_config_length;
18141815
u32 dma_config_tlv_size = 0;
@@ -1885,9 +1886,11 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
18851886
* for capture.
18861887
*/
18871888
if (dir == SNDRV_PCM_STREAM_PLAYBACK)
1888-
ref_params = *fe_params;
1889+
ref_params = kmemdup(fe_params, sizeof(*ref_params), GFP_KERNEL);
18891890
else
1890-
ref_params = *pipeline_params;
1891+
ref_params = kmemdup(pipeline_params, sizeof(*ref_params), GFP_KERNEL);
1892+
if (!ref_params)
1893+
return -ENOMEM;
18911894

18921895
copier_data->gtw_cfg.node_id &= ~SOF_IPC4_NODE_INDEX_MASK;
18931896
copier_data->gtw_cfg.node_id |=
@@ -1924,8 +1927,11 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
19241927
* In case of capture the ref_params returned will be used to
19251928
* find the input configuration of the copier.
19261929
*/
1927-
ref_params = *fe_params;
1928-
ret = sof_ipc4_prepare_dai_copier(sdev, dai, &ref_params, dir);
1930+
ref_params = kmemdup(fe_params, sizeof(*ref_params), GFP_KERNEL);
1931+
if (!ref_params)
1932+
return -ENOMEM;
1933+
1934+
ret = sof_ipc4_prepare_dai_copier(sdev, dai, ref_params, dir);
19291935
if (ret < 0)
19301936
return ret;
19311937

@@ -1934,7 +1940,7 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
19341940
* input configuration of the copier.
19351941
*/
19361942
if (dir == SNDRV_PCM_STREAM_PLAYBACK)
1937-
ref_params = *pipeline_params;
1943+
memcpy(ref_params, pipeline_params, sizeof(*ref_params));
19381944

19391945
break;
19401946
}
@@ -1946,7 +1952,10 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
19461952
ipc4_copier = (struct sof_ipc4_copier *)swidget->private;
19471953
copier_data = &ipc4_copier->data;
19481954
available_fmt = &ipc4_copier->available_fmt;
1949-
ref_params = *pipeline_params;
1955+
1956+
ref_params = kmemdup(pipeline_params, sizeof(*ref_params), GFP_KERNEL);
1957+
if (!ref_params)
1958+
return -ENOMEM;
19501959

19511960
break;
19521961
}
@@ -1959,7 +1968,7 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
19591968
/* set input and output audio formats */
19601969
input_fmt_index = sof_ipc4_init_input_audio_fmt(sdev, swidget,
19611970
&copier_data->base_config,
1962-
&ref_params, available_fmt);
1971+
ref_params, available_fmt);
19631972
if (input_fmt_index < 0)
19641973
return input_fmt_index;
19651974

0 commit comments

Comments
 (0)