Skip to content

drm/apple: audio: suspend an open DP audio stream for system sleep - #1681

Merged
RyanTheTide merged 1 commit into
integration/aurorafrom
dpsusp/sleep-suspends-stream
Nov 12, 2026
Merged

RyanTheTide merged 1 commit into
integration/aurorafrom
dpsusp/sleep-suspends-stream

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

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:

  • At the sleep's .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. .suspend repeats this in case a link was held again.
  • The display drops its sink in its own suspend, which runs first because the DRM device binds last. A stream that is already suspended is now kept rather than stopped as DISCONNECTED. Userspace can't recover a DISCONNECTED stream; PipeWire looped on EBADFD after every wake.
  • After the wake, the kept stream's next prepare or hw_params takes the reconnected sink. It reopens the native audio service, reads the elements and reselects the element from the stream's rate, format and channels. With no sink, or one that can't take the format, it fails and userspace opens a new stream.
  • The PCM drops SNDRV_PCM_INFO_RESUME, since the link doesn't survive the sleep. Userspace prepares again.

Tests

  • KUnit 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. All apple-* suites: 314 passed, 1 skipped (the skip was already there).
  • Host tests 287/287, dcp 88/88.
  • MacBook Neo (T8140), test kernel = this tree on integration 44ff52a, Stage 2 aura 1.0.0b12 code, PipeWire stream held on the DP sink (Acer over the dock):
    • Before (v1, without the keep/rebind): deep sleep entered, but after the wake the PCM was DISCONNECTED and PipeWire never recovered (30 s).
    • deep x10: 10/10 entered, 0 refusals, every one returned through the firmware (boot object 1 -> 11). After each wake the stream was RUNNING with hw_ptr moving within 0.5 s, following the link held at the mode set. DP-1 connected and enabled, jack on.
    • s2idle x3: 3/3, stream running again within 0.5 s.
    • 0 kernel errors, 0 AVCs, 0 display audio warnings; PipeWire logged no EBADFD.

Other Apple audio drivers: aop_audio stops its firmware for the sleep and doesn't refuse. mca still refuses in suspend_late while 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

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>
@RyanTheTide
RyanTheTide merged commit 3d6f0f5 into integration/aurora Nov 12, 2026
1 check passed
@RyanTheTide
RyanTheTide deleted the dpsusp/sleep-suspends-stream branch November 12, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant