Skip to content

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

Open
RyanTheTide wants to merge 7 commits into
j713-disp3/dcp272-internalfrom
j713-disp3/dcp272-power
Open

RyanTheTide wants to merge 7 commits into
j713-disp3/dcp272-internalfrom
j713-disp3/dcp272-power

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

#2660 (stop the M4 MacBook Air's internal DCP firmware on macOS 27.2, for DPMS off and deep sleep) is stacked on #2590, which can no longer be merged (its base #2541 was rebased onto integration). #2590 is replaced by #2818.

Change

The same 7 commits as #2660 at 48789bf, replayed without conflicts onto 2818 (git range-diff shows all 7 =). This replaces #2660. Nothing changes in what they do:

  • drm/apple: the T8132 internal DCP on 27.2 gets the hw.s2r stop T8142 already runs on 27.2, with its power words from the device tree (power-domains chain, apple,retention-workaround, pmc-dcp, the DART streams its DARTs have enabled), not a per-SoC table. Without those properties the firmware keeps running, as before.
  • iommu: apple-dart: apple_dart_enabled_streams().
  • drm/apple: the lit-panel system-sleep stop is decided by hw.s2r alone (no J813 check).
  • dt-bindings: apple,t8132-display-power; J713 DT: the display-power node, apple,display-power on the DCP, and the DCP DART's clock-protection slice.
  • A DT layout that lacks its display DART streams is refused, and the power word offsets must be word-aligned (48789bf).

No kernel or module parameter is involved.

Testing

Earlier rows on #2660's commits (unchanged here) are on #2660: DPMS off/on 10/10 with the power words read back, and 10/10 lit-panel deep sleeps with RTC wake on the fleet80c cut, A/B against the same cut without 48789bf.

Still to run

  • Lid wake (needs someone at the lid), and a sleep-power number on battery.
  • Neo (T8140) DPMS smoke for the shared retention-write path.
Reviewer / agent detail

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>
… 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>
…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>

@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 (§1–§6) at verified live head 888805b87936b04d41f3fcea35beade5f84f6f26: 0 code blockers in these 7 commits, but not ready for APPROVE / MERGETRAIN-LINUX4 yet due to base stack state, 0 CI runs, and pending rebased-head hardware rows.

Verification Against #2660

  • Confirmed patch-identical replay of #2660 (dde724cb..48789bf2 vs a912b89b..888805b8: 0 code/text diffs, hunk line offsets only). Both prior CHANGES_REQUESTED fixes from #2660 (dcp_s2r_layout_streams() fail-closed piodma DART handling and dcp_s2r_layout_from_dt() non-underflowing bounds + 4-byte alignment checks) are preserved.

Checklist Audit (§1–§6)

  • §1 (No model gating): Pass. Power words (DISP_CPU/DISP_FE/DISP_SYS via power-domains chain, retention registers/masks/off-values via ps_disp_cpu's apple,retention-workaround, optional pmc-dcp) and enabled DART streams (apple_dart_enabled_streams()) are derived from DT and hardware state rather than a per-SoC table. Drops the of_machine_is_compatible("apple,j813") board check in dcp_platform_suspend(). J715 stays fail-safe without the new DT nodes until qualified.
  • §2 (Production-ready, no hacks): Pass. Default kernel command line; no new cmdline or module parameters.
  • §3 (Safety / DCP stop, handoff, suspend & non-M4-Air impact): Pass.
    • DT register math checks out against t8132.dtsi, t8132-pmgr.dtsi, and t8132-j713-pmgr.dtsi (dcp_power ps/pwrgate/pmc-dcp cover 0x240, 0x248, 0x10000, retention 0x2504c/0x25070, and dcp_dart gapf 0x38079cb80 = ps_prot + 0x100 + 42 * 0x40, matching apple,dart.yaml).
    • dcp_s2r_layout_from_dt() puts all device_node refs on every path, validates at > gate_res.start (guaranteeing ret_ff != 0), bounds, alignment, and mask containment, and fails closed cleanly.
    • dcp_s2r_layout_streams() runs inside dcp_comp_bind() after dcp_create_piodma_iommu_dev(), so both dcp_dart and disp0_dart are bound and powered when read; any missing DART, 0 stream mask, or enabled stream >= 32 fails closed (-ENODEV/-ENODATA) and leaves the firmware running.
    • dcp_s2r_ret_write() preserves exact whole-word writes (3/0 off, 0/1 on) when mask == 0 (T8140/T8142 static layouts) and masked RMW for DT-derived layouts, so non-M4-Air SoCs are unaffected.
    • (Minor non-blocking note) apple_dart_enabled_streams() reads dart->regs without pm_runtime_resume_and_get(dev) (safe here because ps_disp_cpu is firmware-owned and active at bind, matching apple_dart_display_streams(), but worth noting if ever reused on a runtime-suspended DART).
  • §4 (Clean-room & attribution): Pass. All 7 commits carry human author/committer (Ryan Murray) and human Signed-off-by: with zero AI trailers; PR body includes Assisted-by:.
  • §5 (Hardware evidence): Prior #2660 (48789bf2) rows are strong: J713 A/B 10/10 DPMS off/on + 10/10 lit-panel RTC deep sleeps (0 DART faults, 0 oops, 0 failed units, 0 AVC), plus Neo (T8140) DPMS smoke 10/10 + 1/1 RTC deep sleep (0 errors, 0 failed units, 0 AVC — note the PR body's "Still to run" still lists the Neo smoke even though it already passed on #2660). Still pending on this rebased PR: the queued J713 one-shot row on 888805b8 over current integration/aurora, and J713 lid wake.
  • §6 (Naming): Pass.

Remaining Before APPROVE / Merge

  1. Base stack & CI: Currently stacked on unmerged Draft #2818 (j713-disp3/dcp272-internal, which is itself stacked on Draft #2541) with 0 CI checks executed on 888805b8. Needs #2541 -> #2818 landed, retargeted onto integration/aurora, and green CI (dt-checks, host-tests).
  2. Remaining §5 rows: Post the queued J713 one-shot row for this rebased head on integration/aurora (with full regression counts) and the J713 lid-wake row.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 888805b.

  1. drivers/gpu/drm/apple/dcp.c:311-381, 9124-9200: this re-implements the consumer-switched power-off of this same DCP's domain chain. pmgr-pwrstate already does that from the same DT (apple,consumer-switched and the apple,retention-workaround on &ps_disp_cpu, t8132-j713-pmgr.dtsi:535-541) through apple_pmgr_ps_consumer_off()/_on() (pmgr-pwrstate.c:1332ff), which the M4 backend calls for this DCP (iomfb_m4.c:3662, 5543). The new path ioremaps the PMGR "ps" and "pwrgate" blocks and writes the state and retention words outside the pmgr driver's lock and its consumer_off/consumer_failed state. It also restores the retention words to a value read once at probe (dcp.c:372-373), where pmgr restores the value saved at power-off. Please drive the stop's DISP_CPU/FE/SYS steps through the pmgr API (extend it if the v27 stop needs a different order), or explain why it can't be used.
  2. dcp.c:7375-7376: "Linux never starts its CPU" is no longer true now that s2r is set: power-on after DPMS off or sleep restarts it. Update the comment.
  3. dcp.c:10009 (77e0841): dropping the J813 check means every T8142 board with appledrm.s2r_untested=1 (e.g. J815, t8142-j813-j815.dtsi:423) now also stops at system sleep. Either show a J815 sleep row or say in the message that this reach is intended.
  4. dcp.c:351: at <= gate_res.start refuses a retention word at offset 0 of "pwrgate". I take it that is because ret_ff == 0 means "no retention words" in dcp_s2r_domains_off/on. Add a comment saying so (or use an explicit flag), so it doesn't read as an off-by-one.
  5. arch/arm64/boot/dts/apple/t8132-j713.dts:196-217: the display-power block and the DCP DART's gapf slice are SoC addresses but are added in the J713 board file. drm/apple, iommu: apple-dart: drive the M4 MacBook Air's internal panel on macOS 27.2 (v27 backend, on #2541's rebase) #2818 made the 27.2 internal DCP board-independent, so put these in t8132.dtsi / t8132-dcp.dtsi (disabled where needed). Otherwise another T8132 laptop gets the backend with no stop and no message beyond "no display power layout".
  6. Rows owed at this head: J713 DPMS off/on x10 with the power words read back and s2idle with the panel lit (both queued, per the PR). Neo (T8140) DPMS off/on and s2idle, because dcp_s2r_domains_off/on now go through dcp_s2r_ret_write() for every layout. J813 s2idle as a no-regression row (shared suspend path). If T8142 rows aren't possible, say so.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J713 row (M4 MacBook Air, macOS 27.2 stub), one-shot boot of integration/aurora f1d5b24 merged with this stack (#2819 head 888805b on #2818 a912b89). Default kernel command line, unchanged Stage 2:

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