Repository navigation
drm/apple: audio: suspend an open DP audio stream for system sleep - #1681
Merged
Merged
Conversation
dcpaud_system_suspend() refused any sleep that reaches the firmware with -EBUSY while the DP audio PCM was open, running or not. GNOME plays its device-added sound when a dock's USB devices go away at the start of suspend, and with DP audio as the default sink that keeps the PCM open at the wrong moment: a T8140 refused 8 of 10 deep sleeps this way. The sleep only needs an idle SIO channel, because the SIO firmware stops for it and sio_suspend_late() refuses a channel that still has a transfer. So suspend the stream the ALSA way instead: - At the sleep's prepare, before any device suspends, snd_pcm_suspend_all() triggers SUSPEND and then sync_stop. SUSPEND now ends the DMA as STOP does (a paused channel would stay busy), and sync_stop drains it and stops and completes the link. A link held with silence is then released, as when the display goes off. .suspend does the same again in case a link was held since. - The display drops its sink in its own suspend. A stream that is suspended at that point is kept instead of being stopped as DISCONNECTED, which userspace cannot recover from (PipeWire kept failing with EBADFD after every wake). - After the wake, the kept stream's next prepare or hw_params takes the sink connected then: it reopens the native audio service, reads the sink's elements and selects the stream's element again from its rate, format and channels. With no sink, or one that cannot take the format, it fails and userspace opens a new stream. The PCM no longer claims SNDRV_PCM_INFO_RESUME: the link does not survive the sleep, so userspace prepares the stream again. On the T8140, with a PipeWire stream held on the DP sink: 10 of 10 deep sleeps entered with no refusal, and the stream was running again within 0.5 s of every wake, following the link held at the mode set. s2idle passed 3 of 3. No kernel errors, AVCs or display audio warnings. Fixes: d9b438c ("arm64: apple: support coordinated suspend-to-RAM on T8140") Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
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.
dcpaud_system_suspend()refused every firmware-backed sleep with -EBUSY while the DP audio PCM was open. GNOME plays its device-added sound when a dock's USB devices drop at the start of suspend, so with DP audio as the default sink the PCM is open right then. On a T8140 that refused 8 of 10 deep sleeps.The sleep needs an idle SIO channel, nothing more: the SIO firmware stops for it and
sio_suspend_late()refuses a channel that still has a transfer. This change suspends the stream the ALSA way instead of refusing:.prepare, before any device suspends,snd_pcm_suspend_all()runs SUSPEND and sync_stop. SUSPEND ends the DMA like STOP does (a paused channel would stay busy); sync_stop drains it and stops and completes the link. A link held with silence is then released as at DPMS off..suspendrepeats this in case a link was held again.SNDRV_PCM_INFO_RESUME, since the link doesn't survive the sleep. Userspace prepares again.Tests
apple-dcpaud-release-link: 18/18. Three new cases cover a running stream, a held link, and a stopped stream still playing its cleared buffer: SUSPEND/sync_stop/link order, PM references, state. Allapple-*suites: 314 passed, 1 skipped (the skip was already there).Other Apple audio drivers:
aop_audiostops its firmware for the sleep and doesn't refuse.mcastill refuses insuspend_latewhile a cluster has a stream configured, but no T8140 DT binds MCA, so that path never runs with firmware-backed sleep.🤖 Generated with Claude Code