Repository navigation
drm/apple: afk: retire a superseded singleton AV service - #3175
Conversation
On the classic AV endpoint, DCP firmware 27.2 announces its DCPAVSimpleVideoInterface and DCPAVAudioInterface again on fresh channels every time the display comes back (DPMS on, wake, re-attach) and never closes the previous channels. The old instances stayed enabled, so their slots were never reclaimed. After eight attaches a Mac mini (M2) used all 16 service slots of the endpoint, logged "no reusable service slots" and lost monitor audio until reboot. The compact path already replaces such re-announced services in place (afk_compact_slot()). Do the same on the classic path for services that are singletons, one live instance per endpoint: an announcement on a new channel retires the previous instance, and its slot is reclaimed once its last user lets go. The successor's init takes over the service's state, as before. Firmware that closes the old channel first is unaffected: its instance is already torn down. Mark the classic AV video and audio interfaces as singletons, and add a KUnit test that re-announces them many more times than there are slots. Signed-off-by: Ryan Murray <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Audited full diff across afk.h, afk.c, av.c, afk-service-test.c, and edid.py: cleanly retires superseded singleton AV instances on fresh channel re-announcement without disturbing pinned active users or non-singleton/different services, with solid KUnit coverage and J473 46-announcement verification. Holding merge until CI completes green and the 13.5-firmware row is posted.
afk_recv_handle_init() now supersedes the previous instance of a singleton service and drops its debugfs entry. Give the host model the ops flag, the helper and a debugfs stub, as the apple-dcp model has. Signed-off-by: Ryan Murray <[email protected]>
DjDeveloperr
left a comment
There was a problem hiding this comment.
Re-approved at 5938e9e: the host-test stub update in tools/asahi/dcpext26-startup-tests.py cleanly mirrors the new singleton flag, afk_remove_service_debugfs(), and afk_service_supersede().
|
|
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict at 5938e9e5
The replacement-admission error path needs a follow-up.
Blocker
afk_recv_handle_init() retires the active singleton before it has reserved a slot for the replacement. When every slot is pinned or has a pending command, the allocation loop can return without a successor. The audio owner still holds the previous service, but that service has been disabled and retired. The successor's init callback never runs to replace the published audio reference.
Retain the active service through replacement admission. Add a regression case that fills the available slots while an audio owner reference and a pending command are still present, rejects the replacement, and verifies the previous service remains usable.
Checked
The standalone host model exercised the current service lifetime helpers. The successful reattach hardware row covers normal admission. The model covers failed admission.
Evidence
The model starts with an enabled audio singleton on channel 7 with one owner reference, and a separate retired slot with an outstanding command. A singleton announcement on channel 11 retires channel 7. Both slots then fail the reclaimability check. The result was zero admitted replacements, zero availability for channel 7, its owner count still one, and its retired flag set.
What: On the classic AV endpoint, DCP firmware 27.2 announces
DCPAVSimpleVideoInterfaceandDCPAVAudioInterfaceagain on fresh channels every time the display comes back (DPMS on, wake, re-attach). It never closes the old channels. The old instances stayed enabled, so their service slots were never reclaimed. After eight attaches the endpoint's 16 slots were used up ("no reusable service slots") and monitor audio was gone until reboot. This change marks the two classic AV services as singletons. When a singleton is announced on a new channel, the previous instance is retired, and its slot is reclaimed once its last user lets go. This is the same ruleafk_compact_slot()already applies on the compact path. Firmware that closes the old channel first is unaffected, and nothing depends on the SoC, board or firmware version.Tested:
5938e9e5e9b6pass (kernel code identical to the tested327fbdaf; later commits only update host-test models). Kernel: signed m2combo19 source (main 02c235a + drm/apple: stop an external firmware-27 pipe on DPMS off #3157) plus this commit, fleet default options. One boot ran 18 DPMS-off batches (6 with an RTC s2idle while off), 6 forced off/detect and 3 RTC wakes. Both monitor audio routes kept jack, ELD and sink at all 8 checkpoints. 46 audio-service announcements, where 8 was the ceiling before, with 0 "no reusable service slots".run-host-tests.py --only apple-dcp,--only dcp(65/65) and--only afkv2pass. checkpatch clean.Risk: two-way door. Affects the classic AV endpoint's video and audio services on every Mac that uses it (M1/M2 generation DCPs on 12.3/13.5 and 27.2 firmware). The firmware already treats these services as one live instance per endpoint. Compact-path and other services are unchanged.
Not yet: a row on a 13.5-firmware Mac with an external display (J413/M1 Pro with a monitor attached), where the old channel is expected to close first and the change should be a no-op.
Details
Evidence on the J473 before the fix (signed m2combo19, longer boot): the USB-C DCP saw 8
DCPAVSimpleVideoInterfaceand 8DCPAVAudioInterfaceannouncements with 0 teardowns and 0 command timeouts, then "no reusable service slots" on the next attach. The HDMI DCP behaved the same way.afk_service_reinit()only reclaims a slot that is torn down, not enabled, without users and without pending commands, and the abandoned instances never got torn down.The superseded instance is only retired, without its teardown callback. The successor's init already takes over the service's state (for audio,
av_audiosrv_init()drops the old instance's owner pin), and calling the video teardown would mark the sink unplugged.Gate for #3157: real external DPMS made this leak hit after about two screen-offs, so that PR merges with or after this one.