From: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
To: lgirdwood@gmail.com, broonie@kernel.org
Cc: linux-sound@vger.kernel.org, kai.vehmanen@linux.intel.com,
ranjani.sridharan@linux.intel.com,
yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev,
stable@vger.kernel.org
Subject: [PATCH 4/5] ASoC: SOF: ipc4-pcm: do not report invalid delay values
Date: Thu, 2 Oct 2025 10:47:18 +0300 [thread overview]
Message-ID: <20251002074719.2084-5-peter.ujfalusi@linux.intel.com> (raw)
In-Reply-To: <20251002074719.2084-1-peter.ujfalusi@linux.intel.com>
From: Kai Vehmanen <kai.vehmanen@linux.intel.com>
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>
---
sound/soc/sof/ipc4-pcm.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/sound/soc/sof/ipc4-pcm.c b/sound/soc/sof/ipc4-pcm.c
index 9542c428daa4..6d81969e181c 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
--
2.51.0
next prev parent reply other threads:[~2025-10-02 7:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-02 7:47 [PATCH 0/5] ASoC: SOF: ipc4: Fixes for delay reporting Peter Ujfalusi
2025-10-02 7:47 ` [PATCH 1/5] ASoC: SOF: ipc4-pcm: fix delay calculation when DSP resamples Peter Ujfalusi
2025-10-02 7:47 ` [PATCH 2/5] ASoC: SOF: ipc4-pcm: fix start offset calculation for chain DMA Peter Ujfalusi
2025-10-02 7:47 ` [PATCH 3/5] ASoC: SOF: sof-audio: add dev_dbg_ratelimited wrapper Peter Ujfalusi
2025-10-02 7:47 ` Peter Ujfalusi [this message]
2025-10-02 7:47 ` [PATCH 5/5] ASoC: SOF: Intel: Read the LLP via the associated Link DMA channel Peter Ujfalusi
2025-10-02 17:06 ` (subset) [PATCH 0/5] ASoC: SOF: ipc4: Fixes for delay reporting Mark Brown
2025-10-03 14:33 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251002074719.2084-5-peter.ujfalusi@linux.intel.com \
--to=peter.ujfalusi@linux.intel.com \
--cc=broonie@kernel.org \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-sound@vger.kernel.org \
--cc=pierre-louis.bossart@linux.dev \
--cc=ranjani.sridharan@linux.intel.com \
--cc=stable@vger.kernel.org \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox