From: Takashi Iwai <tiwai@suse.de>
To: Marek Vasut <marex@nabladev.com>
Cc: linux-sound@vger.kernel.org, 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: Re: [RFC][PATCH] ALSA: pcm_dmaengine: Use more shorter periods for SEGMENT granularity PCM DMA
Date: Mon, 30 Mar 2026 09:41:23 +0200 [thread overview]
Message-ID: <87mrzpu5lo.wl-tiwai@suse.de> (raw)
In-Reply-To: <20260327143014.54867-1-marex@nabladev.com>
On Fri, 27 Mar 2026 15:29:43 +0100,
Marek Vasut wrote:
>
> 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;
> + }
Overriding with the hard-coded values at hw_params refine doesn't look
like a right way. Those values are set and dealt by the drivers in
general, as they are pretty hardware-specific. You can't guarantee
this magic number 8 working on all available hardware.
thanks,
Takashi
next prev parent reply other threads:[~2026-03-30 7:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-27 14:29 [RFC][PATCH] ALSA: pcm_dmaengine: Use more shorter periods for SEGMENT granularity PCM DMA Marek Vasut
2026-03-30 7:41 ` Takashi Iwai [this message]
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=87mrzpu5lo.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=broonie@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-sound@vger.kernel.org \
--cc=marex@nabladev.com \
--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