Skip to content

Commit a4b8152

Browse files
kv2019ibroonie
authored andcommitted
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>
1 parent 18dbff4 commit a4b8152

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sound/soc/sof/ipc4-pcm.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ struct sof_ipc4_pcm_stream_priv {
5959
*/
6060
#define DELAY_BOUNDARY U32_MAX
6161

62+
#define DELAY_MAX (DELAY_BOUNDARY >> 1)
63+
6264
static inline struct sof_ipc4_timestamp_info *
6365
sof_ipc4_sps_to_time_info(struct snd_sof_pcm_stream *sps)
6466
{
@@ -1266,6 +1268,13 @@ static int sof_ipc4_pcm_pointer(struct snd_soc_component *component,
12661268
else
12671269
time_info->delay = head_cnt - tail_cnt;
12681270

1271+
if (time_info->delay > DELAY_MAX) {
1272+
spcm_dbg_ratelimited(spcm, substream->stream,
1273+
"inaccurate delay, host %llu dai_cnt %llu",
1274+
host_cnt, dai_cnt);
1275+
time_info->delay = 0;
1276+
}
1277+
12691278
/*
12701279
* Convert the host byte counter to PCM pointer which wraps in buffer
12711280
* and it is in frames

0 commit comments

Comments
 (0)