summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Vehmanen <kai.vehmanen@linux.intel.com>2025-10-02 10:47:18 +0300
committerMark Brown <broonie@kernel.org>2025-10-03 12:39:48 +0100
commita4b8152c09a832b089864e5e209a479bb0fb5cc9 (patch)
tree55e5a28740b09e24331f7cf4cd2c2e02c7a4d9e9
parent18dbff48a1ea58100f9fa6886cfef286a96a5fb0 (diff)
ASoC: SOF: ipc4-pcm: do not report invalid delay values
Add a sanity check for the calculated delay value before reporting it to the application. If the value is clearly invalid, emit a rate limited warning to kernel log and return a zero delay. This can occur e.g if the host or link DMA hits a buffer over/underrun condition. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://patch.msgid.link/20251002074719.2084-5-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/sof/ipc4-pcm.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sound/soc/sof/ipc4-pcm.c b/sound/soc/sof/ipc4-pcm.c
index 9d29d2e56c00..c700972d32ed 100644
--- a/sound/soc/sof/ipc4-pcm.c
+++ b/sound/soc/sof/ipc4-pcm.c
@@ -59,6 +59,8 @@ struct sof_ipc4_pcm_stream_priv {
*/
#define DELAY_BOUNDARY U32_MAX
+#define DELAY_MAX (DELAY_BOUNDARY >> 1)
+
static inline struct sof_ipc4_timestamp_info *
sof_ipc4_sps_to_time_info(struct snd_sof_pcm_stream *sps)
{
@@ -1266,6 +1268,13 @@ static int sof_ipc4_pcm_pointer(struct snd_soc_component *component,
else
time_info->delay = head_cnt - tail_cnt;
+ if (time_info->delay > DELAY_MAX) {
+ spcm_dbg_ratelimited(spcm, substream->stream,
+ "inaccurate delay, host %llu dai_cnt %llu",
+ host_cnt, dai_cnt);
+ time_info->delay = 0;
+ }
+
/*
* Convert the host byte counter to PCM pointer which wraps in buffer
* and it is in frames