Commit 396b9079 authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

ASoC: soc-pcm: Shrink stack frame for __soc_pcm_hw_params

Commit ac950278 ("ASoC: add N cpus to M codecs dai link support")
added an additional local params in __soc_pcm_hw_params, for the CPU
side of the DAI. The snd_pcm_hw_params struct is pretty large (604
bytes) and keeping two local copies of it can make the stack frame
really large.

It is worth noting the variables are in separate code blocks so for
some optimisation levels in the compiler these will get automatically
combined keeping the stack frame reasonable. But better to manually
combine them to cover all cases.

Add a single local variable for __soc_pcm_hw_params and use in both
loops to shrink the stack frame.
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230908085920.2906359-1-ckeepax@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent d7e47e32
......@@ -985,6 +985,7 @@ static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd,
{
struct snd_soc_dai *cpu_dai;
struct snd_soc_dai *codec_dai;
struct snd_pcm_hw_params tmp_params;
int i, ret = 0;
snd_soc_dpcm_mutex_assert_held(rtd);
......@@ -998,7 +999,6 @@ static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd,
goto out;
for_each_rtd_codec_dais(rtd, i, codec_dai) {
struct snd_pcm_hw_params codec_params;
unsigned int tdm_mask = snd_soc_dai_tdm_mask_get(codec_dai, substream->stream);
/*
......@@ -1019,23 +1019,22 @@ static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd,
continue;
/* copy params for each codec */
codec_params = *params;
tmp_params = *params;
/* fixup params based on TDM slot masks */
if (tdm_mask)
soc_pcm_codec_params_fixup(&codec_params, tdm_mask);
soc_pcm_codec_params_fixup(&tmp_params, tdm_mask);
ret = snd_soc_dai_hw_params(codec_dai, substream,
&codec_params);
&tmp_params);
if(ret < 0)
goto out;
soc_pcm_set_dai_params(codec_dai, &codec_params);
snd_soc_dapm_update_dai(substream, &codec_params, codec_dai);
soc_pcm_set_dai_params(codec_dai, &tmp_params);
snd_soc_dapm_update_dai(substream, &tmp_params, codec_dai);
}
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
struct snd_pcm_hw_params cpu_params;
unsigned int ch_mask = 0;
int j;
......@@ -1047,7 +1046,7 @@ static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd,
continue;
/* copy params for each cpu */
cpu_params = *params;
tmp_params = *params;
if (!rtd->dai_link->codec_ch_maps)
goto hw_params;
......@@ -1062,16 +1061,16 @@ static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd,
/* fixup cpu channel number */
if (ch_mask)
soc_pcm_codec_params_fixup(&cpu_params, ch_mask);
soc_pcm_codec_params_fixup(&tmp_params, ch_mask);
hw_params:
ret = snd_soc_dai_hw_params(cpu_dai, substream, &cpu_params);
ret = snd_soc_dai_hw_params(cpu_dai, substream, &tmp_params);
if (ret < 0)
goto out;
/* store the parameters for each DAI */
soc_pcm_set_dai_params(cpu_dai, &cpu_params);
snd_soc_dapm_update_dai(substream, &cpu_params, cpu_dai);
soc_pcm_set_dai_params(cpu_dai, &tmp_params);
snd_soc_dapm_update_dai(substream, &tmp_params, cpu_dai);
}
ret = snd_soc_pcm_component_hw_params(substream, params);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment