Repository navigation
drm/apple: afk: retire a superseded singleton only after its successor is admitted - #3177
Conversation
…r is admitted afk_recv_handle_init() retired the live instance of a singleton service as soon as its replacement was announced, before the replacement had a slot. When no slot was reclaimable (every slot pinned by a user or waiting for a reply) or the replacement failed admission or its OPEN, the replacement was dropped while the previous instance was already disabled and retired. Its owner (the audio service) kept a reference to a service it could no longer use, and no successor's init ran to hand it a new one. Retire the previous instance only once the replacement holds its slot, has been admitted and opened, right before it is published and its init takes over. A rejected replacement now leaves the previous instance usable. Add a host scenario that runs the real announcement path with every other slot pinned: the rejected replacement leaves the previous instance enabled and owned, and an admitted one retires it. Order the KUnit announcement model the same way. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
RyanTheTide
left a comment
There was a problem hiding this comment.
The replacement-admission finding from #3175 is resolved in this host check. With the other service slots pinned, a rejected announcement leaves the current AV service enabled and owned. Once a slot is available, the retry admits its successor and retires the old service.
I ran the service-rebind host test at 63f53f2 with Clang, AddressSanitizer and UndefinedBehaviorSanitizer. It passed. Running the same test with the merged #3175 afk.c failed at the assertion that the original service remains usable. Both native startup checks and all three mutation controls also passed. The J473 hardware check remains pending.
|
63f53f2 J616s (T6040, M4 Pro) PASS: guarded one-shot combined batch (0aa9d658ff34 over main bc9b4c0, 0 merge-tree diffs on 4 changed files, default cmdline, stock Stage 2 1.0.0b17, boot 2546a528-6d7f-434e-b679-90a87d626c2e): 0 failed units, Enforcing, 0 new AVC, 0 GPU faults, 0 new kernel/subsystem errors, eDP connected pre/post, sep+mtp RTKit v12 clean, Borealis VK api.smoke 8/8 pre/post + glsl.loops 624/624, Wi-Fi 3/3 ping pre/post, 2/2 rtc1 s2idle; stock 7.3.0-aurora-fleet89 restored. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 63f53f29d771
Blockers: The change still needs an external-display reconnect with audio on J473 and a reconnect on a second generation using the compact AV or CEC services. The J616s row checks the internal panel and s2idle.
Checked: If the replacement has no reusable slot, fails admission, or fails OPEN, the old service stays usable. The host test covers a rejected replacement and then a successful handover. The retirement loop also serves compact AV and CEC on newer Macs, so the Risk line should include those paths.
|
J473 (M2 Mac mini, T8112, 27.2) at
The success path behaves as before. The failure path is covered by the new host scenario, which fails on main's order. |
|
Thanks. I updated the Risk line to cover the compact AV and CEC singletons on newer Macs. On the J473: the exact-head row above reattached the external AV services 42 times through DPMS on and RTC wake on both monitors, and both kept their audio (jack, ELD and sink at every checkpoint). The firmware re-announces the services on each of those reattaches. That is not a cable replug, though. I've asked for a physical HDMI and USB-C replug with audio. The second-generation reconnect (compact AV/CEC) needs a monitor on a J616s, J713 or J615; none has one attached right now. Both are listed under Not yet, and I'll post the rows here when they're done. |
|
Physical hot-plug row, J473 (M2 mini), exact head 63f53f2 ( Unplugged the HDMI monitor (Acer, HDMI-A-1) for ~10 s and replugged, then the USB-C-to-HDMI monitor (MSI, DP-2) the same way, with a 1 Hz capture of DRM connector state and PipeWire sinks plus the kernel log.
Result: PASS for the J473 reconnect-with-audio item. The second-generation external reconnect row is still to come. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 63f53f29 once Dj's reconnect rows are in (no code blockers)
Blockers: none in the code. The open items are Dj's rows: an external-display reconnect with audio on J473 (Ryan's hot-plug capture is armed for that) and one reconnect on a second generation that uses the compact AV/CEC path. This is a non-author review; GitHub records it as a comment because this account opened the PR.
Checked:
afk_recv_handle_init()now runs the supersede loop only after the successor has a slot, passed admission and is opened. Every rejection path above it is agoto free, so a rejected successor never retires the old instance.old != servicekeeps the new instance out of its own loop.- One trade-off: the successor can no longer reuse the slot of the instance it replaces in the same announcement, so each re-attach holds one extra slot until the old owner lets go. ORACLE's J473 row bounds that in practice: 40 replacements with zero slot exhaustions.
- The KUnit model (
afk_test_announce) and the host selftest now follow the driver's order. The new host case pins every other slot, checks that the rejected replacement leaves the old instance enabled withusers==1, then frees a slot and checks the handover. - No gate, parameter or delay. The loop is shared by classic and compact singleton services, so the Risk line should name compact AV/CEC, as Dj noted.
|
J616s (M4 Pro, T6040, second generation) physical reconnect row at the exact head 63f53f2: guarded one-shot on the default cmdline, saved fleet89 restored afterwards (saved entry fleet89, next empty, Enforcing, 0 failed units, trial kernel removed).
Evidence (lab): traces/display/20261126-3177-second-gen-hotplug/cap-j616s. |
|
63f53f2 J616s (M4 Pro, T6040, no-hands simulated replug + DPMS + seat-user PipeWire) PASS: 3/3 DRM off->detect on card2-DP-3 + 3/3 GNOME Mutter DPMS off/on cleanly re-announced 33/33 compact AV/DP services and restored seat-user PipeWire sink [Built-in Audio HDMI / DisplayPort Output [MPG 325CQRXF] (Stereo)] ([Out] HDMI1) every cycle, muted /dev/zero paplay OK, 0 DCP crashes/slot exhaustion/flip timeouts, Enforcing, 0 failed, 0 AVC, 0 new display/audio kernel errors; fleet89 restored. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: approve at 63f53f29d771.
Blockers: none.
Checked:
afk_recv_handle_init()now runs the supersede loop only after the new instance holds its slot and has passed admission and OPEN, and it skips the new instance itself (old != service). A replacement rejected for a missing slot, failed admission or a failed OPEN takes one of thegoto freepaths before that loop, so the audio owner keeps a live instance.- The successful path keeps its order: retire, then publish, then the successor's init drops the old reference.
- The KUnit model and the new host scenario follow the same order, and the scenario fails on the old order.
- Rows at this head cover both generations: on the J473, the classic path with 18 DPMS-off batches, RTC wakes and a physical replug of both monitors; on the J616s, the compact path with a physical reconnect, 3/3 forced reconnects and DPMS, and the sink back each time with 0 DCP crashes.
One note, not a blocker: an unowned old instance can no longer donate its own slot to its replacement, because it's only retired afterwards. With every slot full, such a replacement is now refused where it used to succeed. The rows saw 42 announcements and 0 slot errors, so this doesn't happen in practice. If it ever shows up as a slot-exhaustion line, that's where to look.
What: Follow-up to #3175, fixing the failure path M2MINI-ORACLE found in its review (#3175 (review)).
afk_recv_handle_init()retired the live singleton as soon as its replacement was announced, before the replacement had a slot. If no slot was reclaimable, or the replacement failed admission or OPEN, the replacement was dropped while the audio owner kept a reference to a disabled, retired service and no successor was ever handed over. Now the previous instance is retired only once the replacement holds its slot and has been admitted and opened, right before it is published and its init takes over. A rejected replacement leaves the previous instance usable. The successful path is unchanged.Tested:
afk_recv_handle_init()with every other slot retired and owing a reply. The replacement is rejected, and the previous instance stays enabled, unretired and owned. Once a slot comes back, the replacement is admitted and only then retires it. The scenario fails on main's order (assertion on the previous instance) and passes with this change.run-host-tests.py --only apple-dcp,--only dcp(65/65) and--only afkv2pass.63f53f29d771pass: exact-head kernel, 18 DPMS-off batches + 3 RTC wakes, both monitor audio routes kept jack/ELD/sink at all 8 checkpoints, 42 announcements, 0 slot errors, 0 timeouts (row comment below).63f53f29d771pass, physical cable replug: Acer (HDMI) then MSI (USB-C/DP) unplugged and replugged with a 1 Hz connector/sink/kernel-log capture (98 samples). Each connector went disconnected then connected and both monitor audio routes were back at the end (drm/apple: afk: retire a superseded singleton only after its successor is admitted #3177 (comment)). The USB-C route's PipeWire label falls back to a generic name, which is also seen on the fleet kernel without this change; that is tracked separately as a userspace late-ELD naming issue.Risk: two-way door. Reaches every singleton service announced through the classic
afk_recv_handle_init()path: the classic AV video/audio services on M1/M2-generation DCPs (J473 27.2, 12.3/13.5 firmware), and the compact-profile AV and CEC singletons that newer Macs (M3/M4/M5 externals on firmware 27) announce through the same path. The previous instance is now retired slightly later, after the replacement's OPEN instead of before slot allocation. During that window both are live, which is the state the firmware itself reports.63f53f29d771pass, physical reconnect: the MSI on USB-C/DP connected, unplugged for about 14 s and replugged; on each plug the AV, audio and DP services were re-announced and the old instance superseded, with 0 DCP crashes and 0 slot-exhaustion lines (drm/apple: afk: retire a superseded singleton only after its successor is admitted #3177 (comment)).63f53f29d771pass, no-hands: 3/3 forced connector off/detect and 3/3 DPMS off/on brought video back and the monitor audio output 'MPG 325CQRXF' back each time, 33/33 compact service replacements, a silent stream played, 0 DCP crashes, timeouts or slot exhaustion (drm/apple: afk: retire a superseded singleton only after its successor is admitted #3177 (comment)).Not yet: nothing for this change; both generations and both reconnect kinds are covered above.