Skip to content

drm: apple: audio: legacy path: 256 KiB audio elements, PM reference held until the DMA stopped - #3128

Merged
DjDeveloperr merged 4 commits into
mainfrom
fix/m2mdf-r1697
Nov 25, 2026
Merged

DjDeveloperr merged 4 commits into
mainfrom
fix/m2mdf-r1697

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

What: Two DCP audio fixes for the legacy audio service (M1/M2 on pre-14.7 firmware), from nekolyanich's #276. (1) Ask for up to 256 KiB of audio elements: DCP truncates the catalogue and reports 0 bytes when it doesn't fit, and a TV behind a USB-C to HDMI adapter has 17312 bytes, so the old 16 KiB lost the rest. (2) Drop the runtime PM reference only after the DMA terminate (in sync_stop): putting it at STOP powered the DPA domain down while SIO could still DMA, SIO crashed ("Shim DMA unavailable") and DP audio died until a reboot. Plus a KUnit suite for the legacy stream's PM reference and element size, and kvzalloc in the host selftests. Replaces #1697: the same four commits on main 40d1e1a, with nekolyanich's authorship and sign-offs kept and the commit trailers removed.

Tested: d0c923a KUnit (drm/apple audio set, incl. the new apple-dcpaud-legacy suite) 229 passed, 1 skipped, on top of the merged held-link changes (#3050); checkpatch --strict clean apart from the new-file MAINTAINERS note. No hardware row at this head yet (see Not yet).

Risk: two-way · M1/M2-family Macs on the legacy audio service (J316s M1 Pro, J413 M2): external display audio.

Not yet: a row at this head with HDMI or DP audio playing through the legacy path on an M1 Pro or the J413 (monitor output only, silent or monitor-jack capture). Neither has a monitor attached right now; this needs a monitor moved to one of them.

Details

Commit 1 and 2 are nekolyanich's, from #276 (credit also to sithglan, who tested #276 on a Mac mini M1 with HDMI and USB-C sinks). With commits 1 and 2 reverted, all five new KUnit cases fail: PM usage drops to 0 at STOP before the terminate is waited for, a retried START leaves an extra reference, and the catalogue is asked for with 16 KiB. On current main the change sits on top of #3050's held-link logic; KUnit covers both together.

nekolyanich and others added 4 commits November 25, 2026 16:08
When the audio elements do not fit the buffer of the get_elements
call, DCP returns them cut off at the buffer's end and reports a used
size of 0. A Samsung TV behind a USB-C to HDMI adapter has 17312 bytes
of elements, so with the 16 KiB the legacy path asked for, everything
past 16 KiB was lost. macOS 13 asks for up to 256 KiB (max_size 0x40000
in the request, 0x43a0 used in the reply for this TV), as the native
14.7 path already does: use that capacity on every firmware. The
native path no longer needs a second buffer of its own.

Allocate the elements buffer and the call buffers with kvzalloc(),
including the ones in afk_service_call_timeout_len() and
afk_service_call_with_reply_len(), which every AFK service call goes
through; they are only copied into the DMA buffers.

Fixes: cb24343 ("gpu: drm: apple: Add DCP audio driver")
Link: #276
Signed-off-by: nekolyanich <me@nekolyanich.com>
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…topped

Trigger STOP put the runtime PM reference right after starting the
asynchronous DMA terminate. Without autosuspend that suspends the
device at once and powers its domain (ps_dpa1/ps_dpa2) down while SIO
may still run DMA towards the DPA. SIO then crashed with "Shim DMA
unavailable" and the TERMINATE timed out after it, taking DP audio on
all outputs down until a reboot. On an M2 Pro with two DP sinks an
earlier version of this change on a downstream tree took it from 4 of
4 boots to none in 11.

Put the reference in sync_stop, after snd_dmaengine_pcm_sync_stop()
waited for the terminate. ALSA calls sync_stop at the next hw_params,
prepare or hw_free, at close, at system suspend and at disconnect, not
right after the STOP, so after a drain, an xrun or a stop with the
stream left open the DPA stays powered until then. Waiting inside
trigger would also work (the PCM is nonatomic), but sync_stop is the
hook ALSA has for it, as in the AOP audio driver.

The stream remembers whether it holds the reference. sync_stop runs
outside the stream lock: test and clear it under the lock. START takes
the reference only once, since a START can follow a failed one before
sync_stop ran. A stream that plays into the void without a sink holds
none, as before.

Fixes: f25cb50 ("drm: apple: audio: Implement runtime PM support")
Link: #276
Signed-off-by: nekolyanich <me@nekolyanich.com>
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…capacity

KUnit cases for the legacy (pre-14.7) audio service: a stopped or
suspended stream keeps its runtime PM reference until sync_stop has
waited for the DMA terminate, a failed START and a retried one before
sync_stop leave one reference, a stream without a sink takes none, and
the element catalog is asked for with 256 KiB so that a 17312 byte
catalog arrives whole.

The audio service's link and catalog calls get static stubs for this.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…ll buffers

The AFK service call and audio osobject call buffers now come from
kvzalloc(); give the host harnesses that compile those functions the
same calloc()/free() shims they have for kzalloc().

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide requested review from a team as code owners November 25, 2026 05:13
@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m2 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merge readiness at d0c923a3: ready to merge

Check Detail
CI at head ok 19 checks passed
Review ok approved by satchlj
Requested changes ok none
Hardware row at head ok comment at d0c923a3
Conflicts ok none
PR text ok Risk: two-way · M1/M2-family Macs on the legacy audio service (J316s M1 Pro, J413 M2): external display audio.

Areas: area:display
Merge: gh pr merge 3128 --merge (Owners and Core through the bypass: add --admin).

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.

Verdict: APPROVE at d0c923a3b25f

Blockers: none

Checked:

  • drivers/gpu/drm/apple/audio.c and drivers/gpu/drm/apple/dcp.c diff for legacy audio ring sizing and runtime-PM lifetime
  • CI matrix and readiness checks at d0c923a3b25f
Evidence
  • audio.c: bumps the legacy audio element size to 256 KiB and holds the runtime PM reference until audio DMA actually stops, avoiding premature power-down while the legacy stream is still draining.
  • dcp.c: matches the updated legacy audio element/PM lifecycle without disturbing non-legacy paths.
  • CI at d0c923a3b25f: 20/20 checks green (apple-build, kunit, all KUnit sub-suites, host-tests, pr-text, readiness).

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Nov 25, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

d0c923a3b25f (0-line diff across drivers/gpu/drm/apple/{afk.c,audio.c,av.c}) J316s (MacBook Pro 16" M1 Pro, T6000, macOS 13.5 legacy DCP fw, guarded one-shot default cmdline, boot_id=0872cdf4) PASS: legacy DCP audio cards card 8: HDMI [Apple HDMI] and card 9: USBC [Apple USB-C DisplayPort] (+ AppleJ316/AppleJ316HPAI, built-in speakers silent) probed cleanly pre- and post-sleep; rtc1 s2idle 1/1 (15.09 s, same_boot=true, fail_delta=0); Borealis VK + Asahi GLES 3.2 ok (gl_error=0, 32 passes); Wi-Fi 5/5 ping; 0 AVC, 0 failed units, 0 appledrm/DCP/audio/GPU kernel errors, Enforcing; stock 7.3.0-aurora-fleet89 restored and verified.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Nov 25, 2026
@DjDeveloperr
DjDeveloperr merged commit 16da002 into main Nov 25, 2026
21 checks passed
@RyanTheTide
RyanTheTide deleted the fix/m2mdf-r1697 branch November 27, 2026 13:21
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:m1 Macs affected, from Merge risk (bot) blast:m2 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants