Repository navigation
dmaengine: apple-admac: count a display ADMAC's pending report at a period's end - #3692
Conversation
…eriod's end A display ADMAC posts a period's report once the display engine has played the period, a FIFO's worth after the channel fetched the period's last bytes and loaded the next descriptor. Until the report comes, the residue is the next period's while the reports still count the fetched one as in progress, so the position reads a whole period behind. At every period's end the position stepped back to the period's start, the PCM core took that for a wrap of the whole buffer, and the stream stopped for an underrun. On the J815 (T8142) with an HDMI TV behind a USB-C hub, DisplayPort audio restarted about 28 times a second: with period interrupts it was heard with gaps, and with PipeWire's timer scheduling, its default, not at all. Take a display ADMAC position behind the last one reported as such a read: the period whose report is pending is done. The position never passes what was submitted and never goes back. Signed-off-by: Nick <nekreshen@yandex.ru>
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: HOLD at 39e02fa5
Blockers:
- Hosted
pull_requestCI checks (pr-text,Host tests, and kernel build/KUnit workflows) are currentlycompleted/action_requiredawaiting maintainer workflow approval for this fork PR; onlypr-readinesshas executed at39e02fa5. - The J815 playback row in
Tested:ran on commit70d72f7dd11d(main 37a19f92f82b+ open PRs including#3264) rather than directly on39e02fa5; please clarify whether#3264is a required prerequisite or add an exact-head39e02fa5boot/smoke row.
Checked:
drivers/dma/apple-admac.c(admac_display_pos(),admac_cyclic_read_residue()),drivers/dma/apple-admac-test.h(admac_pos_display_report_lag), and surrounding ring/position/reclaim logic onorigin/main.- Verified the change is strictly gated on
ad->display(MCA/AOP ADMAC channels are untouched), never stepsreported_posbackward, and leaves theADMAC_RESIDUE_READSfallback (admac_cyclic_pos_at_period_end()) monotonic.
Evidence
- Non-blocking edge case (
submitted_poswraparound on small period counts):admac_cyclic_pos_after()only distinguishes positions separated by< buf_len, whereasadmac_display_start_current_tx()+admac_cyclic_write_desc()can keep 4–5 descriptors (or more on an 8-slot display ring) in flight whiledrivers/gpu/drm/apple/audio.callowsperiods_min = 2. Whenevernperiods_outstanding >= periods_per_buf + 2(for examplebuf_len = 2 * period_lenwith 4–5 outstanding descriptors,buf_len = 3 * period_lenwith 5–6 outstanding, orbuf_len = 4 * period_lenwith 6 outstanding),submitted_poswraps past the half-space boundary ofadmac_cyclic_pos_after(), causing!admac_cyclic_pos_after(adtx, adtx->submitted_pos, ahead)to evaluate false and holdreported_posflat until the report arrives instead of returningahead. It still will not step backward, so it avoids the XRUN wrap, but checking the unwrapped descriptor count (admac_read_reports(&r) + 2 <= adtx->nperiods_outstanding) instead of wrappedsubmitted_poswould handle all buffer period counts and ring depths cleanly. - Minor comment mismatch:
drivers/dma/apple-admac.clines 67–68 say(every period's end, on the J815 with an HDMI TV and with a DisplayPort monitor alike), whileNot yet:in the PR body notes a DisplayPort monitor has not been tested yet (only an HDMI TV behind a hub). - Workflow runs at
39e02fa50b9687d5ab644fc695df8d93a103c5ce:pr-readiness(pull_request_target) succeeded;pr-textandHost tests(pull_request) arecompleted/action_required;Host tests(pull_request_target) skipped.
…criptor count admac_display_pos() took the pending period as done only when the position a period on was not past submitted_pos. submitted_pos is kept modulo two buffers, and admac_cyclic_pos_after() orders positions less than a buffer apart. With a buffer of a few periods the descriptors in flight can span more than that (four or five on a display channel against a two-period buffer), so the check failed and the position stood still until the report arrived. Count instead: the period after the one in progress is submitted when the reports in the ring plus two do not exceed the descriptors outstanding. The comment no longer claims a DisplayPort monitor was tested; only an HDMI TV was. Signed-off-by: Nick <nekreshen@yandex.ru>
There was a problem hiding this comment.
Verdict: HOLD at 84269b0c
Blockers:
- Hosted
pull_requestCI checks (pr-text,Host tests, and kernel build/KUnit workflows) arecompleted/action_requiredawaiting maintainer workflow approval for this fork PR; onlypr-readinesshas executed at84269b0c. - Needs a current-head J815 hardware row referencing
84269b0c(the PR body still cites39e02fa50b96/70d72f7dd11d, andpr-readinesshas flaggedneeds-hw-rowat84269b0c).
Checked:
- Commit
84269b0c(drivers/dma/apple-admac.c,drivers/dma/apple-admac-test.h). - Verified
admac_display_pos()now bounds the pending period cleanly byadmac_read_reports(r) + 2 > adtx->nperiods_outstanding(eliminatingsubmitted_poswraparound aliasing on short-buffer period counts),admac_pos_display_short_buffercovers the two-period / four-descriptor case, and the DisplayPort monitor comment wording matches the HDMI TV test scope.
Evidence
- Workflow runs at
84269b0c21ad60687ab1639c4c4793631d4369e9:pr-readiness(pull_request_target) succeeded;pr-textandHost tests(pull_request) arecompleted/action_required;Host tests(pull_request_target) skipped. - Code is clean; ready to approve once fork CI runs green and a J815 hardware row is recorded at
84269b0c.
|
Addressed at
Hosted CI on this PR is still waiting for workflow approval. |
There was a problem hiding this comment.
Verdict: MERGE at 84269b0c21ad
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: - Commit 84269b0c (drivers/dma/apple-admac.c, drivers/dma/apple-admac-test.h).
- Verified
admac_display_pos()now bounds the pending period cleanly byadmac_read_reports(r) + 2 > adtx->nperiods_outstanding(eliminatingsubmitted_poswraparound aliasing on short-buffer period counts),admac_pos_display_short_buffercovers the two-period / four-descriptor case, and the DisplayPort monitor comment wording matches the HDMI TV test scope.
Follow-ups (not blocking): fork CI approval; J815 row at head
|
Merging at |
What: on a display ADMAC (the DisplayPort/HDMI audio DMA of the display engines), the playback position stepped back by a whole period at every period's end. The PCM core took the step back for a wrap of the whole buffer and stopped the stream for an underrun, so DP/HDMI audio restarted every period: with PipeWire's default timer scheduling nothing was heard, and with period interrupts it was heard with gaps. A display ADMAC posts a period's report once the display engine has played the period, about a FIFO's worth after the channel loaded the next descriptor; until then the residue is the next period's while the reports still count the fetched one as in progress. A read behind the last reported position is now taken as that: the pending period is done, if the period after it was submitted (counted in descriptors). The position never passes what was submitted and never goes back. Only display ADMACs (
ad->display) are affected.Tested: J815 (MacBook Air 15" M5), at the first commit
39e02fa50b96(head84269b0c21adadds the descriptor-count bound from review; its J815 row is pending), HDMI TV behind a USB-C hub on each of the two Type-C ports in turn, YouTube in Firefox through PipeWire. This patch as 70d72f7dd11d on a J815 tree (main 37a19f9 + open PRs, with #3264 for the link rate);apple-admac.cand its test header are identical there and at 39e02fa. PipeWire defaults (timer scheduling), 20 s on each port: 1 stream start, 0 position steps back, 0 XRUN, 48001 / 48003 frames/s, PipeWire ERR 0 -> 0. Without this patch, same setup: about 28 stream restarts/s, ERR 110 -> 463 in 18 s, no sound. 0 failed units, 0 new kernel errors, no SELinux on this install. KUnitapple-admac-*10/10 at84269b0c21adon arm64 QEMU (new casesadmac_pos_display_report_lagandadmac_pos_display_short_buffer; the latter fails with the first commit'ssubmitted_poscheck); checkpatch --strict clean.Risk: two-way door. Display ADMACs only: T8142 (J813, J815) and the T6050 display ADMACs this path was written for. The MCA/AOP ADMACs (speakers, headphone jack, microphones) are unchanged.
Not yet: a J815 row at
84269b0c21ad; J813; T6050 (M5 Pro); a DisplayPort monitor (only an HDMI TV behind a hub so far); a stream kept across a deep sleep.Details
admac_cyclic_pos()computes the position asreclaimed + period * (reports + 1) - residue. That order of events (report posted, then the next descriptor loaded) holds on the MCA ADMAC it was written for (see its comment, J316s). On a display ADMAC the report comes later than the load:snd_pcm_update_hw_ptr0()sees the position go back and adds a buffer:hw_ptrpassesappl_ptr, XRUN.admac_display_pos()adds the pending period to such a read, bounded bysubmitted_pos, and otherwise keeps the last reported position. Reads that are not behind are returned unchanged, so a position that the existing code already got right (after the report) is untouched.This is independent of the sink: it follows from the order of the controller's report and its descriptor load.
#3264 is not a prerequisite in code. It fixes a separate fault on the same path (a stray link rate, 4x too fast on this board); neither change touches the other's code. On the J815 both are needed for correct DP audio: with only #3264 the stream still restarted at every period's end, and with only this PR it would play at the wrong rate. The row above ran with both.
Second commit (review). The first commit took the pending period as done only if the position a period on was not past
submitted_pos.submitted_posis kept modulo two buffers andadmac_cyclic_pos_after()orders positions less than a buffer apart; with a two-period buffer, four or five descriptors in flight on a display channel span more than that, and the position stood still until the report came. It now counts: the next period is submitted when the reports in the ring plus two do not exceednperiods_outstanding. The comment no longer mentions a DisplayPort monitor, which has not been tested.Evidence