Skip to content

drm/apple: audio: start the format sieve with no rates - #3264

Merged
RyanTheTide merged 1 commit into
aurora-silicon:mainfrom
themartiano:fix/dcp-audio-fmt-sieve
Dec 2, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:mainfrom
themartiano:fix/dcp-audio-fmt-sieve

Conversation

@themartiano

Copy link
Copy Markdown
Contributor

What: dcpaud_fill_fmt_sieve() sets the sieve's formats and channel counts, but only ORs bits into its rates. Both callers leave the sieve uninitialised on the stack, so stray stack bits count as requested rates. The hw rules, the element selection and, on firmware that links by format, the link rate can then be wrong. The sieve now starts with no rates. One line.

Tested: No Mac runs this code at b61bd1d yet (see Not yet). Host side at b61bd1d: KUnit apple-dcpaud-* 24/24 on arm64 QEMU with KASAN; the new case dcpaud_sieve_takes_params_only fails without the line (22/23 in its suite). Merged with today's main 859e8a2 (no conflict): KUnit apple-dcpaud-* 29/29. checkpatch --strict clean. Regression only: J713 M4 Air (26.6.2) at the same diff (d6de90ef35cc), kernel = main ba29027 plus all our open branches combined: boots, 0 failed units, 0 kernel errors, 10 of 10 deep sleeps. This code does not run there, because main has no DP audio on the J713.

Risk: two-way · every Mac with DCP audio (an apple,dpaudio node): M1, M2, M1/M2 Pro/Max/Ultra, M3 Pro/Max, M4 Pro/Max, J714s and Neo in main's trees.

Other Macs: This is shared DCP audio code, not M4 code. On every Mac above, only rates that the stream's own parameters exclude stop passing the sieve. A rate the stream asked for is never removed. Whether a Mac saw wrong rates before depends on what was on its stack, so many will see no change. It helps wherever the stray bits picked the wrong element, wrong rules or a wrong link rate.

Not yet: a hardware row. The J713 cannot give one on main today: DP audio there needs a newer aura boot loader and the DT in #3137. Any Mac with working DCP/HDMI audio can give it: speaker-test -D hw: at 44.1, 48 and 96 kHz, and one stream kept across a sleep with the position rate right.

Details
  • Fixes: 4a8d0257cd1a, where the function first appears with the same omission.
  • What the stray rates do: the hw rules count elements that do not have the stream's rate, dcpaud_select_cookie() takes the first element that has any of those rates, and on firmware whose link data is the stream's format, dcpaud_link_format() sends the lowest.
  • Seen on an older tree with DP audio, not at this head: J713, a 48 kHz stereo 24-bit stream that went on after a deep sleep was linked as (1, 2, 24, 192000) and played about four times too fast. A stream opened after it was linked as 48000.
  • The new KUnit case is in drivers/gpu/drm/apple/audio-link-test.c (suite apple-dcpaud-release-link).
Evidence

dcpaud_fill_fmt_sieve() assigns the sieve's formats and channel counts
but only or's bits into its rates, and both callers leave the sieve on
the stack uninitialised. Any rate the stack holds then passes as one the
stream asked for: the hw rules count elements that do not have the
stream's rate, dcpaud_select_cookie() takes the first element that has
any of those rates, and on firmware whose link data is the stream's
format, dcpaud_link_format() sends the lowest.

Measured on an older tree on a J713: a 48 kHz stereo 24-bit stream that
went on after a deep sleep was linked as (1, 2, 24, 192000) and played
about four times too fast. A stream opened after it was linked as 48000.

Start from no rates.

Fixes: 4a8d025 ("gpu: drm: apple: Add DCP audio driver")
Signed-off-by: Eduardo <git@martiano.me>
@m0d16l14n1

Copy link
Copy Markdown
Contributor

Hardware row, J815 (MacBook Air 15" M5, T8142, DCP firmware 27.2), HDMI TV behind a USB-C hub (ELD: LPCM 2ch, 32-192 kHz), on both Type-C ports. Kernel: main 37a19f9 + open PRs, this PR at b61bd1d merged without conflict.

without this PR with this PR
48 kHz stereo 24-bit stream from PipeWire (YouTube) played about 4x too fast on both ports right speed, both ports
display ADMAC report stamps (24 MHz) 256000 ticks per 2048-frame period = ~192000 frames/s 256000 ticks per 512-frame period = 48000 frames/s

Same symptom as the J713 note in Details: the link ran at 192000 for a 48 kHz stream, which is the TV's highest rate.

With this PR alone the stream on these boards still restarted at every period's end; that is a separate fault in the display ADMAC position, #3692. With both, PipeWire's default scheduling plays cleanly on both ports (20 s each: 1 stream start, 0 XRUN, 48001/48003 frames/s, PipeWire errors 0).

Regression: 0 failed units, 0 new kernel errors (the only new error lines are the hub's own USB enumeration, also seen without this PR).

Not tried: speaker-test at 44.1 and 96 kHz, and a stream kept across a deep sleep.

@themartiano
themartiano marked this pull request as ready for review December 2, 2026 16:15
@themartiano
themartiano requested review from a team as code owners December 2, 2026 16:15
@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Merge readiness at b61bd1d9: not ready yet

Check Detail
CI at head ok 18 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at b61bd1d9
Conflicts ok none
PR text ok Risk: two-way · every Mac with DCP audio (an apple,dpaudio node): M1, M2, M1/M2 Pro/Max/Ultra, M3 Pro/Max, M4 Pro/Max, J714s and Neo in main's trees. Other Macs: This is shared DCP audio code, not M4 code. On every Mac above, only rates that the stream's own parameters exclude stop passing the sieve. A rate the stream asked for is never removed. Whether a Mac saw wrong rates before depends on what was on its stack, so many will see no change. It helps wherever the stray bits picked the wrong element, wrong rules or a wrong link rate.

Areas: area:display

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed b61bd1d972f4 (drm/apple: audio: start the format sieve with no rates):

  • Initializing sieve->rates = 0; in dcpaud_fill_fmt_sieve() fixes a clear uninitialized-stack bitmask bug before ORing matching rates, and dcpaud_sieve_takes_params_only cleanly exercises the 0xff-poisoned stack case.
  • DCO, Risk:, and the J815 M5 HDMI audio hardware row are in place.
  • Approved the pending fork workflow runs (pr-text, Host tests, Apple build and KUnit, Apple DRM KUnit); holding approval for CI to finish green at b61bd1d972f4.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at b61bd1d972f4 under the 12-01 merge bar. One-line fix (sieve->rates = 0; in dcpaud_fill_fmt_sieve()) plus KUnit regression test dcpaud_sieve_takes_params_only; audited alongside satchlj's review, all 19 hosted CI checks (including apple-build, host-tests, and all KUnit suites) are now green, and exact-head J815 HDMI audio PASS row is posted.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at b61bd1d972f4 (B2 merge train, 12-01 merge bar). Approval at this head: RyanTheTide. Row: J815 (MacBook Air 15" M5, T8142, DCP fw 27.2) exact-head HDMI audio PASS row at b61bd1d972f4 (m0d16l14n1, comment 7294788136: 48 kHz stream plays at 48000 frames/s on both Type-C ports vs 192000 before, 0 failed units).. CI: All 19 hosted CI checks green at b61bd1d972f4 (apple-build, host-tests, kunit, all KUnit suites). Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit c2f1583 into aurora-silicon:main Dec 2, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:display Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants