Repository navigation
drm/apple: audio: start the format sieve with no rates - #3264
Conversation
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>
|
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.
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: |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
satchlj
left a comment
There was a problem hiding this comment.
Reviewed b61bd1d972f4 (drm/apple: audio: start the format sieve with no rates):
- Initializing
sieve->rates = 0;indcpaud_fill_fmt_sieve()fixes a clear uninitialized-stack bitmask bug before ORing matching rates, anddcpaud_sieve_takes_params_onlycleanly exercises the0xff-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 atb61bd1d972f4.
RyanTheTide
left a comment
There was a problem hiding this comment.
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.
|
Merging at |
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 casedcpaud_sieve_takes_params_onlyfails without the line (22/23 in its suite). Merged with today's main 859e8a2 (no conflict): KUnitapple-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,dpaudionode): 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.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.drivers/gpu/drm/apple/audio-link-test.c(suiteapple-dcpaud-release-link).Evidence
audio.c; the branch merges with it with no conflict.tools/testing/kunit/kunit.py run --arch=arm64with KUNIT, DRM_APPLE, DRM_APPLE_AUDIO, DRM_APPLE_DISPLAY_KUNIT_TEST, KASAN, 16K pages; LLVM 18. At the head:apple-dcpaud-*24/24,apple-dcpaud-release-link23/23 (22/23 without the line),apple-dcpaud-no-sio1/1. On the merge with 859e8a2: 29/29 (apple-dcpaud-legacy,-no-sio,-release-link).drivers/gpu/drm/apple/audio.o(clang 18): no warning in the touched files.7.3.0-0.next2built from main ba29027 plus our open kernel branches (this one, the other DCP audio fix, Thunderbolt/DART, display and PMP thermal), plus drm/asahi: g16: admit 25G83 on every T8132 Air with one normalized entry #2672, drm/apple: turn framebuffer damage into a commit #2797 and arm64: dts: apple: t8132-j713-j715: DisplayPort alt mode on both USB-C ports #2807. Firmware 26.6.2.