Skip to content

drm/apple: stop the M4 MacBook Air's internal DCP firmware on macOS 27.2 (DPMS off, deep sleep) - #2660

Closed
RyanTheTide wants to merge 7 commits into
j713-disp2/dcp272-internalfrom
j713-s2r/dcp-s2r
Closed

RyanTheTide wants to merge 7 commits into
j713-disp2/dcp272-internalfrom
j713-s2r/dcp-s2r

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On macOS 27.2 the M4 MacBook Air's (J713) internal DCP runs the firmware-27 backend (#2590), but nothing stops its firmware on T8132. A deep sleep finds the display coprocessor still running and is refused, and DPMS off only turns the backlight down.

Change

  • drm/apple: the T8132 internal DCP on 27.2 gets the hw.s2r stop the T8142 already runs on 27.2: set_power_state(0), D572, the AP link release (A550 in the 27.2 table), RTKit idle, the CPU stop, then the DART streams. It is on by default, with no module parameter.
  • Its power words come from the device tree, not a per-SoC table. A hw.s2r DCP with no layout in its hw data uses:
    • DISP_CPU, DISP_FE and DISP_SYS from its power-domains chain;
    • DISP_CPU's apple,retention-workaround, writing only the masked bits (the off value at power-off, the value read at probe at power-on);
    • pmc-dcp where the display-power node has it;
    • the DART streams its DARTs have enabled before the first stop.
      Without those properties the firmware keeps running, as before. T8140 and T8142 keep their tables.
  • iommu: apple-dart: apple_dart_enabled_streams(), for the streams above.
  • drm/apple: the lit-panel system-sleep stop no longer checks for the J813. hw.s2r already decides it, since a derived layout only survives probe when opted in (the same hunk as soc: apple: sleep, mfd: macsmc, drm/apple: Select the T8142 sleep paths by hardware, not J813 #2384).
  • dt-bindings: apple,t8132-display-power (T8140's layout).
  • J713 DT: the display-power node, apple,display-power on the DCP, and the DCP DART's clock-protection slice (ADT dart-dcp index 42) as its gapf word. The stop releases it after the DART's power-down flush, so that DISP_CPU's power state can be written.

Stacked on #2590.

Testing

Notes

  • J715 (M4 Air 15") gets none of the new nodes. Its DCP keeps running into a sleep, which is fail-safe, until it has a row; then the nodes move to the shared t8132-j713-j715.dtsi.
  • 48789bf (review): a DCP with a piodma node whose DART is missing or reads no streams now refuses the DT layout (-ENODEV / -ENODATA) instead of restoring 0 streams at power-on. The DISP_CPU/FE/SYS offsets can't underflow the "ps" size check and must be word aligned.
  • 634fbb2 (review): the DT layout reads its DART streams at probe and refuses on 0; apple_dart_enabled_streams() reads every enable word; the comments no longer describe the stop as behind appledrm.s2r_untested.

Still to run

  • Lid wake (needs hands on the lid), and a sleep-power number on battery.
  • Neo (T8140) DPMS smoke for the shared retention-write path. The review fix only touches the DT-layout path, which T8140's static table doesn't use.
Where the words come from, and runtime reads
  • DISP_SYS / DISP_FE: ADT pmgr devices psreg 2, idx 8 / 9 (ps-regs[2] = 0x200), so 0x240 / 0x248. DISP_CPU: psreg 10, idx 0 (0x10000). These are the words t8132_sleep_soc.ps.disp[0] lowers at every deep sleep.
  • Retention: ps_disp_cpu's apple,retention-workaround (pmgr 0x2504c / 0x25070) = pwrgate 0x104c / 0x1070, the pair t8132_sleep_soc.pwrgate_disp[0] writes. They read 0 / 1 while running.
  • Clock protection: slice 42 (dart-dcp) reads 0x12 (protect bit 4 set) at runtime; slice 8 (dart-disp0) reads 0x02.
  • Streams: dart-dcp SID 23 (+ vm-base-24), dart-disp0 SIDs 0 and 16. They are probed from the DARTs, not listed.
  • 27.2 calls used: A464, A539, A537, A462, A534, and A550 for unnamed_500. All are in dcp_methods_27_2.
  • Hardware rows and logs: lab store traces/power/20261121-j713-s2r/ (rowB-s2r1, rowC-s2r4); review-fix A/B: traces/display/20261122-j713-2660fix/.

Assisted-by: LLM (Claude:Opus 5.5)

A DCP whose device tree names its display power words but not its
DART streams stops the streams its DARTs have enabled before its first
power-down and enables them again at power-up. Let it read them: the
first 32 streams of a T8110 DART, read while its domain is up.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…ry hw.s2r SoC

The system-sleep stop ran with an active panel only where the power
words are measured, or on the J813, so another SoC's internal DCP stayed
running into a deep sleep unless DPMS had turned its panel off first,
and the sleep was refused. A derived layout only survives probe with
appledrm.s2r_untested set, which already decides it: drop the board
check.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
… power words from the device tree

The M4 MacBook Air's internal DCP runs the firmware-27 backend on macOS
27.2 but has no firmware stop, so a deep sleep is refused with the
processor still running, and DPMS off only darkens the backlight.

Give it the hw.s2r stop the T8142 runs on 27.2: set_power_state(0),
D572, the AP link's release (A550 in the 27.2 table), RTKit idle and the
CPU stop, then the DCP DART's streams. It has no secure mailbox.

Its power words are not a per-SoC table: a hw.s2r DCP without a layout
in its hw data takes them from its device tree, the ones its deep sleep
lowers. DISP_CPU is the first state of its power-domains, DISP_FE that
state's parent and DISP_SYS theirs; the retention words are DISP_CPU's
apple,retention-workaround, of which only the masked bits are written,
the off value at power-off and the value read at probe at power-on;
pmc-dcp counts it where the display-power node has that word; and the
DART streams are the ones its DARTs have enabled before the first stop.
Without those properties the firmware keeps running, as before.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The T8132's words are T8140's: pmc-dcp, the power manager's power
states and its power gate block.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Name the power manager blocks the internal DCP's firmware-27 stop
writes, the ones the deep sleep lowers (pmc-dcp, the power states and
the power gate block), and the DCP DART's clock-protection slice (42 in
the ADT's dart-dcp) as its gapf word: the stop clears it after the
DART's power-down flush so that DISP_CPU's power state can be written.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Looks good; approve once the regression row below is in.

What I checked at the head. dcp_s2r_layout_from_dt() (drivers/gpu/drm/apple/dcp.c:309-383) takes DISP_CPU/FE/SYS from the power-domains chain and requires them to sit in the pmgr block that "ps" starts. It bounds-checks every offset and refuses a retention entry whose off value has bits outside its mask. It puts all node references on every path. dcp_s2r_check_dt() turns hw.s2r off when the DT words are absent, so a tree without them keeps today's behaviour. The at <= gate_res.start test at :357 looks like an off-by-one, but it is needed: ret_ff == 0 means "no retention words" in dcp_s2r_domains_off()/_on(). The T8132 v27 hw data is not s2r_untested, so the stop runs on the default command line. Dropping the J813 check in dcp_platform_suspend() only widens it for SoCs that are still behind appledrm.s2r_untested. Commits have a human Signed-off-by and no agent trailers.

  1. Four comments still describe the stop as behind appledrm.s2r_untested or J813-only, which this series makes untrue for the T8132 DT layout:
    • arch/arm64/boot/dts/apple/t8132-j713.dts:197 says "(appledrm.s2r_untested)".
    • drivers/gpu/drm/apple/dcp.c:7411-7413 says "A SoC with derived power words is offered the stop only when asked for". A DT-derived layout is offered it by default.
    • dcp.c:296-297 still says the untested path stops the firmware for "J813 system sleep".
    • The d81cf76 commit message says "A derived layout only survives probe with appledrm.s2r_untested set", which is not true for the layout that dcp_s2r_layout_from_dt() builds.
      Please update all four to match the code.
  2. drivers/iommu/apple-dart.c:7768-7776: apple_dart_enabled_streams() reads only the first enable word, so any stream 32 or above that the DART has enabled is silently left out of the stop and the restart. J713's SIDs (23, 0, 16) are fine. Since the function is meant for any T8110 display DART, either dev_warn once when dart->num_streams > 32 and a later enable word is non-zero, or read all the words.

HW row: J713, 27.2 stub, default command line, this series on its own (without #2691/#2692): DPMS off/on x10 plus 10 RTC-wake deep sleeps with the panel lit. Pass: suspend_stats fail 0, eDP back after each wake, 0 DART faults, 0 AVC, 0 failed units, 0 new kernel errors. Then the lid-wake row from "Still to run".

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

No blockers. The two points from the last review are still open at 2218023. First, the comments at t8132-j713.dts:197 and dcp.c:297, :582 and :7412-7413, and the d81cf76 commit message, still describe the stop as behind appledrm.s2r_untested or J813-only, but for the DT-derived T8132 layout it runs by default. Second, apple_dart_enabled_streams() (apple-dart.c:7768-7774) reads only the first enable word, so streams at 32 or above are silently dropped. Please read every word up to num_streams, or warn and refuse. Also, dcp_s2r_find_darts() (dcp.c:8428) uses dcp_streams == 0 as its "not read yet" flag. A first read of 0 would make dcp_dpms_power_on(), the prewarm work and dark_finish read the DCP DART while DISP_CPU is still lowered, and the restart would enable no streams. A separate flag, plus refusing the DT layout when the DCP DART reads 0, closes that. The new gapf reg on dcp_dart (0x38079cb80) is the same word as its apple,clock-protection = <&ps_prot 42> slice (0x100 + 0x40*42). Deriving the GAPF word from that slice would avoid describing it twice. J715 gets none of the new nodes, so its DCP still keeps running into a sleep. Please say so in the description or move the nodes to the shared dtsi once it has a row. The regression row asked for last time is still missing: J713 on the 27.2 stub, stock command line, this series alone without #2691/#2692, DPMS off/on x10 and 10 lit-panel RTC-wake deep sleeps at this head. The current DPMS row is 3/3, and every deep-sleep row stacks #2691/#2692. Lid wake, and a Neo DPMS smoke for the shared layout/retention path, would complete it.

… probe, and only all of them

Review points on the device-tree power layout:

- Its DART streams were read at the first stop, with dcp_streams == 0
  standing for "not read yet". A first read of 0 would have had later
  stops and power-ons read the DART again, maybe with DISP_CPU still
  lowered, and the restart would enable no streams. Now the streams are
  read once at probe, with the firmware running. A DCP DART that reads
  none refuses the layout, and the firmware keeps running as with no
  power words.
- apple_dart_enabled_streams() read only the first enable word. If a
  stream above 31 is enabled, the 32-bit mask can't describe the DART,
  so it now reads every word up to num_streams, warns once, and reports
  0 in that case.
- Comments still described the stop as behind appledrm.s2r_untested or
  J813-only. The device tree's words stop the firmware by default; only
  a SoC whose static words are merely derived (T8142) needs the
  parameter. The same holds for the layout added in "drm/apple: dcp:
  stop a DCP for a deep sleep with its panel lit on every hw.s2r SoC",
  whose message says otherwise.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Both open points are addressed at 634fbb2, one commit on top with no force push.

  1. Comments: t8132-j713.dts, the stop overview in dcp.c, the s2r_untested parameter description and the probe gate now say what the code does. Power words from the device tree stop the firmware by default; only a SoC whose static words are merely derived (T8142) needs appledrm.s2r_untested. d81cf76's message can't change without a force push, so the new commit's message corrects it.
  2. Streams: apple_dart_enabled_streams() reads every enable word up to num_streams. If any stream above 31 is enabled, it warns once and returns 0, because the 32-bit mask can't describe that DART. A DT layout now reads its DART streams once, at probe, while the handed-over firmware runs; the reads at the first stop are gone, and with them dcp_streams == 0 standing for "not read". A DCP DART that reads 0 refuses the layout (no display power layout (-61)), and the firmware keeps running as with no power words.

The GAPF word appears twice, as you say: dcp_dart's gapf reg (0x38079cb80) and its apple,clock-protection = <&ps_prot 42> slice are the same word. I kept the reg because apple_dart_gapf_* works on an MMIO mapping and the clock-protection property only feeds the j713_display lab path. Deriving the GAPF word from the slice is a DART-side follow-up, which I'd do separately so it doesn't widen this PR.

J715: it gets none of the new nodes, so its DCP keeps running into a sleep (fail-safe). I'll say so in the description; the nodes move to the shared dtsi once the J715 has a row.

The regression row you asked for: J713 on the 27.2 stub, stock cmdline, this series alone at 634fbb2 without #2691/#2692, using production Stage 2 af341272 with this tree's DTB.

Evidence: traces/display/20261122-j713-2660-alone/ (README, summary2.txt).

W=1 is clean for dcp.o, apple-dart.o and t8132-j713.dtb, and checkpatch is clean.

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

Adversarial Pre-PR Checklist Review (head 634fbb2d2029)

Requesting changes for two real code bugs in the DT power/DART layout helpers added by this PR.

Code Blockers

  1. Incomplete fail-closed check in dcp_s2r_layout_streams() (drivers/gpu/drm/apple/dcp.c:404-412):

    • Commit 634fbb2d properly fails closed (return -ENODATA) when dcp_dart returns 0 streams from apple_dart_enabled_streams(), but does not fail closed when the piodma child node is present and its DART (disp_dart) is missing or returns 0:
      piodma = of_get_child_by_name(dcp->dev->of_node, "piodma");
      if (piodma) {
          dart = dcp_s2r_find_dart(piodma);
          of_node_put(piodma);
          if (dart) {
              dcp->s2r_dt_layout.disp_streams = apple_dart_enabled_streams(dart);
              put_device(dart);
          }
      }
    • If disp_dart has any stream >= 32 enabled (causing apple_dart_enabled_streams() to warn and return 0, per its fail-closed contract) or isn't bound, dcp_s2r_layout_streams() silently succeeds with disp_streams = 0. On power-on, dcp_s2r_dart_power() then calls apple_dart_display_streams(dcp->s2r_disp_dart, 0, true, false), writing 0 to DART_T8110_ENABLE_STREAMS and leaving display streams disabled.
    • When piodma exists, require dart != NULL and dcp->s2r_dt_layout.disp_streams != 0, returning -ENODEV / -ENODATA otherwise so the DT layout fails closed cleanly.
  2. Unsigned underflow and missing alignment check in dcp_s2r_layout_from_dt() (drivers/gpu/drm/apple/dcp.c:339-341):

    • off[i] > resource_size(&ps_res) - 4 underflows unsigned resource_size_t if resource_size(&ps_res) < 4, bypassing the upper-bound check, and off[i] % 4 is unchecked (unlike the retention offset check at % 4 at line 349).
    • Guard resource_size(&ps_res) < 4 || off[i] > resource_size(&ps_res) - 4 || off[i] % 4.

Non-Blocking Nit

  • Stale comment at drivers/gpu/drm/apple/dcp.c:307-308: still states "The DART streams are the ones its DARTs have enabled at the first stop, see dcp_s2r_find_darts()", whereas 634fbb2d moved the read to probe (dcp_s2r_layout_streams()).

Other Checklist Notes (§1–§6, CI)

  • §1 / §2 / §3 / §4 / §6: Good design deriving power/retention words and DART streams from DT/hardware rather than per-SoC tables, running on default cmdline, and keeping J715 fail-safe until qualified. All 6 commits carry human identity (Ryan Murray) and Signed-off-by: with no agent trailers; PR body has Assisted-by:.
  • CI / Base / §5: Stacked on unmerged #2590 (j713-disp2/dcp272-internal, which currently has conflicts against its base) with 0 CI checks run on this PR. J713 10/10 DPMS off/on on 634fbb2d alone is clean; remaining §5 rows after fixing the bugs above and running CI are J713 lid wake and a Neo (T8140) DPMS smoke covering the shared dcp_s2r_ret_write() / layout path.

Assisted-by: LLM (Gemini 4 Neon)

…and check power word alignment

A DCP with a piodma child restores the display DART's streams at power-on
from the layout. If that DART is not found, or reads no streams (none
enabled, or streams above 31 that the 32-bit mask cannot describe), the
layout kept disp_streams = 0 and power-on would have enabled none. Refuse
the layout then, like a DCP DART that reads none: the firmware keeps
running.

The DISP_CPU/FE/SYS offsets are checked against the "ps" block without
underflowing on a block shorter than a word, and must be word aligned like
the retention offsets.

The overview comment named the old first-stop stream read; point it at
dcp_s2r_layout_streams().

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Both blockers are fixed in 48789bf: one commit on top of 634fbb2, no force push.

  1. piodma DART: when the DCP has a piodma child, dcp_s2r_layout_streams() now needs that DART to be present (-ENODEV otherwise) and to report nonzero streams (-ENODATA otherwise, which covers the "streams above 31" refusal too). Either case refuses the DT layout, so the firmware keeps running, the same as a DCP DART that reads 0. Power-on can no longer write 0 to the display DART's enable word.
  2. Offsets: the DISP_CPU/FE/SYS check is now resource_size(&ps_res) < 4 || off > resource_size(&ps_res) - 4 || off % 4.
  3. Nit: the overview comment now points at dcp_s2r_layout_streams() (read at probe), not the old first-stop read.

Host: drm/apple dcp.o is clean with W=1, and checkpatch reports 0 errors and 0 warnings.

Row: J713 on the 27.2 stub with the stock command line. The kernel is the fleet80c default cut plus this commit, tested A/B against the same cut without it; the J713 DTB is identical, so only a grub one-shot was used.

DPMS off/on lit-panel deep sleeps (RTC 20 s) DCP restarts DART faults oops failed / AVC
fleet80c (634fbb2) 10/10 10/10 10 0 0 0
+ 48789bf 10/10 10/10 10 0 0 0 / 0

The DPMS power words are identical on both kernels (off 0x0f000300 / 0x2300 / 0x300, on 0x1000030f / 0x23ff / 0x3ff). The J713 tree passes the stricter checks: there is no no display power layout line at probe. The J713 is back on its fleet80c default.

Still open from your list:

  • J713 lid wake: needs someone at the lid.
  • Neo (T8140) DPMS smoke: 48789bf only touches the DT-layout path, which T8140's static table doesn't take. The shared dcp_s2r_ret_write() is unchanged since your review, so I'm routing that row to the Neo queue.

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.

Re-review against pre-pr-checklist.md (§1–§6) at verified live head 48789bf2a42f41713426f702a902f7a8ec9f53de: 0 code or §1–§4/§6 blockers remain.

Prior CHANGES_REQUESTED Items — All Fixed Cleanly in 48789bf2

  1. dcp_s2r_layout_streams() fail-closed handling (drivers/gpu/drm/apple/dcp.c:406-416): Fixed. When a piodma child exists, a missing display DART returns -ENODEV and a 0 stream mask (including the apple_dart_enabled_streams() refusal on streams >= 32) returns -ENODATA, causing dcp_s2r_check_dt() to refuse the DT layout cleanly with no node/device ref leaks.
  2. Offset underflow and alignment guard (drivers/gpu/drm/apple/dcp.c:339-342): Fixed. Guards resource_size(&ps_res) < 4 || off[i] > resource_size(&ps_res) - 4 || off[i] % 4.
  3. Stale overview comment (drivers/gpu/drm/apple/dcp.c:307-308): Fixed. Now points to probe-time dcp_s2r_layout_streams().

Checklist Summary (§1–§6)

  • §1 / §2 / §3 / §4 / §6: Clean. Power/retention words and DART streams are derived from DT/hardware, default kernel command line is used, J715 stays fail-safe until qualified, all 7 commits carry human identity (Ryan Murray) + Signed-off-by: with no agent trailers, and the PR body includes Assisted-by:.
  • §5 J713 A/B on 48789bf2: Strong — 10/10 DPMS off/on with identical power words and 10/10 lit-panel RTC deep sleeps (0 DART faults, 0 oops, 0 failed units, 0 AVC, layout accepted at probe).

Remaining Before APPROVE

  • Base / CI: Still stacked on unmerged #2590 (j713-disp2/dcp272-internal, currently conflicting with its base) with 0 CI runs executed on 48789bf2. Needs retargeting onto integration/aurora (once #2590 lands/rebases) with green CI (dt-checks, host-tests).
  • Remaining §5 HW rows:
    1. J713 lid wake (hands-on-lid row).
    2. Neo (T8140) DPMS smoke covering the shared dcp_s2r_ret_write() path in dcp_s2r_domains_off() / dcp_s2r_domains_on().

All code blockers from the prior CHANGES_REQUESTED review are resolved; happy to upgrade to APPROVE once CI and the remaining §5 rows are in.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Neo (J700, T8140) DPMS smoke for 48789bf: PASS. This is the shared DT display-power layout path. Stock fleet cmdline, no appledrm params.

DPMS off/on (Mutter PowerSaveMode 3 -> 0) kernel errors failed units / AVC
Neo default (fleet79, no #2660) 10/10 0 0 / 0
Same tree as the J713 rows + 48789bf, kernel-only one-shot 10/10 0 0 / 0
  • On the drm/apple: stop the M4 MacBook Air's internal DCP firmware on macOS 27.2 (DPMS off, deep sleep) #2660 kernel, every cycle shows dpms Off, then On with eDP-1 still connected, and the backlight goes 0 -> 525. One 20 s deep sleep (apple-pmu-rtc wake) also passed 1/1, with the panel back afterwards.
  • The Neo's live DT has apple,t8140-display-power (/soc/display-power@3028a9c14). Neither refusal line ("no display power layout", "no apple,display-power in the device tree") appears in the log, so the stricter DART/offset checks accept the Neo's layout.
  • "Kernel errors" counts DART faults, oops, DCP crashes, timeouts and WARNINGs.
  • The Neo is back on its default.

That leaves the J713 lid-wake row, which needs someone at the lid. It is armed and will be posted here when it runs.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

The Neo DPMS smoke has passed and code review is clear, so the J713 lid-wake row is the last hardware row. This waits for #2590 (which now needs rebuilding on the rebased #2541), then a retarget onto integration/aurora so CI runs.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Replaced by #2819: the same 7 commits (range-diff all = against 48789bf), stacked on #2818.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants