]> git.hungrycats.org Git - linux/commitdiff
ASoC: SOF: Intel: hda-pcm: Limit the maximum number of periods by MAX_BDL_ENTRIES
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Thu, 4 Jul 2024 09:01:06 +0000 (11:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jul 2024 07:53:40 +0000 (09:53 +0200)
[ Upstream commit 82bb8db96610b558920b8c57cd250ec90567d79b ]

The HDaudio specification Section 3.6.2 limits the number of BDL entries to 256.

Make sure we don't allow more periods than this normative value.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://patch.msgid.link/20240704090106.371497-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/sof/intel/hda-pcm.c

index d7b446f3f973e3d532d8eaef241aac2f3a30a54d..8b5fbbc777bd4f9131c710d3d7c1de0f4fadeb12 100644 (file)
@@ -254,6 +254,12 @@ int hda_dsp_pcm_open(struct snd_sof_dev *sdev,
        snd_pcm_hw_constraint_integer(substream->runtime,
                                      SNDRV_PCM_HW_PARAM_PERIODS);
 
+       /* Limit the maximum number of periods to not exceed the BDL entries count */
+       if (runtime->hw.periods_max > HDA_DSP_MAX_BDL_ENTRIES)
+               snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS,
+                                            runtime->hw.periods_min,
+                                            HDA_DSP_MAX_BDL_ENTRIES);
+
        /* Only S16 and S32 supported by HDA hardware when used without DSP */
        if (sdev->dspless_mode_selected)
                snd_pcm_hw_constraint_mask64(substream->runtime, SNDRV_PCM_HW_PARAM_FORMAT,