Skip to content

drm/apple: iomfb 26.6: answer the display power-down callbacks - #2558

Closed
satchlj wants to merge 2 commits into
mainfrom
drm-apple/v26-power-down-callbacks
Closed

satchlj wants to merge 2 commits into
mainfrom
drm-apple/v26-power-down-callbacks

Conversation

@satchlj

@satchlj satchlj commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

The 26.6 DCP firmware calls back D2, D592, D572 and D209 while it powers the display down. The 26.6 driver handled none of them. When the firmware sent D209, the driver answered -EOPNOTSUPP, which failed the outer call and ended the session ("recovery requires a reboot").

This answers them the way the H17P and M4 drivers already do:

Callback Shape (in/out) Answer
D2 0/0 no-op
D592 swap_complete_intent_gated 20/0 no-op
D572 powerUpDART 4/4 success (0). Nothing is powered: as in the M4 driver, the answer is success without touching a DART.
D209 get_calendar_time_ms 0/8 wall-clock time in ms

During its own panel-off on J613, macOS sent all four callbacks and replied in the same way: no output for D2 and D592, 0 for D572, and the time in ms for D209. They were observed on the DCP's mailbox and RPC memory with Aura's packet capture (aurora-silicon/aura#390).

What was tested. On J613 (M3 Air, 26.6 DCP firmware), in the J613 deep-sleep trial kernels. They carry this commit plus out-of-tree trial calls that make the firmware power the display down; those calls are not in this PR.

  • Before, on n32 (f44bf7af + 37, without this commit): a call that makes the firmware power the display down failed with -95 on an unhandled D209 (J613 unhandled kernel callback 0x44323039 0/8).
  • After, on n33 (f44bf7af + 39): the call completes. The firmware logs its full power-down (power on -> off, power_down_M3: disabling M3, link shutdown, display HPD removed, set_device_enabled_gated: ... requested state: 0), and the calls after it succeed. Five runs on that build.
  • Since then: the same commit, unchanged, is in the trial kernels n34 (5ff7084f + 40), n35 and n36 (391fac63 + 41 and + 43). Each of their runs logged the calls completing and no unhandled callback. Every run is n=1.

This branch is that commit rebased onto acfcd08b, unchanged (range-diff =). It has not been booted at this exact head.

Untested:

  • Which of D2, D592 and D572 the firmware actually sent under Linux. They are not logged, and only D209 is known to fire, from n32's error. Their answers come from the H17P/M4 drivers and macOS's replies, not from a Linux run that exercised them.
  • Any 26.6 machine other than J613.
  • The display path in a normal boot (DPMS off and on, modesets). The trial only reaches these callbacks through its sleep calls.

@satchlj
satchlj force-pushed the drm-apple/v26-power-down-callbacks branch 3 times, most recently from dd86886 to 422359b Compare November 20, 2026 15:42
@satchlj
satchlj force-pushed the drm-apple/v26-power-down-callbacks branch from 422359b to 6ba1daf Compare November 20, 2026 16:29
satchlj added a commit that referenced this pull request Nov 20, 2026
Before the cold stop for a system sleep (switches, off by
default), send the 26.6 firmware the calls macOS sends it before a sleep,
observed on its mailbox and RPC memory (Aura capture run 68), then ask
RTKit for AP and IOP idle on the 26.6 session's RTKit:

- appledrm.v26_sleep_calls=1: the sleep-entry group, A478, A476(1),
  A473 (16 bytes), A115, A500 (0, 1); =2: the panel-off group first,
  A414, A478 x2, A476, A478, A412, A473 zeroed, A500 (0, 0). Every reply
  is compared with macOS's; a mismatch is -EPROTO.
- appledrm.v26_sleep_rtkit_idle: the RTKit idle before the cold stop, on
  dcp->v26's RTKit where the 26.6 path keeps it.

Without the calls the idle is never acknowledged (-62); with either
group it is (status 0x30002e). Needs the power-down callbacks (#2558).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor

The four handlers are shape-checked and match what the M4 dispatcher answers (dcp-m4-callback.h:155-173), and the before/after on n32/n33 shows D209 was the call that failed.

One note on D572: the comment says it is answered as the H17P driver does, but H17P (iomfb_h17p.c:332-341) and v27 (iomfb_v27.c:374-380) also pass the on/off argument to dcp_s2r_dart_power(), which the S2R path waits on (dcp.c:8303-8311). Here the argument is dropped. That is fine while the 26.6 path never powers the display down outside a cold-stopped sleep, but either forwarding it the same way or saying in the comment that 26.6 ignores it would keep a later 26.6 S2R path from timing out on a D572 that did arrive.

Assisted-by: LLM (Claude:Opus 5.5)

@satchlj

satchlj commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Codex GPT-6.2 Sol on @satchlj's behalf.

The 26.6 D572 handler now passes its little-endian on/off word to dcp_s2r_dart_power(), matching H17P and v27. It still replies with success, including when the retained session has no bound DCP. drivers/gpu/drm/apple/iomfb_v26_6.o compiled for ARM64. This revision is compile-tested only and untested on hardware.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of e9ece5b: Blockers: 1.

Earlier point:

  • D572 dropping the on/off argument: resolved. drivers/gpu/drm/apple/iomfb_v26_6.c:565-570 now passes the little-endian word to dcp_s2r_dart_power() as iomfb_h17p.c:338 and iomfb_v27.c:380 do. The v26->dcp test and use are safe: the callback runs with v26->lock held (iomfb_v26_6.c:502) and unbind clears the pointer under the same lock (iomfb_v26_6.c:1219-1221). On 26.6 the call is a no-op today, since s2r_active is never set for this firmware, so it changes nothing at runtime.
  1. Commit 6ba1daf ("drm/apple: iomfb 26.6: answer the display power-down callbacks") has no Signed-off-by and ends with a Co-Authored-By: Claude Opus 5.5 trailer. It needs the author's Signed-off-by and that trailer dropped (or fold e9ece5b into it with one sign-off). The agent credit goes in the PR body's Assisted-by: line, which is already there.

HW row: J613 (26.6 DCP firmware) booted at e9ece5b itself: display up, a DPMS off/on cycle and one modeset with no unhandled-callback line; plus 0 AVC, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

satchlj added a commit that referenced this pull request Nov 21, 2026
Before the cold stop for a system sleep (switches, off by
default), send the 26.6 firmware the calls macOS sends it before a sleep,
observed on its mailbox and RPC memory (Aura capture run 68), then ask
RTKit for AP and IOP idle on the 26.6 session's RTKit:

- appledrm.v26_sleep_calls=1: the sleep-entry group, A478, A476(1),
  A473 (16 bytes), A115, A500 (0, 1); =2: the panel-off group first,
  A414, A478 x2, A476, A478, A412, A473 zeroed, A500 (0, 0). Every reply
  is compared with macOS's; a mismatch is -EPROTO.
- appledrm.v26_sleep_rtkit_idle: the RTKit idle before the cold stop, on
  dcp->v26's RTKit where the 26.6 path keeps it.

Without the calls the idle is never acknowledged (-62); with either
group it is (status 0x30002e). Needs the power-down callbacks (#2558).

Signed-off-by: Satya Benson <[email protected]>
The 26.6 firmware calls back D2, D592, D572 and D209 while it powers the
display down (seen during A473 on J613: Linux's sleep-call trial failed
on an unhandled D209 with -EOPNOTSUPP, taking the session down). Answer
them as the H17P and M4 drivers do: D2 and D592
(swap_complete_intent_gated) as no-ops, D572 (powerUpDART) with success,
D209 (get_calendar_time_ms) with the wall-clock time in ms. macOS's
replies during its own panel-off (capture run 68) are the same: no
output, 0, and the time in ms.

Signed-off-by: Satya Benson <[email protected]>
Pass the D572 on/off word to the S2R helper, as H17P and v27 do,
so a waiter can observe the callback. Keep acknowledging the message
when the retained session has no bound DCP.

Signed-off-by: Satya Benson <[email protected]>
@satchlj
satchlj force-pushed the drm-apple/v26-power-down-callbacks branch from e9ece5b to 388dac0 Compare November 21, 2026 20:51
@satchlj

satchlj commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf. Commits rewritten to carry human identity and DCO only (no Co-Authored-By); trees are byte-identical to the previous head e9ece5b (new head 388dac0).

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

Pre-PR checklist review at 388dac0a5fa42a4cbb2c32cba8469e732ccb2fb8 (§1–§6): 0 code/policy/attribution/CI blockers — COMMENT (holding for §5 HW row on live head).

Code & Source Verification

  • drivers/gpu/drm/apple/iomfb_v26_6.c:563-574 handles D(2) (0/0), D(592) (20/0), D(572) (4/4), and D(209) (0/8). Verified all four shapes and reply encodings match drivers/gpu/drm/apple/dcp-m4-callback.h:49,53,55,155-173, iomfb_h17p.c:332-341,703,722,731, and iomfb_v27.c:374-383,676,697,712.
  • Verified locking and lifetime of v26->dcp in the D(572) handler: every caller of dcp_v26_callback (dcp_v26_call via dcp_v26_link_call and dcp_v26_idle via dcp_v26_link_pump) runs with v26->lock held, and iomfb_v26_6_unbind() (iomfb_v26_6.c:1219-1221) clears WRITE_ONCE(v26->dcp, NULL) under the same v26->lock.
  • Verified dcp_s2r_dart_power() (drivers/gpu/drm/apple/dcp.c:8376-8385, declared unconditionally in dcp-internal.h:453): checks READ_ONCE(dcp->s2r_active) first and returns immediately without acquiring v26->lock (a safe no-op on 26.6 today while dcp_s2r_capable() is false, and ready when 26.6 S2R is wired up).
  • Required headers (<linux/ktime.h>, <linux/unaligned.h>, "dcp-internal.h") are already included in iomfb_v26_6.c.

Checklist Summary

  • §1 No model gating: Pass — protocol callback handling applies uniformly to the 26.6 IOMFB path with no board/chip gating added.
  • §2 Production-ready: Pass — default command line, no hacks or sleeps.
  • §3 Safety: Pass.
  • §4 Clean-room & attribution: Pass — both commits (9f04123c, 388dac0a) carry human author/committer and Signed-off-by: Satya Benson <[email protected]> with zero AI trailers; Assisted-by: is in the PR body.
  • §6 Naming: Pass.
  • CI: host-tests SUCCESS on live head 388dac0a.

Missing §5 Evidence (Hold)

  • As noted in the PR body and the follow-up comment on e9ece5bc, the D(572) -> dcp_s2r_dart_power() revision (tree-identical to live head 388dac0a) is compile-tested only and has not been booted on hardware.
  • Please post a §5 HW row on J613 (26.6 DCP firmware) booted at 388dac0a on a normal kernel: display up, DPMS off/on cycle, one modeset with no unhandled-callback errors, plus the regression gate (0 SELinux denials / 0 failed units / 0 new kernel errors).

Non-blocking nits: link_callback() (iomfb_v26_6_link.c:379) already zeroes out before invoking dcp_v26_callback, so memset(out, 0, 4) is harmlessly redundant; the PR body's D572 table description still reflects the pre-388dac0a commit before dcp_s2r_dart_power() forwarding was added.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 388dac0. It has the same tree as e9ece5b (f7ecb693), so this is a trailer-only rewrite. Both commits now carry only the author's Signed-off-by, which closes the attribution point. The code is fine. The only thing left is the J613 boot row already asked for; a row from either SHA counts, since the trees match.

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.

Formal pre-PR re-review (§1–§6) at 388dac0a5fa42a4cbb2c32cba8469e732ccb2fb8: REQUEST_CHANGES (code, locking, attribution, and CI are all clean; holding solely for §5 hardware evidence on live head).

Verified Clean (§1–§4, §6, CI)

  • Code & locking (drivers/gpu/drm/apple/iomfb_v26_6.c:557-579): D(2) (0/0), D(592) (20/0), D(572) (4/4 forwarding get_unaligned_le32(in) to dcp_s2r_dart_power(v26->dcp, ...) with 4-byte zero reply), and D(209) (0/8 returning ktime_get_real_ns() / NSEC_PER_MSEC) match H17P, v27, and M4 callback shapes/semantics. v26->dcp access is protected by v26->lock (held across dcp_v26_callback and iomfb_v26_6_unbind()), and dcp_s2r_dart_power() is a safe no-op while s2r_active is false on 26.6. Not superseded on live integration/aurora (70a00e583b03).
  • §4 Attribution: Both commits (9f04123c0390, 388dac0a5fa4) carry human author/committer and Signed-off-by: Satya Benson <[email protected]> only (zero AI commit trailers); Assisted-by: is in the PR body.
  • CI: Live Host tests is green on 388dac0a5fa4.

Remaining Blocker

  1. §5 (Missing hardware & regression row on live head 388dac0a5fa4): The D(572) → dcp_s2r_dart_power() revision (e9ece5bc / tree-identical live head 388dac0a5fa4) is still compile-tested only, and the earlier n33–n36 runs predated that commit and only ran out-of-tree sleep trials without exercising normal display operation. Please post a J613 (26.6 DCP firmware) boot row at 388dac0a5fa4 on the default command line: display up, DPMS off/on cycle, one modeset with no unhandled-callback errors, and the regression gate (0 SELinux denials / 0 failed units / 0 new kernel errors).

Non-blocking Nit

  • The PR body's D572 table row still describes the pre-388dac0a5fa4 behavior before dcp_s2r_dart_power() forwarding was added.

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (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

@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: FINISH, then merge at 388dac0a5fa4: the code is ready; it needs only a row at this head.

Blockers: none in the code. Missing row: the D572 change that forwards the on/off word to dcp_s2r_dart_power() (e9ece5bc, the same tree as this head) has only been compiled. Needed: one J613 boot at this head on the default command line, with the display up, a DPMS off/on cycle and one modeset, and no unhandled-callback lines. If you can boot it, please post the row; otherwise we'll get it run.

Checked: no Apple material, no gates. The four handlers are shape-checked and answer as the H17P, v27 and M4 drivers do. D209 returns wall-clock ms. v26->dcp is used under v26->lock, and dcp_s2r_dart_power() does nothing while no sleep is active. The n32/n33 before/after shows D209 was the failing call. CI green. This replaces my earlier reviews.

Evidence

Read both commits (drivers/gpu/drm/apple/iomfb_v26_6.c, +18) against dcp-m4-callback.h, iomfb_h17p.c and iomfb_v27.c. Nit: the D572 row in the PR body still describes the reply before the forwarding was added.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 24, 2026 18:57

Superseded by the review at 388dac0

@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 24, 2026
@github-actions

Copy link
Copy Markdown

Merge readiness at 388dac0a: ready to merge

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

Areas: area:display
Merge: gh pr merge 2558 --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.

@satchlj

satchlj commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

Superseded by #3140 (merged in 7c9d9adcda5a), which landed these exact iomfb_v26_6 power-down callbacks in f7f2a1db0494.

@satchlj satchlj closed this Nov 25, 2026
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) 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.

3 participants