Re: [PATCH] ALSA: sparc: cs4231: Require an integer number of periods

From: Takashi Iwai

Date: Wed Dec 02 2026 - 03:32:57 EST


On Tue, 01 Dec 2026 22:15:14 +0100,
Stian Halseth wrote:
>
> The DMA engine is fed one period at a time. snd_cs4231_advance_dma()
> wraps after runtime->periods periods. Nothing requires the buffer to
> be a whole number of periods. When it is not, the DMA ring ends before
> the buffer does. The frames in the tail are never played. On capture,
> the tail is never filled.
>
> Any application that sets its own buffer and period sizes can hit
> this. Buffer and period times can also round to such sizes. A minimal
> case:
>
> aplay -D hw:0 -t raw -f S16_BE -c 2 -r 48000 \
> --buffer-size=8192 --period-size=2016 /dev/zero
>
> The DMA wraps after 8064 frames, but ALSA counts each wrap as a full
> pass of 8192 frames. On a Sun Ultra 5, hw_ptr in the substream's proc
> status advances 48781 frames/s, against 48020 with 2048-frame periods.
> With music the skipped frames are heard as distortion. This was found
> with Audacious, which picks such sizes by default on this card.
>
> Add the integer periods constraint, as other drivers that program DMA
> per period do.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Closes: https://github.com/sparclinux/issues/issues/134
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Stian Halseth <stian@xxxxxx>

Applied to for-next branch. Thanks.


Takashi