Skip to content

drm/apple: av: fix a boot oops that leaves no display device when an HDMI port has CEC but no audio - #2733

Merged
DjDeveloperr merged 1 commit into
aurora-silicon:integration/aurorafrom
funkzy:pr/appledrm-cec-avep
Nov 21, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-silicon:integration/aurorafrom
funkzy:pr/appledrm-cec-avep

Conversation

@funkzy

@funkzy funkzy commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Since native HDMI-CEC (#2230), an HDMI port whose HDMI audio is not started gets its AV endpoint for CEC alone:
dcp_cec_init_avep() sets dcp->avep, and no audio owner (dcp->audiosrv) exists. The display code calls
av_service_connect() and av_service_disconnect() whenever dcp->avep is set, and both take the audio owner's
rwsem first. So the first DP-to-HDMI connect at bind dereferences a NULL owner, appledrm never finishes binding, and
the machine boots with no /dev/dri and no desktop.

This happens on every boot of the Mac Studio (M5 Ultra), whose HDMI port has no audio device linked in its device
tree. By the same path it should happen on any HDMI-CEC board booted with appledrm.hdmi_audio=0; that case is from
reading the code and has not been booted.

Unable to handle kernel NULL pointer dereference at virtual address 0000000000000048
 down_write
 av_service_connect [appledrm]
 dcp_dptx_connect_raw [appledrm]
 dcp_dptx_connect [appledrm]
 dcp_enable_dp2hdmi_hpd [appledrm]
 dcp_wait_ready [appledrm]
 apple_drm_init_dcp [appledrm]
 apple_drm_bind [appledrm]

Change

av_service_connect() and __av_service_disconnect() return when the endpoint has no audio owner: there is no
audio service to connect or disconnect. The other AV audio paths already check for the owner
(av_audio_before_modeset(), av_video_init(), dcp_audiosrv_close()), and the !CONFIG_DRM_APPLE_AUDIO stubs
already make these two no-ops. The callers stay keyed on the endpoint, which CEC still uses. A display processor
with an audio owner runs the same code as before. One commit, with Fixes: on 7577337.

Why the check is in the two entry points, not in the callers

The calls keyed on dcp->avep are in dcp.c (link connect and disconnect, link recovery and park, display power on
and off, external stop, suspend, resume and unbind: 12 sites) and iomfb_v14_7.c (the mode set and power-off: 5 sites, four of them through dcp_v14_audio_on/off()). All
of them reach the audio service through these two functions, and they are the only two audio entry points in av.c
that do not check for the owner. The sound driver's calls (dcp_audiosrv_prepare() and the rest) and the audio
service ops run only on an endpoint the audio code started, because the CEC endpoint has its own ops table. Changing
the 17 callers to test dcp->audiosrv would leave the same assumption in any new caller, and would touch code in
many open drm/apple PRs.

The commit also adds a host test, cec-only-av-endpoint in the apple-dcp group. It calls both functions on a
CEC-only endpoint, for the classic and the native link. With an audio owner it checks that the service is opened
once and closed once, the firmware 27 native-link start runs once per instance, and the service pins and locks
balance.

Testing

Mac Studio (M5 Ultra, J775D), the default command line, a read-only root, one boot per kernel.
Both kernels are integration/aurora's head of today (the merge of #2654). The second one adds this commit and nothing
else.

integration/aurora + this commit
boot oops at 3.3 s in av_service_connect() from apple_drm_bind() no oops, BUG or WARNING
appledrm stuck loading, no /dev/dri card0 (platform-display-subsystem-card)
HDMI output (capture device on the port) no signal HDMI-A-1 connected, 1920x1080@60
DPMS off/on, 3 cycles (console blank/unblank) n/a 3/3: connector Off then On, the display powered on and its mode set again each time, 0 warnings
CEC /dev/cec0 /dev/cec0 (apple-dcp, physical address 1.0.0.0, CEC 2.0); took logical address 4 as a playback device
failed units iwd, systemd-networkd-persistent-storage the same two (read-only root)
kernel error lines the oops, plus the HDMI lane-count line 3, the same as on this base with the same fix earlier today: the HDMI lane-count line, an undeclared provider clock, a receiver with no listeners. 0 new

ALARM has no SELinux, so there is no AVC count.

Neither kernel has a render node, so neither reaches a desktop: the J775D GPU node comes with #1973. Earlier today,
the same driver change with #1973 on the same base gave renderD128, the desktop up, and the render CTS subset at 571
Pass, 57 NotSupported, 0 Fail.

Checks
  • scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.
  • apple-dcp host group (run.py --group audio): 2/2 with the commit. Without the av.c change the new test fails, as
    the Mac Studio did: UBSan reports a member access within a NULL struct audiosrv_data at the rwsem.
  • tools/asahi/run-host-tests.py (gcc 15, clang 21): 451/451 on the base and 451/451 with this commit, 0 runs
    differ. The apple-dcp group, which now includes the new case, passes.

Still to run

  • HDMI audio started. @astaff, could you run a row on a Mac whose HDMI audio is started, for example your J616c?
    The interesting cases are HDMI audio playing across an HDMI unplug and replug, and a DPMS off/on while it plays.
    That path should run the same code as before, and that row would show it.
  • Another Mac with HDMI. @RyanTheTide, the M1 Pro, M2 or M4 Pro HDMI rows you offered on drm/apple: add native HDMI-CEC and 2 ms IRQ_HPD pulse tracking #2230 (hotplug x5,
    s2idle with the sink attached) would cover a non-M5 board on this commit.
  • HDMI hotplug on the Mac Studio. Its HDMI sink is a capture device that can't be replugged remotely, so the
    hotplug path has run here only at bind.

Assisted-by: LLM (Claude:Opus 5.5)

…HDMI port has CEC but no audio

On a display processor with an HDMI-A connector whose HDMI audio is not
started (no audio device linked to its port, as on the Mac Studio
(M5 Ultra), or appledrm.hdmi_audio=0), connecting the DP-to-HDMI link at
bind oopses, and appledrm never binds: no /dev/dri, no desktop. On the
Mac Studio every boot does this:

  [    3.475771] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000048
  [    3.480673] Call trace:
  [    3.480724]  down_write (P)
  [    3.480810]  av_service_connect [appledrm]
  [    3.481023]  dcp_dptx_connect_raw [appledrm]
  [    3.481239]  dcp_dptx_connect [appledrm]
  [    3.481441]  dcp_enable_dp2hdmi_hpd.isra.0 [appledrm]
  [    3.481658]  dcp_wait_ready [appledrm]
  [    3.481856]  apple_drm_init_dcp [appledrm]
  [    3.482063]  apple_drm_bind [appledrm]

In that case dcp_cec_init_avep() starts the AV endpoint for CEC alone,
so dcp->avep is set while no audio owner (dcp->audiosrv) exists. The
display code calls av_service_connect() and av_service_disconnect()
whenever dcp->avep is set (connect, disconnect, mode set, suspend,
resume and teardown), and both take the audio owner's rwsem at once.

Check for the audio owner in these two entry points, as the other AV
audio paths already do (av_audio_before_modeset(), av_video_init(),
dcp_audiosrv_close()) and as the !CONFIG_DRM_APPLE_AUDIO stubs make
them no-ops: without an owner there is no audio service to connect or
disconnect. The callers stay keyed on the endpoint, which CEC still
uses. A processor with an audio owner runs the same code as before.

Add a host test that calls both on a CEC-only endpoint, and with an
owner checks the classic and native-link open and close.

Fixes: 7577337 ("drm/apple: add native HDMI-CEC and 2 ms IRQ_HPD pulse tracking")
Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor

The fix is right, and putting it in the two entry points is the better place: all 17 callers go through them. I checked whether the early return could skip a connect that matters later. In dcp.c the audio endpoint (avep_init(), which sets dcp->audiosrv) is always tried first, and dcp_cec_init_avep() only runs when that left dcp->avep unset. So a port's audio owner exists from init or never, and nothing creates it after a CEC-only endpoint has already skipped a connect. The only other writer clears it at teardown, where returning early is the safe outcome too. The UBSan reproduction in the host test without the fix is a good touch.

On the rows you asked for: none of our M1 Pro, M2 or M4 Pro (J616s) has an HDMI sink attached at the moment. The J616s's HDMI port is empty, as recorded in the #2230 CEC row. With no sink, av_service_connect() isn't reached, so a boot there wouldn't exercise this change. I won't post an empty row. A Mac whose HDMI audio is started, with a sink, as you asked of the J616c, is the row that covers the unchanged path.

Assisted-by: LLM (Claude:Opus 5.5)

@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.

Reviewed head 58904c7aa78cf8ac9860343909b0e0043b5e878b against the pre-PR checklist.

Code & lifecycle audit

  • NULL audio owner guards (drivers/gpu/drm/apple/av.c): Guarding if (!asrv) return; at the entry of av_service_connect() and __av_service_disconnect() cleanly covers all 17 dcp->avep-gated callers across dcp.c (connect/disconnect, OOB connect/disconnect, external stop, Type-C relink/park, poweron/poweroff, suspend/resume, and unbind) and iomfb_v14_7.c (modeset and poweroff) before taking &asrv->srv_rwsem.
  • Remaining av.c entry points & CEC isolation: Audited the other av.c paths: av_audio_before_modeset(), av_video_init()/av_video_teardown(), av_audiosrv_quiesce(), av_audiosrv_reports_restart(), and the dcp_audiosrv_* native-link/catalog helpers all already guard against a NULL dcp->audiosrv. dcp_cec_init_avep() installs dcp_cec_desktop_ops, so av_audiosrv_* / av_interface_teardown EPIC callbacks never run on a CEC-only endpoint, and avep_init() is always tried before dcp_cec_init_avep(). Even if avep_init() returns early after populating dcp->audiosrv without an audio_pdev and CEC then starts dcp->avep, asrv->srv is NULL and both functions exit safely without RPCs.
  • No regression for audio-capable / audio+CEC endpoints: When dcp->audiosrv is present, both functions execute the exact same classic and native-link paths as before.
  • Host test (tools/testing/selftests/drivers/gpu/apple-dcp/audio.py, run.py): cec-only-av-endpoint extracts the real production av_service_connect, __av_service_disconnect, and av_service_disconnect bodies and covers CEC-only (classic + native/v27), classic audio owner open/close idempotency, firmware 27 native-link single-start + teardown ordering, asrv->srv == NULL, and pin/lock balance.

Pre-PR checklist

  • No model gating: Pure structural dcp->audiosrv check; no SoC/board/fw gates.
  • Production-ready, no hacks: Works on default kernel cmdline; no parameters, sleeps, or workarounds.
  • Clean-room & attribution: Clean-room; single commit with human identity (Jeff Queisser), human Signed-off-by:, accurate Fixes: 75773377faae, no agent commit trailers; PR body ends with Assisted-by: LLM (Claude:Opus 5.5).
  • Evidence & CI: Clear before/after J775D (Mac Studio M5 Ultra) hardware row on default cmdline (boot oops eliminated, card0 bound, 1920x1080@60 HDMI, 3/3 DPMS cycles, /dev/cec0 PA 1.0.0.0 / LA 4, 0 new kernel errors) and Host tests/host-tests CI green (SUCCESS). Note that the requested HDMI-audio-started regression row on another board remains listed under "Still to run" and is worth capturing when a board with an attached HDMI sink is available, though this fix is strictly a no-op when dcp->audiosrv != NULL.

Assisted-by: LLM (Google:Gemini 4 Neon)

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.

3 participants