Skip to content

drm/apple: external DP/HDMI audio on firmware-27 classic-layout DCPs (Mac mini M2) - #3050

Merged
RyanTheTide merged 7 commits into
mainfrom
m2mini/v27-classic-audio
Nov 24, 2026
Merged

RyanTheTide merged 7 commits into
mainfrom
m2mini/v27-classic-audio

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What: DP/HDMI audio on the Mac mini M2 (J473, T8112) with its 27.2 display firmware. Its DCPs keep the classic audio service on endpoint 0x29 (0x2b is HDCP only there), so the firmware-27 desktop role is now taken only on the V2 DPTX layout (T6050/T6041 DCPEXTs). A PCM open that hits an instance being replaced reads from the successor instead of failing. A classic Open belongs to its instance: a replaced or removed service is opened afresh, and a refusal during a replacement (each resume on the J473's DP processor) is judged after AV_AUDIOSRV_REPLACE_MS, logging at error level only if no successor opened. The classic Open and Close run unlocked, so their state (is_open, card connect/disconnect) is committed only while the RPC's instance is still the published one.

Tested: 2ce8e3c J473 (T8112, 27.2) pass: both HDMI/DP PCMs stream zero samples (hw_ptr 200192 / 199168, pw-cat rc 0), s2idle 2/2, Enforcing, 0 AVC, 0 audio-service open/close errors (the firmware still refuses the pre-sleep instance with 0xe00002d7 at warn level; each successor is published and connects); with merged aura #495 source + linux #3051
Tested: 2ce8e3c M1 Pro (J316s, 13.x HDMI DCP, classic path) pass: module loads, both DP/HDMI audio cards enumerate, s2idle 1/1, 0 AVC, only the fleet-wide dwc3 genpd -11; no monitor attached, so no live Open
Tested: 82a27e5 J473 pass: both HDMI/DP PCMs stream zero samples (hw_ptr 31232 -> 199680, pw-cat rc 0), s2idle 2/2, Enforcing, 0 AVC (with aura #495 + linux #3051)
Tested: 2ce8e3c host: apple-dcp selftests 93/93 pass (cec-only-av-endpoint covers a refused classic Open and stale Open/Close across a replacement; an always-published mutant fails it), Apple display KUnit 146/147 pass (1 skip); dcpaud-open-fallback-tests.py pass, mutations no-retry/wait-any/gone-fails/keep-cookie/mask-all all killed; builds with CONFIG_DRM_APPLE_DCP_T6030_AUDIO=n

Risk: two-way door (driver-only, revertable). Macs: J473 (T8112, firmware 27, the change). J615/J713 external DCPs (firmware 27, classic layout) change role but take the same path: no dp-audio node, no HDMI-A, no 0x2b endpoint. Neo, T6041/T6050 firmware 27 (V2), J616s 26.6 desktop and 13.x/14.x Macs keep their role; the classic Open lifecycle fix applies to all classic-path Macs (M1 Pro row above).

Not yet: Audible-content check through a monitor's jack (the buildbox line-in loopback carries no signal; needs hands).

Details
  • Endpoint role: dcp_is_v27_external() now also requires hw.dptx_endpoint == DPTX_ENDPOINT_V2. Live logs: J473/J615/J713 firmware 27: DPTX controller on 0x24, ports on 0x2a (advertised); Neo remote port on 0x2c.
  • Replacement wait: dcp_pcm_open() waits (interruptible, up to AV_AUDIOSRV_REPLACE_MS) only on -EINVAL, the firmware's refusal (a non-zero retcode); -ENODEV opens as unplugged with a cookie no connection has; other errors fail the open. asrv->srv/asrv->gen written with WRITE_ONCE for the lockless wait.
  • Classic Open lifecycle: is_open cleared on replacement (av_audiosrv_init() with an old instance) and removal (av_audiosrv_teardown()); refused Open judged by the open_check_wq owner delayed work (flushed with the owner works, disabled on drain, enabled on restart).
  • Evidence (lab store): traces/display/20261124-m2mini-display-full/{audio-a4,sio3051-v10,sio3051-old,pr3050r-hdmi13}.

dcp_is_v27_external() was true for every firmware-27 DCP with DPTX
ports. It is meant for the T6050 and firmware-27 T6041 DCPEXTs, whose
ports are on DPTX_ENDPOINT_V2 and whose DP/HDMI audio service is the
desktop one, compact EPIC on endpoint 0x2b.

The T8112 DCPs (Mac mini M2) on 27.2 firmware advertise the classic
layout, ports on DPTX_ENDPOINT. On them 0x2b announces only
dcpdptx-hdcp-interface, and the audio service is the classic
dcpav-audio-interface-epic on AV_ENDPOINT (0x29), as macOS binds it on
the same machine. Taking the desktop role there waited on 0x2b for an
audio service that never comes: no audio service started, the ELD
stayed empty, and the HDMI and DP jacks stayed off.

Take the desktop role only where the DPTX ports are on
DPTX_ENDPOINT_V2 as set at probe, so that the DP audio driver, which
binds before the DCP starts, sees the same role as the DCP. Every other
firmware-27 DCP takes the classic audio service on AV_ENDPOINT with the
firmware-27 command table.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
PipeWire and PulseAudio probe a PCM once when its card appears and drop
the output for good if the open fails, which is why an unplugged sink
already opens with a fixed hardware description.

A plugged sink's open reads its elements and product attributes from the
DCP audio service. On the Mac mini M2 (27.2 firmware) the HDMI DCP's
firmware announces that service again while the display link is set up
again at boot, and stops and restarts it meanwhile; a read in that window
fails. The open failed with it, PipeWire's first probe of that card fell
in the window, and the HDMI output never got its HiFi profile, although
the ELD and jack came up a few seconds later. A restart of PipeWire after
that showed the profile and an available HDMI port on both cards.

Open as for an unplugged sink when the sink info cannot be read. The
stream then runs as an unplugged one does, until the next open.

tools/asahi/dcpaud-open-fallback-tests.py runs the real dcp_pcm_open()
over plugged, unplugged, restarting and refused sinks and a DMA failure,
and kills two mutations.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

RyanTheTide commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Independent review at cf3d0b9b973e7e6c76b0dcd34ac4a61733a13711. I replayed the exact five-case PCM-open fixture successfully. The endpoint change accounts for the two J473 jack and ELD readbacks. Two questions still affect working output.

  • The same predicate also selects the link encoding and native lifecycle in av.c. With the corrected classic endpoint, J473 now takes the legacy dcp_audiosrv_prepare() and dcp_audiosrv_startlink() calls with the full cookie. The PR reports a format-based link on this firmware. Please show which link payload it accepts, and select that independently of endpoint layout if the classic service uses the format payload. A profile and valid ELD cover enumeration only.
  • The PCM fallback turns every remote failure into a successful open for the void stream. The fixture explicitly expects this for -EIO. A service restart can deserve the unplugged probe behavior, while a stable service that rejects the request leaves a profile present and the opened stream silent until close. Please distinguish service unavailability or a generation change from a persistent error and cover both in the fixture.

R15d on J473 can settle the profile-at-boot symptom. The classic 13.x/14.x and desktop-role regression rows are still needed after the final source change.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J473 boot row with both commits (fc96d3c3 + cf3d0b9b as an appledrm module on integration/aurora 7946d189 + linux#2853 + linux#2868 + linux#2953, production Stage 2, default command line). Read-backs only, nothing was played:

  • At boot, with no PipeWire restart, both DP audio cards have the HiFi profile active, [Out] HDMI1 available and a sink each. Both HDMI/DP Jack controls read on, and both ELDs are valid.
  • The HDMI DCP's firmware refused the element and product-attribute reads (group 1 cmd 16, group 0 cmd 11, retcode 0xe00002d7) at the same second WirePlumber probed the card. That is the window the second commit covers, and this time the card kept its profile.
  • Enforcing, 0 AVC, 0 failed units. Production was restored afterwards.

Follow-up, cosmetic: in this boot the ELD monitor name was still empty when the snapshot was taken. The name arrives with the reconnect after the mode is set, and an earlier row showed QG270 S3 after that. Playback rows are still to run.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-PR §1–§6 review at cf3d0b9b973e7e6c76b0dcd34ac4a61733a13711 against integration/aurora (c67c44a5ca).

Blockers

  1. Merge conflict & missing exact-head CI

    • The PR is currently CONFLICTING with integration/aurora in tools/asahi/run-host-tests.py (where dpavserv-admission-tests.py landed in the same hunk), and cf3d0b9b97 has 0 check runs / 0 commit statuses. Rebase onto current integration/aurora (which also now carries #2853 and #2868) and get clean exact-head CI.
  2. Code correctness — dcp_pcm_open() fallback breaks the open_unplugged ⇒ !dcpaud_connection_up() invariant (drivers/gpu/drm/apple/audio.c)

    • Previously, dcpaud->open_unplugged could only be true when !dcpaud->connected at open time, so dcpaud_connection_up(dcpaud) was guaranteed false for the lifetime of that open. Setting dcpaud->open_unplugged = true on dcpaud_read_remote_info() < 0 while dcpaud->connected == true leaves dcpaud->open_cookie == dcpaud->connection_cookie, so dcpaud_connection_up() returns true for an open_unplugged stream:
      • Classic path (dcp_pcm_hw_free, audio.c:599): only checks if (!dcpaud_connection_up(dcpaud)) and omits dcpaud->open_unplugged. When WirePlumber closes/frees after hitting the fallback, dcp_pcm_prepare() was skipped, yet dcp_pcm_hw_free() sends a spurious dcp_audiosrv_unprepare() RPC (group 0 cmd 11). This already fired in the latest J473 boot log (group 0 cmd 11, retcode 0xe00002d7 — product attributes is group 1 cmd 18, which wasn't reached after group 1 cmd 16 failed; group 0 cmd 11 is cmds.unprepare).
      • Native-link path (dcp_pcm_native_trigger / dcp_pcm_native_start, audio.c:1181,1254): dcp_pcm_native_open() calls dcp_pcm_open(), so native-link Macs (T6030 / T6041 / T6050 / J700) inherit this fallback. If dcpaud_read_remote_info() fails while connected, dcp_pcm_native_hw_params() and dcp_pcm_native_prepare() skip dcpaud_select_cookie(), DMA slave config, and dcpaud_link_prepare() because open_unplugged is true, but dcp_pcm_native_start() does not check dcpaud->open_unplugged at all (only !dcpaud_connection_up(), which is true). Starting that stream will call dcpaud_link_prepare() / DCP_AUDIO_LINK_START with a zero/stale selected_cookie and unconfigured DMA.
    • Broad error masking (§2): catching every ret < 0 from dcpaud_read_remote_info() turns persistent or transport/allocation failures (-ENOMEM, -ETIMEDOUT, persistent -EIO) into a silently succeeding void stream. Distinguish transient service unavailability/restart from persistent errors, guard both dcp_pcm_hw_free() and dcp_pcm_native_start() (or invalidate open_cookie / handle open_unplugged consistently across all PCM ops), and extend tools/asahi/dcpaud-open-fallback-tests.py beyond dcp_pcm_open() alone to cover hw_free and native-start behavior.
    • Also worth checking in drivers/gpu/drm/apple/av.c: on the classic path, av_audiosrv_init() / av_audiosrv_teardown() never clear asrv->is_open, and __av_service_disconnect() returns early if asrv->srv is already NULL. If the firmware replaces DCPAVAudioInterface while asrv->is_open stays true, av_service_connect() skips cmds.open on the new instance.
  3. Code correctness & ABI — dcp_is_v27_external() conflates endpoint layout (0x2b vs 0x29) with link payload & lifecycle (drivers/gpu/drm/apple/dcp-internal.h, drivers/gpu/drm/apple/av.c)

    • Returning false from dcp_is_v27_external() on J473 switches not only the endpoint/transport (0x29 classic EPIC vs 0x2b compact EPIC in av.c:1404 and afk.c:530,539), but also turns off dcp_audiosrv_native_link() (av.c:309,322), dcp_audiosrv_link_by_format() (av.c:314,564), and av_v27_start() (av.c:873,1079).
    • That sends J473 through legacy dcp_audiosrv_prepare() / dcp_audiosrv_startlink() with a 24-byte ElementData cookie (and 16 KiB DCPAUD_ELEMENTS_MAXSIZE), whereas the PR notes "macOS describes the stream by format here, as on T6050" and playback has not been tested yet. Prove working playback on both ports and decouple link payload/lifecycle selection from endpoint layout if firmware-27 classic requires format-based links.
    • Minor config note: av.c:1455 still guards case DCP_FIRMWARE_V_27_0: under #if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO), so disabling that option breaks classic firmware-27 audio with -ENODEV.
  4. §1 No model gating — dcp->hw.dptx_endpoint == DPTX_ENDPOINT_V2 at probe acts as a two-SoC allowlist and silently changes other firmware-27 dcpexts

    • At probe, dcp->hw.dptx_endpoint = DPTX_ENDPOINT_V2 is only populated for apple,t6050-dcpext and apple,t6041-dcpext (dcp.c:7626,10431). Every other compatible leaves dptx_endpoint == 0 (which dcp-internal.h:316 and dptxep.c:1645 define as firmware 27's default DPTX_ENDPOINT_V2 unless dcp_v27_dptx_layout() overrides it from RTKit's endpoint map) or DPTX_ENDPOINT (apple,t8142-dcpext).
    • Consequently, this predicate silently flips t8142-dcpext (M5 Air / J704) and t8122-dcpext (M3 on 27.2) out of dcp_is_v27_external() without any hardware evidence on those machines, and misclassifies any future firmware-27 dcpext relying on the 0 default. Either derive the audio endpoint/role from what the firmware advertises (or a dedicated capability/DT property rather than overloading probe-time dptx_endpoint), or prove and document behavior on t8142-dcpext and t8122-dcpext as well.
  5. §5 Evidence — incomplete for a non-draft PR

    • The J473 two-commit boot row (r15d) confirms read-back enumeration and 0 AVC / 0 failed units, but:
      • Actual DP/HDMI audio playback on both J473 ports has not been run yet (and group 0 cmd 11 failed with 0xe00002d7 in that boot).
      • Missing regression rows (0 SELinux denials, 0 failed units, 0 new kernel errors) on the rebased head for: J473 playback, a 13.x/14.x HDMI Mac, a desktop-role firmware-27 Mac (t6050 / t6041 / J616s), and the newly affected t8142-dcpext / t8122-dcpext if their predicate result changes.
    • Until those rows and exact-head CI land (or while the fix is still in progress), please convert to draft or land the fixes + evidence before merge.

Passing Checklist Items

  • §3 Safety: Pass — external DP/HDMI digital audio only; no speaker amp / speakerguardd or hardcoded safety limits touched.
  • §4 Clean-room & Attribution: Pass — both commits carry human author/committer (Ryan Murray <ryan@aurorasilicon.org>) and human Signed-off-by: with zero AI trailers; based on own ioreg capture and lab traces; PR body includes Assisted-by:.
  • §6 Naming: Pass — no Honeykrisp/hk/m1n1 naming violations; new host test follows the existing tools/asahi/ harness layout.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide
RyanTheTide marked this pull request as draft November 24, 2026 07:56
Takes linux#2853, #2868 and #2953. The only conflict is the host-test
registry, where both sides add entries.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The previous change opened a PCM as unplugged on any failure to read the
sink info. That masked persistent errors as a silent stream, and it left
the open's cookie live, so dcp_pcm_hw_free() and the native start took
the sink as connected for a stream that never prepared a link.

What fails at boot on the Mac mini M2 is a call to an audio service
instance the firmware is replacing: it refuses it as offline and
publishes the successor within a second, as dcp_audiosrv_open() already
handles for the open itself. Do the same for the sink info: when the
read fails and a successor is published within AV_AUDIOSRV_REPLACE_MS,
take the sink as the successor reports it and read again from it.

Only a service that is gone (-ENODEV) still opens as unplugged, and
with a cookie no connection has, so no stream op of that open takes the
sink as connected. Any other failure fails the open as before.

The host test runs the real dcp_pcm_open() and dcpaud_connection_up()
over nine cases and kills four mutations.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews. The PR stays a draft. State at 82a27e5e:

1. Conflict. Fixed with a merge of integration/aurora (04e94d27). Only the host-test registry conflicted.

2. PCM open fallback. Reworked in 82a27e5e. Errors are no longer turned into a successful open across the board:

  • If the sink-info read fails and the firmware publishes a successor instance within AV_AUDIOSRV_REPLACE_MS, the open re-samples the connection and reads again from the successor. This is the same wait dcp_audiosrv_open() already does.
  • Only a service that is gone (-ENODEV) opens as unplugged, and its open cookie is set to one no connection has. dcpaud_connection_up() is then false for that open, so dcp_pcm_hw_free() and the native start treat it as unplugged.
  • Every other error (a stable refusal, -ENOMEM and so on) fails the open as before.
  • The fixture now builds the real dcp_pcm_open() and dcpaud_connection_up(). It runs nine cases and kills four mutations. The DCP host suites pass locally (61/61).
  • On the J473 (fleet87 + this branch as a module), the HDMI DCP's audio instance refused the element read as Offline at 15.89 s. The successor arrived 0.2 s later, the read was retried, and both HDMI/DP sinks were present.

3. Link payload and lifecycle. You were right that enumeration proves nothing about playback. I ran a silent row: 4 s of zero samples through each sink on fleet87. It fails, but before the link question can even be tested:

  • On the first DMA slave config, the SIO coprocessor crashed: RTKit: co-processor has crashed, Fifo allocation overflow 2048:0.
  • After that, the USB-C card sat in RUNNING with hw_ptr 0, and the HDMI card's dmaengine_slave_config returned -22.
  • Before this PR, audio never got as far as DMA on 27.2, so this was hidden.
  • Whether firmware-27 classic needs the format link payload and the v27 lifecycle can only be tested once the SIO FIFO setup works on this firmware. If it does need them, the payload and lifecycle predicates will be split from the endpoint choice, as you suggest.

4. t8142 / t8122 dcpext. I checked what the predicate change does there:

  • Both are USB-C only (apple,connector-type = "USB-C"), and neither has a DP audio node in its DT. avep_init() therefore returns before starting any audio service.
  • The other user, dcp_cec_init_avep(), requires an HDMI-A fixed connector.
  • So the predicate changes no behaviour on them today. I will still look at deriving the role from the firmware's advertised endpoints rather than the probe-time layout when the payload split above happens.

The av.c is_open point on the classic path and the CONFIG_DRM_APPLE_DCP_T6030_AUDIO guard on the firmware-27 command table are noted for the same rework.

Evidence: traces/display/20261124-m2mini-display-full/audio-a1 on the lab store, with the kit in kits/test/20261124-m2mdf-audio87.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Playback update: the SIO crash comes from the boot loader, not this PR. The J473's 27.2 SIO firmware speaks protocol 10, but aura built it the earlier table layout. With the protocol-10 layout (aurora-silicon/aura#495, tested as a trial Stage 2), zero-sample streams run on both HDMI/DP cards with this PR's appledrm module. The DMA pointer advances at 48 kHz, both DMA channel configs succeed, and the firmware accepts the classic link (ElementData cookie). There is no SIO crash, and the row stayed Enforcing with 0 AVC and 0 failed units. Evidence is traces/display/20261124-m2mini-display-full/audio-a3 on the lab store.

So on the J473, firmware-27 classic takes the existing cookie link payload and lifecycle. No format-based link split is needed for this machine. Still open before ready: a playback row with real audio, and the 13.x/desktop-role regression rows.

@RyanTheTide

RyanTheTide commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Re-review at 82a27e5e91eb2eb794f244366b6a1ebd42c9b21c. The source now retries when a successor instance is published. It still returns a persistent negative error, with the unplugged probe case limited to -ENODEV. This addresses my concern about concealing a stable service failure.

I checked A3’s J473 receipt. With the trial Aura SIO tables, the classic cookie route was accepted and both display PCM streams returned 0. Each pointer advanced from 31,744 to 200,192 frames during the silent run, with no SIO crash. That answers the link payload question for the tested pair. The production signed Aura path and active external-display peer receipts remain to run.

@RyanTheTide

RyanTheTide commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Playback path, production shape (audio-a4): this PR's head 82a27e5e as a module, plus the SIO fix in its final form (no firmware-version selector). The boot loader passes both SIO table layouts (aurora-silicon/aura#495 at e6d3b082), and the SIO driver sends the one that matches the protocol the firmware reports (#3051). On the J473 (27.2): "SIO protocol v10", and both HDMI/DP PCMs stream zero samples (hw_ptr 31232 to 199680 in 4.2 s, pw-cat rc 0, slave config 0) with no SIO crash. Enforcing, 0 AVC.

A -20 dBFS tone row into the monitors' 3.5 mm jacks played (rc 0 on both), but the buildbox line-in recorded nothing on either channel. That cable needs a physical check before an audible-content proof is possible.

@RyanTheTide

RyanTheTide commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Resume note from the #3051 J473 rows, which ran this head 82a27e5e as a module with 2 s2idle cycles of 12 s each. On each resume, the DP DCP (231c00000) first refuses the pre-sleep audio service on ep 0x29: DCPAVAudioInterface ... cmd 4 returned retcode 0xe00002d7, and error opening audio service: -22 is logged twice per resume. It then publishes a successor DCPAVAudioInterface on a new channel, and av_service_connect connects with plugged:1. Sleep is 2/2 and the HDMI DCP is unaffected. So this is err-level noise during the successor handoff, not a failure. Before this leaves draft, it should go through the same successor wait as the PCM-open path, or at least log quietly. Evidence: traces/display/20261124-m2mini-display-full/sio3051-v10/4-kernel-journal.txt (around 100.08 s and 108.07 s).

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Follow-up design for the resume noise, written down rather than coded yet. av_service_connect() cannot tell this refusal from a real failure when it happens: the successor DCPAVAudioInterface is published about 1 to 8 ms later, and the connect may run on the resume path, where it must not wait the AV_AUDIOSRV_REPLACE_MS second that dcp_audiosrv_replaced() waits.

The clean fix is an owner work with a deadline. On a refused Open, record the refused generation and the error and arm the work for AV_AUDIOSRV_REPLACE_MS. If asrv->gen has moved on by then, the successor's own connect handles it and the refusal is logged at debug level. Otherwise the existing error opening audio service line is logged. A real persistent failure therefore still reaches err level, which keeps your earlier point about not masking errors.

The work has to join the owner-work lifecycle: av_audiosrv_flush_owner(), drain/block_owner_restart, reports_restart enable/disable, and av-lifetime-test.c coverage. That is why it goes in a separate commit with a J473 sleep row (kit kits/test/20261124-m2mdf-audio87e, run.sh j473 <row> 2 0), not a quick logging change.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Code review of head 82a27e5e91eb found one blocking issue in the dcp_pcm_open() replacement wait:

dcp_pcm_open() blocks uninterruptibly for 1000 ms on -ENODEV / persistent errors, plus unpaired lockless writes

  • Locations:
    • drivers/gpu/drm/apple/audio.c:431-458 (dcp_pcm_open)
    • drivers/gpu/drm/apple/av.c:101-113 (dcp_audiosrv_replaced)
    • drivers/gpu/drm/apple/av.c:188, 190, 219, 221 (av_service_connect / av_service_teardown)
  • Scenario:
    • When dcpaud_read_remote_info() fails for any reason (ret < 0) — including -ENODEV on an unplugged monitor where asrv->srv is already NULL, or -ENOMEM — dcp_pcm_open() unconditionally calls dcp_audiosrv_replaced(dcpaud->dcp_dev, gen).
    • dcp_audiosrv_replaced() executes wait_event_timeout(asrv->gen_wq, READ_ONCE(asrv->srv) && READ_ONCE(asrv->gen) != gen, msecs_to_jiffies(1000)).
    • Because asrv->srv == NULL on teardown, wake_up_all(&asrv->gen_wq) in teardown cannot satisfy the predicate, so every open against an unplugged audio device (or any persistent failure) stalls the calling userspace audio daemon (e.g. PipeWire/WirePlumber probing PCMs) in uninterruptible sleep (TASK_UNINTERRUPTIBLE) for a full 1000 ms.
    • Additionally, av.c:188, 190, 219, 221 write asrv->srv and asrv->gen with plain assignments while dcp_audiosrv_replaced() reads them locklessly via READ_ONCE().
  • Suggested fix:
    1. Only wait for audio-service replacement when a live service refused the open (or when the connector is still connected and ret is the expected refusal error, not -ENOMEM or disconnected -ENODEV), and use wait_event_interruptible_timeout() so callers remain killable/interruptible.
    2. Pair the READ_ONCE() in dcp_audiosrv_replaced() with WRITE_ONCE() on asrv->srv and asrv->gen in av.c:188, 190, 219, 221 (with smp_wmb()/smp_rmb() or a helper taking srv_rwsem).

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

On your blocker 4, I previously said the predicate leaves the J615 and J713 unaffected. That was imprecise. Checked at 82a27e5e, with live logs from the lab Macs:

  • Where the predicate changes. It changes only for a firmware-27 DCP with DPTX ports on the classic DPTX_ENDPOINT. The J615 (T8122) and the J713 (T8132) external DCPs are in that set, like the J473: their logs say firmware 27: DPTX controller on 0x24, ports on 0x2a (advertised). The Neo (remote port on 0x2c, DPTX_ENDPOINT_V2), the T6050/T6041 firmware-27 DCPEXTs (V2), the J616s (26.6 desktop) and the 13.x Macs keep their current role.
  • Why nothing changes on the J615/J713.
    • av_init() picks the role, then returns 0 before starting any endpoint when port@0 links no audio device. Neither Air has a dp-audio node: no apple_dcp sound card on either, live.
    • dcp_cec_init_avep() applies only to an HDMIA connector, and both Airs are DP over USB-C.
    • afk_compact_capable() only concerns an AFK endpoint on 0x2b, which neither Air creates under either predicate.
    • So the same code paths run there before and after this PR.
  • Where it does change, it is tested. On the J473 (T8112, the one classic-layout firmware-27 DCP with a dp-audio node) the change is the fix. Exact-head rows:
    • audio-a4: both PCMs stream.
    • sio3051-v10: both PCMs stream, s2idle 2/2.
    • sio3051-old: firmware-only SIO; DCP side unchanged.
      The classic cookie link was accepted (your blocker 3).
  • Remaining. The resume-time refusal log for the replaced service is cosmetic, and recovery works (successor connects). I'll fix it in a follow-up commit with the deadline-work design above rather than block the audio fix. If you'd rather have it in this PR, say so.

Taking this out of draft. With linux#3051 merged and aura#495 approved, this is the last piece for HDMI/DP audio on the J473 default.

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 24, 2026 14:44
@RyanTheTide
RyanTheTide requested review from a team as code owners November 24, 2026 14:44
@RyanTheTide
RyanTheTide requested review from DjDeveloperr, LiamRay11 and malik-na and removed request for LiamRay11 November 24, 2026 14:44

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at 82a27e5e91eb
Blockers:

  1. drivers/gpu/drm/apple/audio.c:446, drivers/gpu/drm/apple/av.c:188-190,219-221,362-374: dcp_pcm_open() unconditionally calls dcp_audiosrv_replaced() on every dcpaud_read_remote_info() < 0 (including real-unplug -ENODEV, -ENOMEM, -ETIMEDOUT, and stable -EINVAL), blocking userspace in uninterruptible sleep (wait_event_timeout) for a full 1000 ms, while av_audiosrv_init() / av_audiosrv_teardown() write asrv->srv and asrv->gen with plain assignments against lockless READ_ONCE() (KCSAN data race). Guard the replacement wait so non-refusal / already-disconnected errors do not stall, use wait_event_interruptible_timeout(), and pair WRITE_ONCE() (or take srv_rwsem in a helper) for asrv->srv and asrv->gen.
  2. drivers/gpu/drm/apple/av.c:171-237,1095-1135,1182-1185,1486-1490: Classic-path asrv->is_open is never cleared when DCPAVAudioInterface is replaced in av_audiosrv_init() or removed in av_audiosrv_teardown(), and __av_service_disconnect() returns early if asrv->srv is already NULL; replacing an already-open classic audio service therefore skips both cmds.open and dcpaud_connect() on the successor. Clear asrv->is_open on replacement/teardown (or track the opened service/generation as the native path does), and drop the #if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) guard around case DCP_FIRMWARE_V_27_0: in avep_init() so disabling that option does not leave dcp_av_audio_cmds_v27 unused and fail classic firmware-27 audio with -ENODEV.
  3. §4 Attribution hygiene: PR comments #7125168710 and #7126495776 still carry AI attribution footers. Remove them so zero AI attribution remains anywhere on the PR (commits, PR title, and PR body are clean).
  4. §5 Evidence & PR body hygiene: Update the PR body from the stale cf3d0b9b draft text to the required What: / Tested: (exact head SHA + Mac + result) / Risk: (door + affected Macs) / Not yet: format, add an exact-head no-regression row on at least one other Mac sharing this code path (a 13.x/14.x HDMI Mac or a firmware-27 desktop-role DPTX_ENDPOINT_V2 Mac), and resolve the 2x per-resume error opening audio service: -22 (0xe00002d7) dev_err logs observed in J473 sio3051-v10 (0 new kernel errors required for §5; folding the deadline-work fix from #7133317550 into the next push covers this cleanly).

Checked: §1 pass (J615/J713/Neo/J616s/J473 predicate scope verified), §2–§3 pass (external DP/HDMI audio only, default cmdline), §4 commits/title/body clean / 2 comments flagged, §5 J473 streaming proven (audio-a4, sio3051-v10) / PR body stale + cross-Mac row & resume error logs open, §6 pass; MERGEABLE against main; CI at 82a27e5e91eb: kunit PASS, host-tests PASS, readiness / readiness pending (45417547564).

Evidence
  • Delta since prior review (cf3d0b9b973e → 82a27e5e91eb):
    • Prior blocker 1 (merge conflict): resolved in 7f24979bbc0d; PR is MERGEABLE against main.
    • Prior blocker 2 (open_unplugged / cookie invariant + broad error masking): partially resolved in 82a27e5e91eb (-ENODEV now invalidates open_cookie so dcpaud_connection_up() is false for hw_free and dcp_pcm_native_start, and dcpaud-open-fallback-tests.py covers 9 cases / 4 mutations), but the replacement wait introduced blocker 1 above, and the classic-path asrv->is_open lifecycle bug remains unfixed (blocker 2).
    • Prior blocker 3 (firmware-27 classic link payload/lifecycle): resolved — J473 exact-head rows audio-a4 and sio3051-v10 (paired with merged aurora-silicon/linux#3051 and merged aurora-silicon/aura#495) confirm the classic cookie link payload and lifecycle stream cleanly on both HDMI and DP PCMs (hw_ptr 31232 → 199680 in 4.2 s, pw-cat rc 0, dmaengine_slave_config 0, Enforcing, 0 AVC, 0 failed units).
    • Prior blocker 4 (dcp_is_v27_external() scope): resolved — live logs confirm J615 (t8122-dcpext) and J713 (t8132-dcpext) advertise classic DPTX_ENDPOINT and have neither dp-audio DT nodes nor HDMIA connectors, while Neo (DCP_FIRMWARE_H17P), J616s (DCP_FIRMWARE_V_26_6_DESKTOP), 13.x/14.x Macs, and t6050/t6041 fw27 (DPTX_ENDPOINT_V2) keep their existing roles.
  • Commit hygiene (fc96d3c3, cf3d0b9b, 7f24979b, 82a27e5e): all 4 commits have human author/committer (Ryan Murray <ryan@aurorasilicon.org>) and human Signed-off-by:, zero AI attribution.
  • CI at 82a27e5e91eb2eb794f244366b6a1ebd42c9b21c: Apple DRM KUnit (kunit) SUCCESS, Host tests (host-tests) SUCCESS, earlier readiness / readiness (45396590891) SUCCESS, latest readiness / readiness (45417547564) PENDING after leaving draft.
  • Note on dcp_pcm_open() retry ordering: av_audiosrv_init() calls wake_up_all(&asrv->gen_wq) before schedule_work(&asrv->start_av_service_wq), so a woken dcp_pcm_open() can sample dcpaud->connected / read get_elements on the successor before av_service_connect() completes cmds.open and dcpaud_connect(). Safe for profile discovery (if dcpaud_connect() runs later, connection_cookie advances cleanly), worth keeping in mind when updating the replacement wait.

…n a refusal

Review fixes for the firmware-27 classic audio path:

- A classic Open belongs to the instance it was made on: clear is_open
  when the service is replaced or removed, so the successor's connect
  opens it and connects the card (it skipped both).
- Firmware 27's classic command table no longer depends on
  CONFIG_DRM_APPLE_DCP_T6030_AUDIO: without it, the J473 (T8112) failed
  its audio with -ENODEV.
- dcp_pcm_open() waits for a successor only when the firmware refused
  the read (-EINVAL, a non-zero retcode), not on a missing service, a
  timeout or no memory, and the wait is interruptible. asrv->srv and
  asrv->gen are written with WRITE_ONCE, as the wait reads them
  without the lock.
- The firmware refuses an Open on an instance it is replacing (each
  resume on the J473's DP processor, 0xe00002d7), and the successor's
  connect opens it within AV_AUDIOSRV_REPLACE_MS. Judge a refused
  classic Open then, in an owner delayed work: debug if the service
  was opened again or removed, the old error otherwise. The work joins
  the owner-work lifecycle (flush, disable on drain, enable on
  restart).

Host test: a non-refusal error with a successor published still fails
the open without a second read; the wait-any mutation is killed.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at 2ce8e3cd: ready to merge

Check Detail
CI at head ok 4 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at 2ce8e3cd
Conflicts ok none
PR text ok Risk: two-way · (driver-only, revertable). Macs: J473 (T8112, firmware 27, the change). J615/J713 external DCPs (firmware 27, classic layout) change role but take the same path: no dp-audio node, no HDMI-A, no 0x2b endpoint. Neo, T6041/T6050 firmware 27 (V2), J616s 26.6 desktop and 13.x/14.x Macs keep their role; the classic Open lifecycle fix applies to all classic-path Macs (M1 Pro row above).

Areas: area:display, area:gpu
Merge: gh pr merge 3050 --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.

@github-actions github-actions Bot added blast:all Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) and removed needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Verdict at 1b655c9f271fc2e4e227cf3ba542f7e6d4b06d17: Hold for classic audio owner state.

Blockers: The new generation reset can still be overwritten by a stale Open completion. av_audiosrv_init() publishes the successor and clears is_open under plug_lock. A prior av_service_connect() can return successfully from its pinned old service's RPC, take the lock afterward and mark the successor open without comparing the published service. The successor then skips its own Open. The disconnect path can likewise clear the successor's state after the old Close returns.

Checked: The refusal-only interruptible wait and persistent-error cases address the earlier unconditional wait. Please check that the pinned service still owns the published slot before the post-RPC state commit, under the existing lock order. Keep RPCs outside these locks so receive can progress. Initialize open_check_dev once with the containing DCP owner, since every refusal currently writes it while the delayed work can read it. Add a focused replacement/teardown interleaving control alongside the exact J473 and classic peer rows.

The CEC-only harness compiles av_service_connect(), which now defers judging a refused classic Open (-EINVAL) to a delayed work: give its stub audiosrv_data the new fields and stub the work call, and check that a refusal arms the check without an error, that another error is still reported at once, and that a later Open succeeds.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 24, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

All four blockers are addressed at 122cf4f3 (1b655c9f driver fixes + 122cf4f3 selftest):

  1. Replacement wait. dcp_pcm_open() now waits only on -EINVAL, the firmware's refusal (any non-zero retcode). -ENODEV, -ETIMEDOUT and -ENOMEM do not wait. The wait is wait_event_interruptible_timeout(), and asrv->srv/asrv->gen are written with WRITE_ONCE(). The host test has a new case (no memory, successor published: fails with one read) and a wait-any mutation; all 5 mutations are killed.
  2. Classic lifecycle. is_open is cleared on replacement (av_audiosrv_init() with an old instance) and on removal (av_audiosrv_teardown()), so the successor is opened and connected. The firmware-27 classic command table and its case are no longer under CONFIG_DRM_APPLE_DCP_T6030_AUDIO. I built av.o/audio.o with that option off, with no errors or new warnings.
  3. Attribution. Removed the footers from comments 7125168710 and 7126495776; none are left on the PR.
  4. Body, rows and resume logs.
    • The body is in What/Tested/Risk/Not yet form.
    • A refused classic Open is now judged by an owner delayed work after AV_AUDIOSRV_REPLACE_MS: debug if the service was opened again or removed, the old error otherwise. The work joins the owner lifecycle (flush, disable on drain, enable on restart; lifetime test initialises it). The cec-only-av-endpoint selftest covers it: a refusal arms the check without an error, another error is reported at once, and the next Open succeeds.
    • Rows: J473 (exact head, with merged ASoC: apple: draft playback energy contract and ledger prototype #495 source and dmaengine: apple-sio: Send a low-window SIO the tables for its protocol #3051): both PCMs stream, s2idle 2/2, 0 AVC, 0 error opening audio service lines. The firmware still refuses the pre-sleep instance at warn level, and each successor connects. M1 Pro (13.x HDMI DCP, classic path): both audio cards enumerate, s2idle 1/1, 0 AVC.

Local checks: Apple display KUnit 146/147 (1 skip), apple-dcp selftests 93/93, dcpaud/dpavserv/backlight-coldboot host subsets pass. Evidence: traces/display/20261124-m2mini-display-full/pr3050r-{v10,hdmi13}.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at 122cf4f39f6b

Blockers:

  • drivers/gpu/drm/apple/av.c:212-213,1099-1108,1140-1165,1247-1265: Classic-path asrv->is_open still races with concurrent replacement/teardown across the unlocked Open/Close RPCs:
    1. av_service_connect() reads asrv->is_open outside plug_lock (av.c:1107), runs cmds.open without locks, and unconditionally sets asrv->is_open = true and calls dcpaud_connect() (av.c:1159-1164) without checking that asrv->srv == service (taking srv_rwsem read inside plug_lock, matching the existing plug_lock → srv_rwsem order). If av_audiosrv_init() publishes a successor or av_audiosrv_teardown() clears asrv->srv while cmds.open is in flight, the stale completion marks is_open = true on the successor (or on srv == NULL, where a later av_audiosrv_init() with old == NULL skips if (old) asrv->is_open = false; at av.c:212), causing the successor to skip its own Open and dcpaud_connect().
    2. __av_service_disconnect() reads asrv->is_open locklessly (av.c:1247) and unconditionally writes asrv->is_open = false outside plug_lock (av.c:1264) without verifying asrv->srv == service, so a stale Close completion can clear a newly opened successor's state and races with av_work_open_check() / av_service_connect().
    3. av_service_connect() stores asrv->open_check_dev = dcp->dev on every -EINVAL refusal (av.c:1150) without synchronization while av_work_open_check() reads asrv->open_check_dev (av.c:1324,1327).
    • Fix: Check asrv->is_open under plug_lock, verify asrv->srv == service under plug_lock + srv_rwsem read before committing asrv->is_open = true / dcpaud_connect() in av_service_connect() and before clearing asrv->is_open = false in __av_service_disconnect() (keeping RPCs outside both locks), clear asrv->is_open = false unconditionally in av_audiosrv_init(), and initialize open_check_dev = dcp->dev once in avep_init(). Add a replacement/teardown interleaving test case in tools/testing/selftests/drivers/gpu/apple-dcp/audio.py and refresh the J473 + classic peer hardware rows on the updated head.

Checked: Prior blockers 1, 3, and 4 from #6041584429 are cleanly resolved (dcp_pcm_open() refusal-only interruptible wait + WRITE_ONCE, zero AI attribution across commits/PR/comments, PR body format, J473 + M1 Pro rows at 122cf4f3 with 0 error opening audio service lines, CONFIG_DRM_APPLE_DCP_T6030_AUDIO=n build); MERGEABLE against main; CI at 122cf4f39f6b: kunit PASS, host-tests PASS, pr-text / pr-text PASS, readiness / readiness PASS.

Evidence
  • Delta since #6041584429 (82a27e5e91eb → 122cf4f39f6b):
    • Prior blocker 1 (dcp_pcm_open() wait & KCSAN): resolved — audio.c:448 now gates dcp_audiosrv_replaced() on ret == -EINVAL, av.c:380-383 uses wait_event_interruptible_timeout(), av.c:198-200,232-234 pair WRITE_ONCE() on asrv->srv and asrv->gen, and dcpaud-open-fallback-tests.py adds the -ENOMEM + successor test and wait-any mutation (5/5 mutations killed).
    • Prior blocker 2 (classic is_open & CONFIG_DRM_APPLE_DCP_T6030_AUDIO): partially resolved — case DCP_FIRMWARE_V_27_0: in avep_init() (av.c:1533-1535) is no longer gated on CONFIG_DRM_APPLE_DCP_T6030_AUDIO, and av_audiosrv_init() / av_audiosrv_teardown() clear is_open, but the unlocked RPC-completion races on asrv->is_open and the repeated asrv->open_check_dev write remain (blocker above).
    • Prior blocker 3 (§4 attribution hygiene): resolved — all 6 commits (fc96d3c36d44, cf3d0b9b973e, 7f24979bbc0d, 82a27e5e91eb, 1b655c9f271f, 122cf4f39f6b) carry human author/committer (Ryan Murray <ryan@aurorasilicon.org>) and human Signed-off-by:; PR title, body, and comments (#7125168710, #7126495776 cleaned) have zero AI attribution.
    • Prior blocker 4 (§5 PR body, resume error logs, cross-Mac row): resolved for 122cf4f3 — PR body uses What: / Tested: / Risk: / Not yet:, J473 row at 122cf4f3 (1b655c9f driver + test-only commit, with merged aura#495 + linux#3051) passes both PCMs + 2x s2idle + Enforcing + 0 AVC + 0 error opening audio service lines, and M1 Pro (J316s, 13.x classic path) passes enumeration + 1x s2idle + 0 AVC.
  • Checklist (§1–§6): §1 pass, §2 pass (pending blocker above), §3 pass, §4 pass, §5 pass at 122cf4f3 (will need refresh after the av.c fix commit), §6 pass.
  • CI at 122cf4f39f6b86caadc9eda39bddd3926ce76517: kunit (45427631939) SUCCESS, host-tests (45427631913) SUCCESS, pr-text / pr-text (45427634254) SUCCESS, readiness / readiness (45427623950) SUCCESS.
  • Non-blocking note: In av_audiosrv_flush_owner() (av.c:1330-1337), flushing start_av_service_wq before open_check_wq matches av_audiosrv_drain_owner() (av.c:1360-1361), since start_av_service_wq is what can arm open_check_wq.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 24, 2026
The classic Open and Close run without locks, so the published instance
may change under them. Read is_open under plug_lock, and commit an Open
(is_open, dcpaud_connect()) or a Close (dcpaud_disconnect(), clearing
is_open) only while the RPC's instance is still the published one,
checked under plug_lock then srv_rwsem, the order av_audiosrv_init()
takes them. A stale Open no longer marks the successor opened (which
then skipped its own Open and card connect), and a stale Close no
longer clears a successor's Open. Every publication starts the
instance unopened. The refusal check's device is set once at init.

The CEC-only selftest gains both interleavings: a Close whose instance
is replaced and the successor opened meanwhile, and an Open whose
instance is replaced meanwhile.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@github-actions github-actions Bot added the needs-hw-row No hardware row at the PR head (bot) label Nov 24, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Verdict at 2ce8e3cd0fb7fb3a68f99cc6bd8c1873bfd71b7e: FINISH, then merge.

Blockers: The previously reported stale Open/Close completion and delayed worker device-state findings are addressed. The pending checks are green CI and new-head J473 target / classic peer hardware evidence. The earlier exact target row remains evidence for 122cf4f3.

Checked: Each classic state commit now checks the published pinned instance under plug_lock then srv_rwsem. Both RPCs still run outside those locks. Publication clears the open bit and the delayed worker's device is initialized once. I retrieved this exact source and ran the existing CEC-only/classic lifecycle fixture, including both new replacement interleavings, and reply bounds with GCC and Clang (-Wall -Wextra -Werror). Four of four executions passed.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH at 2ce8e3cd0fb7

Blockers:

  • §5 exact-head hardware rows missing at 2ce8e3cd0fb7: 2ce8e3cd0fb7 changes runtime driver code (drivers/gpu/drm/apple/av.c), while the current Tested: rows in the PR body are from 122cf4f3 (1b655c9f module). Refresh the J473 (T8112, 27.2) target row (both PCMs streaming, s2idle, Enforcing, 0 AVC, 0 error opening audio service lines) and the classic-path peer row (e.g., M1 Pro J316s 13.x) at 2ce8e3cd0fb7, and record 2ce8e3cd in Tested:.

Checked: Zero code, safety, or policy blockers remain. The prior #6042574342 classic-path asrv->is_open / open_check_dev race in drivers/gpu/drm/apple/av.c is cleanly resolved (av_audiosrv_published() checks asrv->srv == service under plug_lock → srv_rwsem read before committing is_open/dcpaud_connect() and before disconnecting/clearing is_open; RPCs stay outside both locks; av_audiosrv_init() clears is_open unconditionally; open_check_dev is initialized once in avep_init()); audio.py covers both replacement interleavings; MERGEABLE against main; all CI checks green at 2ce8e3cd0fb7; zero AI attribution across all 7 commits, PR title/body, and comments.

Evidence
  • Delta since #6042574342 (122cf4f39f6b → 2ce8e3cd0fb7):
    • drivers/gpu/drm/apple/av.c:212: av_audiosrv_init() now clears asrv->is_open = false unconditionally under plug_lock.
    • drivers/gpu/drm/apple/av.c:1085-1090,1115-1117,1173-1179: av_service_connect() reads asrv->is_open under plug_lock, keeps cmds.open outside both locks, and verifies av_audiosrv_published(asrv, service) (plug_lock → srv_rwsem read; pinned slot cannot be reclaimed via afk_service_reinit() while service->users > 0) before setting asrv->is_open = true and calling dcpaud_connect().
    • drivers/gpu/drm/apple/av.c:1264-1283: __av_service_disconnect() checks asrv->is_open && av_audiosrv_published(asrv, service) under plug_lock before dcpaud_disconnect() and cmds.close, keeps cmds.close outside locks, and verifies av_audiosrv_published(asrv, service) under plug_lock before clearing asrv->is_open = false.
    • drivers/gpu/drm/apple/av.c:1159-1162,1575: audiosrv_data->open_check_dev = dcp->dev is initialized once in avep_init(), removing the unsynchronized write on -EINVAL.
    • tools/testing/selftests/drivers/gpu/apple-dcp/audio.py:168-281: compiles av_audiosrv_published(), av_service_connect(), __av_service_disconnect(), and av_service_disconnect() from av.c, and exercises both a stale Close and a stale Open interleaved with replacement (hook = 2 and hook = 1).
  • Checklist (§1–§6): §1 pass (DPTX_ENDPOINT_V2 layout property, no model/fw-version gates), §2 pass, §3 pass, §4 pass (all 7 commits authored/committed by Ryan Murray <ryan@aurorasilicon.org> with human Signed-off-by:; zero AI attribution in commits/PR/comments), §5 pending exact-head hardware rows at 2ce8e3cd0fb7, §6 pass.
  • CI at 2ce8e3cd0fb7fb3a68f99cc6bd8c1873bfd71b7e: kunit (45431301327, 146/147 passed, 1 skipped) SUCCESS, host-tests (45431301352, apple-dcp ok, dcpaud-open-fallback-tests + 5/5 mutations killed) SUCCESS, pr-text / pr-text (45431301818) SUCCESS, readiness / readiness (45431298344) SUCCESS.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Race fixed at 2ce8e3cd:

  • av_service_connect() reads is_open under plug_lock, runs the Open with no lock held, then commits is_open = true and dcpaud_connect() only if the RPC's instance is still the published one. That check is av_audiosrv_published(): plug_lock, then srv_rwsem read, the same order av_audiosrv_init() takes them.
  • __av_service_disconnect() takes the same check under plug_lock before dcpaud_disconnect() and the Close, and clears is_open after the Close only if the instance is still published.
  • av_audiosrv_init() clears is_open on every publication, and open_check_dev is set once in avep_init().
  • Selftest cec-only-av-endpoint adds both interleavings: a Close whose instance is replaced and the successor opened during the RPC (the successor stays open), and an Open whose instance is replaced during the RPC (nothing is committed). A mutant whose published check always says yes fails it.

Local checks: apple-dcp 93/93, Apple display KUnit 146/147 (1 skip), dcpaud/dpavserv/backlight-coldboot subsets pass, and a build with CONFIG_DRM_APPLE_DCP_T6030_AUDIO=n succeeds.

Rows at the exact head:

Evidence: traces/display/20261124-m2mini-display-full/pr3050s-{v10,hdmi13}. CI at 2ce8e3cd: host-tests, kunit, pr-text and readiness all pass.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 24, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 2ce8e3cd0fb7

Blockers: none

Checked: Exact-head 2ce8e3cd0fb7 hardware rows are now recorded in Tested: and comment #7137642680 for both J473 (T8112, 27.2: both HDMI/DP PCMs streaming, s2idle 2/2, Enforcing, 0 AVC, 0 audio-service open/close errors) and M1 Pro (13.x HDMI DCP classic path: both audio cards enumerate, s2idle 1/1, 0 AVC), and all 4 CI checks (kunit, host-tests, pr-text / pr-text, readiness / readiness) pass. Code, av.c is_open/open_check_dev locking fixes, audio.py interleaving selftests, and attribution/policy checks already passed at this exact head in #6043021911.

Evidence
  • Head: 2ce8e3cd0fb7fb3a68f99cc6bd8c1873bfd71b7e (OPEN, non-draft, MERGEABLE)
  • CI: kunit SUCCESS, host-tests SUCCESS, pr-text / pr-text SUCCESS, readiness / readiness SUCCESS
  • Hardware evidence: J473 (T8112, 27.2) + M1 Pro (13.x classic path) at 2ce8e3cd0fb7

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 24, 2026
@RyanTheTide
RyanTheTide merged commit d37a486 into main Nov 24, 2026
8 checks passed
@RyanTheTide
RyanTheTide deleted the m2mini/v27-classic-audio 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) area:gpu Area from CODEOWNERS (bot) blast:all 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.

2 participants