Re: [PATCH] dmaengine: apple-admac: Fix position one period ahead at period boundary

From: Martin Povišer

Date: Thu Oct 29 2026 - 15:01:32 EST



> On 29. 10. 2026, at 11:59, Jacob Procee <sn125164@xxxxxxxxx> wrote:
>
> Speaker playback on a MacBook Pro 14" (M1 Pro, J314s) underruns at
> irregular intervals, audible as a tick: 8 times in 3.7 hours of
> playback. Where an underrun was caught (4 of 8), the ALSA hw_ptr had
> jumped by one buffer size while about 70 ms of audio was still queued,
> and a kernel trace showed the DMA position stepping back by exactly one
> period at each of the 6 underruns it covered.
>
> admac_cyclic_read_residue() derives the position from the report ring
> (periods finished but not yet reclaimed) and REG_RESIDUE (bytes left in
> the current descriptor). When a descriptor finishes, the residue first
> drops to zero, then the report is posted and the next descriptor is
> loaded. Usually the last two happen together, but occasionally the
> report comes first.

Hi Jacob,

this is an interesting change. I agree with your assessment that this boils down to assuming REG_REPORT_RING and REG_RESIDUE get updated in one atomic transaction after completion of each descriptor. To my recollection, the driver is written assuming this behavior as a guess. I have reverse engineered the block's interface by looking at MMIO traces and by direct experimentation, neither gives certainty on this point.

Rewriting admac_cyclic_read_residue to avoid the race altogether would be best but until then, your change looks to be a strict improvement.

Feel free to add
Acked-by: Martin Povišer <povik+lin@xxxxxxxxxxx>

Best regards,
Martin