Skip to content

soc: apple: rtkit: let ordinary firmware traffic through the committed v27 display stop - #2913

Merged
DjDeveloperr merged 4 commits into
mainfrom
soc-apple/rtkit-v27-committed-stop
Nov 26, 2026
Merged

DjDeveloperr merged 4 commits into
mainfrom
soc-apple/rtkit-v27-committed-stop

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On firmware-27 machines, the late display stop at sleep entry checks each display co-processor once before the sleep is committed and again right before its stop, after the commit, where any failure ends in a panic. Two of those steps treated ordinary firmware traffic as a failure:

  • apple_rtkit_v27_check() consumed any pending mailbox message and returned -EAGAIN, also after the commit, although the stop that follows reads the mailbox itself.
  • apple_rtkit_v27_idle_atomic() returned -EPROTO for any message that was not one of the three power-state answers or an owed OSLOG counter (for example a syslog line).

So a log line arriving in that window turned a normal sleep into a panic.

Change

  • The check op learns whether the sleep is committed. Before the commit, a pending message still refuses the sleep and is kept for the disarm, as today. After it, the check leaves the message for the stop.
  • The atomic idle acknowledges SYSLOG and IOREPORT notifications through the bounded echo path and retains other system messages for replay. Application messages, unexpected management replies, crash logs, FIFO exhaustion and timeout stop the sequence.
  • The panic for a co-processor that really does not stop is unchanged: it still runs with its DARTs unstopped, and the DART stop requires the initiator to be stopped first.

Testing

  • The arm64 RTKit object compiled. The fake-mailbox suite passed at 1b68ad86, including notification echo, FIFO order and application endpoint refusal. Both existing negative controls failed at their intended assertions.
  • Built into a fleet-based test kernel together with the drm/apple IOMFB series, which ran display rows on an M2, a MacBook Neo, an M3 Air and a t6041 MacBook Pro on the default command line, including 8/8 short s2idle cycles with no new errors. None of those machines takes this sleep path, so this only shows the change does not disturb them.

Still to run

  • A sleep-entry row on a firmware-27 machine with this sleep path (T6050); we have none in our lab. Requesting a row from someone who has one.

…d v27 display stop

The firmware-27 late display stop checks each display coprocessor once
before the sleep's commit and again right before its stop, after the
commit, where any failure ends in panic("Apple committed display stop
failed"). Two steps failed on ordinary firmware traffic:

- apple_rtkit_v27_check() consumed any pending mailbox message into the
  scope FIFO and returned -EAGAIN, also when called after the commit.
  The stop that follows reads the mailbox itself.
- apple_rtkit_v27_idle_atomic() returned -EPROTO for any message that
  was neither one of the three power-state answers nor an owed OSLOG
  counter, e.g. a syslog line or an application endpoint's message.

The check op now learns whether the sleep is committed (the sleep core
passes entry_committed). Before the commit a pending message still
refuses the sleep and is kept for the disarm; after it, the check
leaves the message in the mailbox for the stop. The atomic idle keeps
messages from other endpoints in the scope FIFO, which the disarm
already replays after the restart, and goes on waiting for the
power-state answers within the same 100 ms budget. A management
message off the handshake, a crashlog message, a full FIFO and the
timeout still fail the stop, as before.

The panic itself stays: a coprocessor that did not stop still runs
with its DARTs unstopped, and the DART stop requires the initiator to
be stopped first.

tools/asahi/rtkit-v27-late-tests.py compiles both functions from the
source against a fake mailbox and firmware; its --consume-committed
and --fail-foreign mutations restore the old behaviour and fail.

Reported-by: erikwb <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 4b5650c.

Read at 4b5650c. The committed change in apple_rtkit_v27_check() (rtkit-v27-late.inc:116) is fine. After the commit, a pending management or crashlog message is still caught by the stop's own receive, so it fails the stop just as the old -EAGAIN did. Pre-27 firmware is unaffected: both functions are reached only through dcp_v27_late_ops, which only registers when apple_sleep_v27_late() is true. The concern is the new pass-through branch:

  1. rtkit-v27-late.inc:205-212: every endpoint except MGMT and CRASHLOG is now deferred and the wait goes on. That includes application endpoints, notably IOMFB 0x37: dcp_v27_sleep_inventory() doesn't close it ("drains through its serialized queue", dcp-v27-sleep.inc:787-805). A callback or ack arriving there means the firmware is mid-call. Today it fails the stop; with this change it is replayed by the disarm (:39) into dcpep_got_msg() after the processor has been through IDLE, against a shared record from before the sleep. Please limit the pass-through to system endpoints (msg.msg1 < APPLE_RTKIT_APP_ENDPOINT_START, excluding MGMT/CRASHLOG) and keep -EPROTO for application endpoints. That is the narrowest form, and it still covers the syslog case in the description.
  2. Syslog lines are acknowledged by echo (rtkit.c:1329). Deferring one also defers its ack until after the wake. If the firmware holds the power-state answer until that ack, the stop still times out and panics, so the motivating case may not be fixed. Owed OSLOG is echoed inside the loop (:196); please either echo syslog the same way (and skip the echo on replay) or show on T6050 that the firmware answers IDLE with a syslog ack outstanding.
  3. Replay order: the disarm turns receive back on (:32) before it replays the deferred FIFO (:39). Please confirm the hold keeps new messages from the woken firmware from being dispatched ahead of the deferred ones; more messages can now wait in the FIFO.
  4. Rows: none of J616s, J713, J615, M1 Pro, M2 or Neo takes this path (it only exists in the T6050 sleep profile), so the posted rows only show that nothing else is disturbed. Owed: a T6050 (J714s/J716c) row at this head with s2idle x2, internal + external display attached, and a syslog line in the stop window (e.g. an external release just before entry), plus the host test with a 0x37 message in the window.

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

Formal §1–§6 pre-PR checklist review at 4b5650c9f5115afcd748f12a419c560823747d97.

Checklist Summary

  • §1 No model gating: Pass (reaches only existing dcp_v27_late_ops path gated by apple_sleep_v27_late()).
  • §2 Production-ready, no hacks: Needs change — see blockers 1–2 below. (apple_rtkit_v27_check(s, committed) itself is sound, and disarm replay ordering is protected because apple_mbox_hold_rx() keeps the mailbox RX IRQ disabled until apple_mbox_release_rx() runs after the kfifo_get replay loop.)
  • §3 Safety: Needs change — see blocker 1 below (deferring application endpoints weakens fail-closed stop safety).
  • §4 Clean-room & attribution: Pass (commit carries human author/committer, Reported-by:, and Signed-off-by: Ryan Murray <[email protected]> only, zero AI trailers in commit; PR body disclosure present).
  • §5 Evidence: Owed — see blocker 3 below.
  • §6 Naming: Pass (registers new host test in existing tools/asahi/run-host-tests.py harness).

Blockers

  1. Overbroad endpoint pass-through (drivers/soc/apple/rtkit-v27-late.inc:199-212): The else branch defers every endpoint except APPLE_RTKIT_EP_MGMT and APPLE_RTKIT_EP_CRASHLOG, including application endpoints (msg.msg1 >= APPLE_RTKIT_APP_ENDPOINT_START). Notably, dcp_v27_sleep_inventory() leaves IOMFB (0x37) open and relies on it being quiesced; an application-endpoint message arriving during apple_rtkit_v27_idle_atomic() means firmware is mid-call, and replaying it via apple_rtkit_rx_dispatch() in apple_rtkit_v27_disarm() after IDLE/restart replays pre-sleep RPC state into a restarted coprocessor. Restrict the deferred pass-through strictly to non-MGMT/non-CRASHLOG system endpoints (msg.msg1 < APPLE_RTKIT_APP_ENDPOINT_START), keep -EPROTO for application endpoints (>= APPLE_RTKIT_APP_ENDPOINT_START), and update tools/asahi/rtkit-v27-late-tests.py:311 to verify 0x37 fails closed with -EPROTO.
  2. Syslog echo/ack deferral deadlock risk (drivers/soc/apple/rtkit.c:1270-1330, rtkit-v27-late.inc:205-212): apple_rtkit_syslog_rx_log() acknowledges syslog lines by echoing them back to firmware (apple_rtkit_send_message(rtk, APPLE_RTKIT_EP_SYSLOG, msg, ...)), and rtkit.c notes that records must be acknowledged for the coprocessor to make progress. Unlike owed OSLOG (echoed inline at line 196), a deferred SYSLOG_LOG message is not echoed until disarm after wake. If T6050 firmware blocks completing the IDLE handshake while a syslog ack is outstanding, the 100 ms idle loop still hits -ETIMEDOUT and panics. Either echo APPLE_RTKIT_SYSLOG_LOG inline (avoiding double-echo on disarm replay) or prove on T6050 hardware that firmware completes IDLE with an unacked syslog line pending.
  3. §5 T6050 hardware evidence owed: None of the tested machines (M2, Neo, M3 Air, t6041) execute apple_sleep_v27_late() / apple_rtkit_v27_*. Owed: a T6050 (J714s/J716c) hardware row at the updated head exercising s2idle/sleep cycles with internal + external display and a syslog line in the stop window, plus regression check (0 SELinux denials, 0 failed units, 0 new kernel errors).

Assisted-by: LLM (Gemini 4 Neon)

…ay stop

Acknowledge SYSLOG and IOREPORT notifications in the atomic idle loop using the existing bounded echo path. An acknowledged record can be recycled, so leave it out of the deferred FIFO. Preserve the stop refusal for application traffic and replay only other system messages after a successful stop.

Signed-off-by: Ryan Murray <[email protected]>

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

Formal §1–§6 pre-PR checklist re-review at 1b68ad86e50a6bc9f3009b426db00f103e249383.

Verdict: REQUEST_CHANGES (0 code/CI blockers remaining; blocked solely on owed §5 T6050 hardware evidence on this non-draft PR).

Prior Finding Verification (1b68ad86e50a)

  1. Overbroad endpoint pass-through (drivers/soc/apple/rtkit-v27-late.inc:196-202) — FIXED:
    • apple_rtkit_v27_idle_atomic() now fails closed with -EPROTO and poisons the scope for msg.msg1 >= APPLE_RTKIT_APP_ENDPOINT_START alongside unexpected EP_MGMT and EP_CRASHLOG. Live IOMFB (0x37) / application RPC traffic can no longer slip through or replay pre-sleep state on disarm.
    • tools/asahi/rtkit-v27-late-tests.py now verifies APPLE_RTKIT_APP_ENDPOINT_START returns -EPROTO with sc.failed && !sc.stopped && rk.strict_idle_poisoned.
  2. Syslog echo/ack deferral deadlock risk (drivers/soc/apple/rtkit-v27-late.inc:203-207, rtkit.c:1610-1620) — FIXED:
    • apple_rtkit_notification_msg() (EP_SYSLOG/SYSLOG_LOG and EP_IOREPORT/UNKNOWN1/UNKNOWN2) is now acknowledged inline via the existing bounded echo_pending path alongside owed OSLOG, and omitted from s->deferred so disarm neither double-echoes nor reads recycled ring entries.
    • apple_rtkit_v27_idle_atomic() requires !echo_pending before returning 0, ensuring the ack is transmitted before completion.
    • Disarm replay order remains safe (apple_mbox_hold_rx() holds the RX IRQ disabled until apple_mbox_release_rx() runs after the kfifo_get replay loop).
  3. CI at 1b68ad86e50a — ALL GREEN (7/7):
    • host-tests, source, rust-build, kunit, DWC3/ATC builtin-no-atc, DWC3/ATC modular-no-atc, DWC3/ATC builtin-modular-atc all COMPLETED / SUCCESS.

Remaining Blocker (§5 Evidence)

  • §5 T6050 hardware proof still owed (also acknowledged under ## Still to run):
    • None of the 4 lab machines (M2, Neo, M3 Air, t6041) execute apple_sleep_v27_late() / apple_rtkit_v27_*.
    • Owed before approval / MERGETRAIN-LINUX4: a T6050 (J714s/J716c) hardware sleep-entry row at this head exercising s2idle cycles with internal + external display and a syslog line in the committed stop window, plus regression check (0 SELinux denials, 0 failed units, 0 new kernel errors).

Checklist Summary

  • §1 No model gating: Pass.
  • §2 Production-ready / §3 Safety: Pass (all prior code/safety blockers resolved).
  • §4 Clean-room & attribution: Pass (both commits carry human author/committer Ryan Murray <[email protected]> and human Signed-off-by: only, zero AI trailers in commits; PR body includes Assisted-by: disclosure).
  • §5 Evidence: Blocked on owed T6050 hardware row (not ready for MERGETRAIN-LINUX4 until satisfied or converted to draft).
  • §6 Naming: Pass.

Non-blocking Note

  • tools/asahi/rtkit-v27-late-tests.py verifies inline echo for SYSLOG_LOG and deferred FIFO ordering for non-notification SYSLOG/IOREPORT messages; adding an inline echo test case for IOREPORT (UNKNOWN1/UNKNOWN2) and having --fail-foreign also mutate the notification echo branch would make the negative control even tighter.

Assisted-by: LLM (Gemini 4 Neon)

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-hw-row No hardware row at the PR head (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 48b6d70d: ready to merge

Check Detail
CI at head ok 26 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok comment at 48b6d70d
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:display, area:gpu, area:platform
Merge: gh pr merge 2913 --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 the merge-conflict Conflicts with the base branch (bot) label Nov 25, 2026
Keep the main branch's secure-port idle callback and pass the commit
state through the DCP late-check callback to RTKit.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide requested a review from a team as a code owner November 25, 2026 02:11
@RyanTheTide
RyanTheTide requested a review from Acelogic November 25, 2026 02:11
@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label Nov 25, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Forwarded to current main without rewriting the branch. The new head is 6c9bb91. The only conflict was the DCP late-check declaration. The forward preserves main's secure-port idle callback and the PR's committed-state check. All six PR files retain the same added and removed lines.

The existing RTKit host fixture passed, the DCP layout suite passed 5/5, and the three affected objects compiled with W=1 on ARM64 with 16 KiB pages and Rust disabled. Hosted checks and the exact T6050 short-sleep display row are pending. Please re-review the forward and record the result at this head.

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Nov 25, 2026
Bring in the G16-disabled build fix for the SEP KUnit configuration.
Keep the existing RTKit change and add its test to the current host
test registry.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide requested review from a team as code owners November 25, 2026 20:52
@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 25, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Forwarded this branch to current main at 48b6d70dde9e. This includes the G16-disabled build fix from #3111. The five RTKit source and dedicated test files are unchanged, and the current host registry retains every existing entry plus the RTKit suite. The ordinary host test passed with Clang on that exact tree.

The new SEP KUnit run and the T6050 default-command-line display/suspend row remain open.

Copy link
Copy Markdown
Contributor

PASS on a 14-inch MacBook Pro (J714s, M5 Pro/T6050, G17S B1), kernel 7.3.0-m5-rows-prs, at 48b6d70dde9ea6f5e24eba730b089d4f7a811c4b.

Candidate 053c0549b09b7a48582d5dfbfeb1ddbb25af442d merged these unchanged heads onto main 15695c3ba53291e78bf62140598dbdffc7fb2b72 plus Clang fix 0050f580cc54892302f38e458e609d1b793010e0, which has since merged. The baseline was that same main plus the fix (f2b85419afafcfd6e6bc5ceeaa79e9ee557563a4).

The merged heads were #2906 f3ad1a8f362c, #3123 822a1dd7369c, #3116 064c3c65cd3e, #2949 0a4f6d6576a3, #2913 48b6d70dde9e, #2218 b3e6c51a4b5f and #2007 4738426f6c24.

All 3 displays, including the internal panel, were active before a 30.7 s deep sleep. The log recorded PM: suspend entry (deep), the PMU RTC wake, and five firmware-v27 V27 wake: DCP stopped and restarted records, including the internal DCP. The four external display processors also logged stopped and restarted between the wake's stages: 0. The system returned on the same boot with all 3 display modes restored.

The sleep check used deep mem. The baseline s2idle attempt stayed unreachable.

The command line matched the default. SELinux was disabled. tailscaled.service was the one failed unit on both boots and on the default. Each boot had 6 error-priority lines, all the known DCP clock-index message. After one deep cycle, there were 83 warning/error-priority lines on the baseline and 79 on the candidate, with zero added lines and zero kernel WARNING: reports. The known DCP clock-index message occurred 10 times on each arm through the wake.

@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 48b6d70dde9e

Blockers: none. Both earlier points are fixed. Application endpoints now fail closed with -EPROTO during the late idle, and syslog and ioreport notifications are acknowledged inline instead of deferred. The two later commits only merge main; the PR's own diff is unchanged.

Checked: this path runs only in the v27 late sleep (apple_sleep_v27_late()), which only the T6050 takes. The J714s row at this head passes a firmware-27 sleep with the display active and the committed stop exercised. CI is green, and rtkit-v27-late-tests.py covers the endpoint and acknowledgement cases.

@DjDeveloperr
DjDeveloperr dismissed stale reviews from themself November 26, 2026 05:31

Superseded by the review at 48b6d70

@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 26, 2026
@DjDeveloperr
DjDeveloperr merged commit 52eb351 into main Nov 26, 2026
29 of 30 checks passed
@RyanTheTide
RyanTheTide deleted the soc-apple/rtkit-v27-committed-stop 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) area:platform Area from CODEOWNERS (bot) needs-template PR body lacks Tested or 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