Repository navigation
dmaengine: apple-admac: Read the cyclic position only from a consistent snapshot - #979
Merged
Merged
Conversation
…nt snapshot At the end of a period the controller runs the residue down to 0, posts the period's report, and only then loads the next descriptor. A residue read in between (report counted, residue still 0) put the position a whole period ahead. The PCM core then saw the hardware pointer past the application pointer and stopped the stream for an underrun. On the J316s (M1 Pro) speakers this hit two to three times in each five-minute full-volume run. PipeWire's timer wakes a few microseconds before the period interrupt, and the protection supervisor reads the PCM status every millisecond, so the reads land at period ends. ftrace showed the playback position jump from 11242 to 11776 frames (a period end plus 512) in 0.36 ms, with the PCM stopped in XRUN by the same read. Both data loop wakes and the DMA interrupt were on time, and no thread was preempted. The old check caught only a descriptor load between the two residue reads. It also counted a report posted before the first ring read twice. So read again until the snapshot is consistent: the report ring the same on both reads, and the residue non-zero, not reloaded and within a period. A controller that stays at a period's end (stalled, with no descriptor to load) is reported at the periods done or the last position, whichever is later. That position is never ahead of the transfer and never behind an earlier report, since a pointer that goes back reads as a wrap of the whole buffer. KUnit covers the cases from the trace. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause of the J316s speaker dropouts. At a period's end, a residue read between the report post and the descriptor load put the playback position a period ahead. ALSA then stopped the stream with an XRUN. Captured with ftrace on the M1 Pro (pointer 11242 -> 11776 in 0.36 ms).
The fix: retry until the snapshot is consistent. A stalled controller gets a monotonic fallback.
🤖 Generated with Claude Code