* [PATCH 0/2] ALSA: compress: Robustness improvements in pointer() handling
@ 2026-04-01 16:57 Mark Brown
2026-04-01 16:57 ` [PATCH 1/2] ALSA: compress: Refuse to update timestamps for unconfigured streams Mark Brown
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Mark Brown @ 2026-04-01 16:57 UTC (permalink / raw)
To: Vinod Koul, Jaroslav Kysela, Takashi Iwai
Cc: Péter Ujfalusi, linux-sound, linux-kernel, Mark Brown
While looking at an ASoC driver I happened to notice a divide by zero on
a pointer operation, discussion of which with Péter Ujfalusi identified
several other issues in the handling of pointer operations in the core.
This isn't a comprehensive review, it's just fixing up issues that
happened to be noticed.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
Mark Brown (2):
ALSA: compress: Refuse to update timestamps for unconfigured streams
ALSA: compress: Pay attention if drivers error out retrieving pointers
sound/core/compress_offload.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
---
base-commit: 7aaa8047eafd0bd628065b15757d9b48c5f9c07d
change-id: 20260330-alsa-unconfigured-tstamp-6886ed04cf22
Best regards,
--
Mark Brown <broonie@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] ALSA: compress: Refuse to update timestamps for unconfigured streams
2026-04-01 16:57 [PATCH 0/2] ALSA: compress: Robustness improvements in pointer() handling Mark Brown
@ 2026-04-01 16:57 ` Mark Brown
2026-04-01 16:57 ` [PATCH 2/2] ALSA: compress: Pay attention if drivers error out retrieving pointers Mark Brown
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-04-01 16:57 UTC (permalink / raw)
To: Vinod Koul, Jaroslav Kysela, Takashi Iwai
Cc: Péter Ujfalusi, linux-sound, linux-kernel, Mark Brown
There are a number of mechanisms, including the userspace accessible
timestamp and buffer availability ioctl()s, which allow us to trigger
a timestamp update on a stream before it has been configured. Since
drivers might rely on stream configuration for reporting of pcm_io_frames,
including potentially doing a division by the number of channels, and
these operations are not meaningful for an unconfigured stream reject
attempts to read timestamps before any configuration is done.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/core/compress_offload.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index fdba6e4b25fd..67b3b1a3b526 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -192,6 +192,14 @@ static int snd_compr_update_tstamp(struct snd_compr_stream *stream,
{
if (!stream->ops->pointer)
return -ENOTSUPP;
+
+ switch (stream->runtime->state) {
+ case SNDRV_PCM_STATE_OPEN:
+ return -EBADFD;
+ default:
+ break;
+ }
+
stream->ops->pointer(stream, tstamp);
pr_debug("dsp consumed till %u total %llu bytes\n", tstamp->byte_offset,
tstamp->copied_total);
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] ALSA: compress: Pay attention if drivers error out retrieving pointers
2026-04-01 16:57 [PATCH 0/2] ALSA: compress: Robustness improvements in pointer() handling Mark Brown
2026-04-01 16:57 ` [PATCH 1/2] ALSA: compress: Refuse to update timestamps for unconfigured streams Mark Brown
@ 2026-04-01 16:57 ` Mark Brown
2026-04-02 3:35 ` [PATCH 0/2] ALSA: compress: Robustness improvements in pointer() handling Vinod Koul
2026-04-02 9:15 ` Takashi Iwai
3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-04-01 16:57 UTC (permalink / raw)
To: Vinod Koul, Jaroslav Kysela, Takashi Iwai
Cc: Péter Ujfalusi, linux-sound, linux-kernel, Mark Brown
Currently we have a return code on the driver pointer operation but the
core ignores that. Let's start paying attention.
Reported-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/core/compress_offload.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 67b3b1a3b526..c91547451311 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -190,6 +190,8 @@ snd_compr_tstamp32_from_64(struct snd_compr_tstamp *tstamp32,
static int snd_compr_update_tstamp(struct snd_compr_stream *stream,
struct snd_compr_tstamp64 *tstamp)
{
+ int ret;
+
if (!stream->ops->pointer)
return -ENOTSUPP;
@@ -200,7 +202,9 @@ static int snd_compr_update_tstamp(struct snd_compr_stream *stream,
break;
}
- stream->ops->pointer(stream, tstamp);
+ ret = stream->ops->pointer(stream, tstamp);
+ if (ret != 0)
+ return ret;
pr_debug("dsp consumed till %u total %llu bytes\n", tstamp->byte_offset,
tstamp->copied_total);
if (stream->direction == SND_COMPRESS_PLAYBACK)
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] ALSA: compress: Robustness improvements in pointer() handling
2026-04-01 16:57 [PATCH 0/2] ALSA: compress: Robustness improvements in pointer() handling Mark Brown
2026-04-01 16:57 ` [PATCH 1/2] ALSA: compress: Refuse to update timestamps for unconfigured streams Mark Brown
2026-04-01 16:57 ` [PATCH 2/2] ALSA: compress: Pay attention if drivers error out retrieving pointers Mark Brown
@ 2026-04-02 3:35 ` Vinod Koul
2026-04-02 9:15 ` Takashi Iwai
3 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2026-04-02 3:35 UTC (permalink / raw)
To: Mark Brown
Cc: Jaroslav Kysela, Takashi Iwai, Péter Ujfalusi, linux-sound,
linux-kernel
On 01-04-26, 17:57, Mark Brown wrote:
> While looking at an ASoC driver I happened to notice a divide by zero on
> a pointer operation, discussion of which with Péter Ujfalusi identified
> several other issues in the handling of pointer operations in the core.
> This isn't a comprehensive review, it's just fixing up issues that
> happened to be noticed.
>
Acked-by: Vinod Koul <vkoul@kernel.org>
--
~Vinod
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] ALSA: compress: Robustness improvements in pointer() handling
2026-04-01 16:57 [PATCH 0/2] ALSA: compress: Robustness improvements in pointer() handling Mark Brown
` (2 preceding siblings ...)
2026-04-02 3:35 ` [PATCH 0/2] ALSA: compress: Robustness improvements in pointer() handling Vinod Koul
@ 2026-04-02 9:15 ` Takashi Iwai
3 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2026-04-02 9:15 UTC (permalink / raw)
To: Mark Brown
Cc: Vinod Koul, Jaroslav Kysela, Takashi Iwai, Péter Ujfalusi,
linux-sound, linux-kernel
On Wed, 01 Apr 2026 18:57:33 +0200,
Mark Brown wrote:
>
> While looking at an ASoC driver I happened to notice a divide by zero on
> a pointer operation, discussion of which with Péter Ujfalusi identified
> several other issues in the handling of pointer operations in the core.
> This isn't a comprehensive review, it's just fixing up issues that
> happened to be noticed.
>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
> Mark Brown (2):
> ALSA: compress: Refuse to update timestamps for unconfigured streams
> ALSA: compress: Pay attention if drivers error out retrieving pointers
As it's at a quite late stage, I applied to for-next branch for 7.1.
thanks,
Takashi
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-02 9:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-01 16:57 [PATCH 0/2] ALSA: compress: Robustness improvements in pointer() handling Mark Brown
2026-04-01 16:57 ` [PATCH 1/2] ALSA: compress: Refuse to update timestamps for unconfigured streams Mark Brown
2026-04-01 16:57 ` [PATCH 2/2] ALSA: compress: Pay attention if drivers error out retrieving pointers Mark Brown
2026-04-02 3:35 ` [PATCH 0/2] ALSA: compress: Robustness improvements in pointer() handling Vinod Koul
2026-04-02 9:15 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox