Repository navigation
drm/apple: av: fix a boot oops that leaves no display device when an HDMI port has CEC but no audio - #2733
Conversation
…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>
|
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 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, Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Reviewed head 58904c7aa78cf8ac9860343909b0e0043b5e878b against the pre-PR checklist.
Code & lifecycle audit
- NULL audio owner guards (
drivers/gpu/drm/apple/av.c): Guardingif (!asrv) return;at the entry ofav_service_connect()and__av_service_disconnect()cleanly covers all 17dcp->avep-gated callers acrossdcp.c(connect/disconnect, OOB connect/disconnect, external stop, Type-C relink/park, poweron/poweroff, suspend/resume, and unbind) andiomfb_v14_7.c(modeset and poweroff) before taking&asrv->srv_rwsem. - Remaining
av.centry points & CEC isolation: Audited the otherav.cpaths:av_audio_before_modeset(),av_video_init()/av_video_teardown(),av_audiosrv_quiesce(),av_audiosrv_reports_restart(), and thedcp_audiosrv_*native-link/catalog helpers all already guard against a NULLdcp->audiosrv.dcp_cec_init_avep()installsdcp_cec_desktop_ops, soav_audiosrv_*/av_interface_teardownEPIC callbacks never run on a CEC-only endpoint, andavep_init()is always tried beforedcp_cec_init_avep(). Even ifavep_init()returns early after populatingdcp->audiosrvwithout anaudio_pdevand CEC then startsdcp->avep,asrv->srvis NULL and both functions exit safely without RPCs. - No regression for audio-capable / audio+CEC endpoints: When
dcp->audiosrvis 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-endpointextracts the real productionav_service_connect,__av_service_disconnect, andav_service_disconnectbodies 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->audiosrvcheck; 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), humanSigned-off-by:, accurateFixes: 75773377faae, no agent commit trailers; PR body ends withAssisted-by: LLM (Claude:Opus 5.5). - Evidence & CI: Clear before/after J775D (Mac Studio M5 Ultra) hardware row on default cmdline (boot oops eliminated,
card0bound, 1920x1080@60 HDMI, 3/3 DPMS cycles,/dev/cec0PA 1.0.0.0 / LA 4, 0 new kernel errors) andHost tests/host-testsCI 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 whendcp->audiosrv != NULL.
Assisted-by: LLM (Google:Gemini 4 Neon)
92fd860
into
aurora-silicon:integration/aurora
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()setsdcp->avep, and no audio owner (dcp->audiosrv) exists. The display code callsav_service_connect()andav_service_disconnect()wheneverdcp->avepis set, and both take the audio owner'srwsem 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/driand 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 fromreading the code and has not been booted.
Change
av_service_connect()and__av_service_disconnect()return when the endpoint has no audio owner: there is noaudio 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_AUDIOstubsalready 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->avepare in dcp.c (link connect and disconnect, link recovery and park, display power onand 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()). Allof 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 audioservice 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->audiosrvwould leave the same assumption in any new caller, and would touch code inmany open drm/apple PRs.
The commit also adds a host test,
cec-only-av-endpointin the apple-dcp group. It calls both functions on aCEC-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.
av_service_connect()fromapple_drm_bind()/dev/dricard0(platform-display-subsystem-card)/dev/cec0/dev/cec0(apple-dcp, physical address 1.0.0.0, CEC 2.0); took logical address 4 as a playback deviceALARM 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 571Pass, 57 NotSupported, 0 Fail.
Checks
scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.run.py --group audio): 2/2 with the commit. Without the av.c change the new test fails, asthe Mac Studio did: UBSan reports a member access within a NULL
struct audiosrv_dataat the rwsem.tools/asahi/run-host-tests.py(gcc 15, clang 21): 451/451 on the base and 451/451 with this commit, 0 runsdiffer. The apple-dcp group, which now includes the new case, passes.
Still to run
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.
s2idle with the sink attached) would cover a non-M5 board on this commit.
hotplug path has run here only at bind.
Assisted-by: LLM (Claude:Opus 5.5)