Repository navigation
drm/apple: audio: end a stream whose service instance was replaced - #3286
Merged
Merged
Conversation
The firmware publishes a successor of the DP audio service whenever the display link is set up again, also with the sink connected throughout. The successor comes up plugged, so the card sees no unplug and a running stream is not stopped. The link the stream started on went with the old instance: its DMA stops and the stream waits in RUNNING until the PCM is reopened. On the M2 Mac mini (firmware 27.2) this happens after every short system sleep. The HDMI monitor drops HPD for ~1.7 s as it wakes, and ~10.7 s after the resume the firmware announces DCPAVAudioInterface on a new channel. A stream started in between stops after ~1.5 s. Record the instance a stream's link starts on, read under the lock the start call takes the instance with. Each newly opened instance connects the card; a stream still running on an older instance then ends as an xrun, and userspace prepares it again on the successor. A stream playing into the void (no sink) has no link and is left alone. The instance comes from the service's own generation count, not from a firmware or board test. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
The DCP unbinds after its DP audio component and may still connect the card meanwhile. Cancelling the work at unbind left it free to be queued again by such a connect, and the work then acted on the substream of a card being freed. Keep the work disabled outside a bound card: it starts disabled, is enabled once the card is registered, and is disabled (waiting for a running one) at unbind before the card is freed. A connect while it is disabled queues nothing. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
RyanTheTide
commented
Nov 26, 2026
RyanTheTide
left a comment
Contributor
Author
There was a problem hiding this comment.
Formal non-author review at efa19470: no blocking findings. MERGE once CI is green and the peer row is in (MERGETRAIN6). ORACLE's teardown hold was lifted for this head at 09:18.
Checked the one-commit delta on top of f923c386 (audio.c, +18/-1):
- Lifecycle balance.
disable_work()runs right afterINIT_WORK()in probe.enable_work()runs only afterdcpaud_init_snd_card()succeeds in bind. Unbind callsdisable_work_sync()only ifreplaced_enabledis set, then clears it. The disable count stays balanced across a bind that fails (unbind doesn't run, and the work stays disabled), across unbind/rebind cycles, and across remove without bind (never queued).replaced_enabledis only touched in bind/unbind, which the component framework serializes. - The race it closes.
dcpaud_connect()queues afterdcpaud_report_hotplug()has droppeddata_lock, so thedcpaud->cardcheck there is unlocked. With this change that's safe: once unbind has rundisable_work_sync(), a racing connect'sschedule_work()returns false and queues nothing. A work that was already queued or running finishes beforesnd_card_free_when_closed().schedule_work()'s return value is ignored and no reference is taken, so nothing leaks when it is refused. - Work body unchanged. It still checks
substream/dcp_devand stops a running stream as XRUN under the PCM stream lock only whenstart_genno longer matches the live instance. - Rows: the J473 3/3 silent wake runs with one HDMI service replacement per stream completed 3/3 at this source (ORACLE 09:17), against 3/3 timeouts on combo23.
Still owed before merge: green CI at this head, and the peer row ORACLE named (a second Mac on the same audio path).
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.
What: When the firmware replaces the DP/HDMI audio service while the sink stays connected, a stream running on the old instance is now ended as an xrun, and userspace prepares it again on the new one. Before, the replacement came up already plugged, so the card saw no unplug. The stream kept waiting on a link that had gone with the old instance: its DMA stopped and playback hung in RUNNING until the PCM was reopened.
On the M2 Mac mini (firmware 27.2) this happens after every short system sleep. The HDMI monitor drops HPD for ~1.7 s as it wakes, and ~10.7 s after the resume the firmware announces
DCPAVAudioInterfaceon a new channel. A stream started in that window stops after ~1.5 s.How:
dcp_audiosrv_startlink()reports the generation of the instance the link starts on, read under thesrv_rwsemwrite lock that picks the instance. Each newly opened instance connects the card (dcpaud_connect()), which queues a work item. Under the PCM stream lock, that work ends a running stream whose recorded generation is no longer the published one. A stream playing into the void (no sink) has no link and is left alone. Native-link PCMs are not touched. No firmware, SoC or board check.The work is only queued while the card is bound: it starts disabled, is enabled once the card is registered, and is disabled at unbind (waiting for a running one) before the card is freed. The DCP unbinds after its audio and may still connect meanwhile; such a connect queues nothing.
Tested:
efa19470pass: same row as below, HDMI 3/3 with the xrun 3/3, USB-C 3/3, no WARN/Oops in the trial boot including its shutdown (card unbind), restore verified.efa19470pass (peer, same classic DP-audio ops): guarded one-shot with the signed combo23 J616s Stage 2, 3 RTC wakes each followed by an 18 s zero-sample stream on its DP monitor, 3/3 complete, 0 kernel warnings, saved default restored and verified. No service replacement happened during these streams, so this row shows no regression, not the fix firing.f923c386pass: HDMI monitor stream after an RTC s2idle wake 3/3 (pw-catcompletes; the xrun fires 3/3 when the successor appears mid-stream, and hw_ptr restarts and advances at 48 kframes/s to the end), USB-C 3/3, restore to the saved default verified.859e8a29(main, no fix) fail, same row: HDMI 0/3 (pw-cattimes out, hw_ptr frozen), successor during each stream 3/3, USB-C 3/3.apple-dcpaud-*31/31 on arm64 QEMU, with 3 new legacy-path cases: a replaced instance ends the stream and the next START records the successor; the same instance leaves the stream playing; a void stream is untouched.Risk: two-way door. Only classic-ops DP audio is affected (
!native_link). A healthy stream is left alone: the work compares generations under the stream lock that START records them under (KUnit same-instance case). A stream on a replaced instance gets one xrun, which PipeWire recovers from without reopening (J473 rows). Unplug, DPMS and system-sleep paths are unchanged: they stop or suspend the stream before any connect.Not yet:
dcpaud->cardis set. Whichever lands second should re-check this.Evidence and timeline
Raw rows (store, not public):
traces/display/20261127-j473-hdmi-audio-wake-stall/(README, ab-summary.txt) andtraces/display/20261125-j473-dpms-relight/{m2combo23-wa-ctl,m2mdfaw2-wa-fix}.Kernel timeline of the original stall (m2combo23, monotonic s): 2837.78 resume; 2838.03 HDMI HPD low; 2846.52 stream opens; 2848.19
dcp_hotplug() connected:0; 2848.47DCPAVAudioInterface on channel 87 supersedes channel 83+av_service_connect: starting audio service, plugged:1; the stream's hw_ptr stops at 74752 frames (1.56 s). On the saved production kernel (no post-wake HPD low) the same check passes, because no successor appears during the stream.An earlier version hooked only the native-link ops and did not engage on the J473, which uses the classic ops (0/3 on the same row). That version was dropped. Two race windows found in review (generation read outside the startlink lock; generation read outside the stream lock) and the teardown admission (work queued by a DCP connect after the audio unbind cancelled it) are closed in this head.