From: Marek Vasut <marex@nabladev.com>
To: linux-sound@vger.kernel.org
Cc: Marek Vasut <marex@nabladev.com>,
Jaroslav Kysela <perex@perex.cz>,
Lars-Peter Clausen <lars@metafoo.de>,
Mark Brown <broonie@kernel.org>, Michal Simek <monstr@monstr.eu>,
Takashi Iwai <tiwai@suse.com>
Subject: [RFC][PATCH] ALSA: pcm_dmaengine: Use more shorter periods for SEGMENT granularity PCM DMA
Date: Fri, 27 Mar 2026 15:29:43 +0100 [thread overview]
Message-ID: <20260327143014.54867-1-marex@nabladev.com> (raw)
The segment granularity PCM DMA updates PCM pointer at the end of every
segment. In case the segments are too long, which happens with pipewire,
it may happen that pcm_lib wait_for_avail() will time out while waiting
for PCM pointer update and playback will fail with IO error.
In case of SEGMENT granularity, use 8 shorter segments over the default
2 long segments set in dmaengine_pcm_set_runtime_hwparams(). That gives
the DMA engine some chance to update the PCM pointer every once in a
while and prevent the timeout.
Signed-off-by: Marek Vasut <marex@nabladev.com>
---
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Mark Brown <broonie@kernel.org>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: linux-sound@vger.kernel.org
---
sound/core/pcm_dmaengine.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c
index 1306b04be171a..092ce958e1aee 100644
--- a/sound/core/pcm_dmaengine.c
+++ b/sound/core/pcm_dmaengine.c
@@ -424,6 +424,10 @@ int snd_dmaengine_pcm_refine_runtime_hwparams(
hw->info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME;
if (dma_caps.residue_granularity <= DMA_RESIDUE_GRANULARITY_SEGMENT)
hw->info |= SNDRV_PCM_INFO_BATCH;
+ if (dma_caps.residue_granularity == DMA_RESIDUE_GRANULARITY_SEGMENT) {
+ hw->periods_min = 8;
+ hw->period_bytes_max /= 8;
+ }
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
addr_widths = dma_caps.dst_addr_widths;
--
2.53.0
next reply other threads:[~2026-03-27 14:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-27 14:29 Marek Vasut [this message]
2026-03-30 7:41 ` [RFC][PATCH] ALSA: pcm_dmaengine: Use more shorter periods for SEGMENT granularity PCM DMA Takashi Iwai
2026-03-30 16:47 ` Marek Vasut
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=20260327143014.54867-1-marex@nabladev.com \
--to=marex@nabladev.com \
--cc=broonie@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-sound@vger.kernel.org \
--cc=monstr@monstr.eu \
--cc=perex@perex.cz \
--cc=tiwai@suse.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