Skip to content

arm64: dts: apple: t8142: CPU idle, PMU and cluster power gate on every M5 (on #2325) - #2328

Open
RyanTheTide wants to merge 4 commits into
mainfrom
dtfill/t8142-cpu-idle-default
Open

RyanTheTide wants to merge 4 commits into
mainfrom
dtfill/t8142-cpu-idle-default

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On the MacBook Pro 14-inch M5 (J704), the boot P core never powers down in WFI, perf has no hardware counters, and cpuidle-psci has no idle state under the loader's PSCI monitor. The CPU cluster power-gate enables, the CPU PMU and the PSCI retention state were described only for the MacBook Airs:

  • cluster_pwrgate existed only in t8142-j813.dts, so the J815 lacked it too.
  • cpu_pmu was enabled per board.
  • The idle states lived in the Air-only t8142-j813-psci-idle.dtsi.

These are CPU and PMGR facts of the T8142: the J704, J813 and J815 ADTs have the same /cpus and the same pmgr.

Change

  • Move cluster_pwrgate into t8142.dtsi, as t8140.dtsi already does.
  • Enable cpu_pmu in t8142.dtsi.
  • Rename t8142-j813-psci-idle.dtsi to t8142-psci-idle.dtsi and include it from t8142.dtsi. cpuidle-psci still only probes when a /psci node is present.
  • Update the file name in the comment in cpuidle-apple.c.

Testing

cpp + dtc before and after, decompiled trees compared node by node:

  • J813: unchanged.
  • J815: gains cluster_pwrgate.
  • J704: gains cluster_pwrgate, the PMU, the idle-states node and cpu-idle-states on all ten CPUs.

dt-validate -m reports nothing new on any of the three boards.

Still to run

  • @term-guy (J704), booted through the loader's PSCI monitor:
    • /sys/devices/system/cpu/cpu*/cpuidle/state*/usage climbs on every CPU.
    • perf stat -e cycles,instructions sleep 1 counts.
    • The cluster power-gate driver probes.
    • Three s2idle cycles pass. Deep sleep stays off: the J704 has no sleep controller node yet.
  • @m0d16l14n1 (J815): cpuidle residency on the boot core before and after.
Details

…ery M5

The Neural Engine (with its three DARTs and ANE_SYS power state), the
video encoder (two DARTs, VENC power tree) and both JPEG engines (DART,
JPG power state) are SoC blocks: the J704, J813 and J815 ADTs give the
same addresses, interrupts and power gates for ane, dart-ane, ave,
dart-ave, jpeg0, jpeg1 and dart-jpeg. Only the J815 enabled all three
and the J813 only the encoder (twice); the J704 had none of them.

Turn them on in t8142-peripherals.dtsi and drop the per-board enables.
The ANE and the encoder run firmware that iBoot preloads: the boot
loader hands the preload over by compatible and disables the node when
the ADT has none, so a board without a preload keeps them off. Every
DART keeps its engine's power domain. The JPEG engines need no firmware.

J815: no change in the built tree beyond status "okay" becoming implicit.
J813: gains the Neural Engine and both JPEG engines. J704: gains all
three.

The ANE and JPEG enables on J815 come from m0d16l14n1's
33d8f13 and c3c1417.

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

The CPU cluster power-gate enables, the CPU PMU and the PSCI retention
idle state are CPU/PMGR facts of the T8142, not of a board: the J704,
J813 and J815 ADTs have the same /cpus and the same pmgr. They were
only described for the MacBook Airs (cluster_pwrgate in t8142-j813.dts
alone, cpu_pmu enabled per board, the idle states in the Air-only
t8142-j813-psci-idle.dtsi), so on the MacBook Pro 14" (J704) the boot
P core never powered down in WFI, perf had no hardware counters and
cpuidle-psci had no state under aura's PSCI monitor.

Move cluster_pwrgate into t8142.dtsi (as t8140.dtsi already has it),
enable cpu_pmu there, and rename t8142-j813-psci-idle.dtsi to
t8142-psci-idle.dtsi, included from t8142.dtsi. Without a /psci node
cpuidle-psci does not probe, as before.

J813: unchanged. J815: gains cluster_pwrgate. J704: gains
cluster_pwrgate, the PMU and the retention idle state.

cluster_pwrgate is gig3m's (c58ab8c).

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

Copy link
Copy Markdown
Contributor Author

No row has covered this one yet. gig3m's J813 row on #2325 ran with this PR on top, but this change leaves the J813 tree unchanged, so that row only shows it doesn't break the J813 (including two deep sleeps). term-guy's J704 rows on #2325 and #2329 were on a kernel without it.

Still open, as listed above:

  • @term-guy (J704, through the loader's PSCI monitor): cpuidle usage climbing on every CPU, perf stat -e cycles,instructions sleep 1, the cluster power-gate probe, and three s2idle cycles.
  • @m0d16l14n1 (J815): cpuidle residency on the boot core before and after.

@m0d16l14n1

Copy link
Copy Markdown
Contributor

J815 (MacBook Air 15" M5) row for the boot-core cpuidle residency. Kernel: integration/aurora 2c35f5094de1 + this head 95dda1cb24eb (with #2325 1f4da1ec68ee), #2329, #2330, #2383, #2384, #2385 at their current heads.

Before and after. On the J815 this PR does not change the device tree: the J815 DTB with it is identical, node for node, to our previous J815 DTB without it, apart from phandle numbers. (In the old tree /pmu and dart-aop had an explicit status = "okay"; now they have no status property, which means the same.) So a "before" boot runs the same description. The row below is the "after".

Residency. 30 s with the desktop idle, deltas of cpuidle/stateN/{usage,time} (apple_idle driver):

CPU state0 (WFI) state1 (index 1)
cpu0 (boot core) 2 entries, 0.0% 14144 entries, 98.5%
all 10 CPUs 0.0% each 195531 entries, mean 91.7%

On T8142, index 1 is the second WFI entry by design (the driver keeps index 1 for the s2idle path, and CYC_OVRD is locked from M4 on), so it is named WFI, not CPU PD. The governor uses it for nearly all idle time on every core. No cpuidle or PMU errors in the boot.

@term-guy

Copy link
Copy Markdown
Contributor

J704 (MacBook Pro 14" M5) row. macOS 27.2 (26B123) stub. Kernel: this head 95dda1cb24eb (with #2325 1f4da1ec68ee), plus the J704 GPU (#2093 at f41fdbe5) and our Fedora install's J704 DTS on top. Booted through the installed aura.

No PSCI monitor here. The installed aura starts the CPUs with spin-table (secondaries confined at EL2), so there is no /psci node and cpuidle-psci does not probe. The idle driver is apple_idle, as in m0d16l14n1's J815 row. The tree's idle-states/cpu-retention and cpu-idle-states are present on all ten CPUs.

cpuidle. 30 s with the desktop idle, deltas of cpuidle/stateN/usage and residency:

CPU state0 (WFI) state1 (WFI)
cpu0 (boot core) +0 +2321, 99.8%
cpu1-cpu9 +0 to +6 +397 to +2037 each, 99.7-100%

Every CPU climbs.

PMU. Before this PR the J704 had no hardware counters (The cycles event is not supported). With it: hw perfevents: enabled with apple_t8142_pmu PMU driver, 10 (0,000003ff) counters available, and perf stat -e cycles,instructions sleep 1 counts 841,913 cycles and 2,012,280 instructions.

Cluster power gate. The driver ran at boot (apple_cluster_pwrgate.dyndbg=+p):

/soc/power-gate@380724000: power gate 0 0x80000000, now 0x80000000
/soc/power-gate@380724000: power gate 1 0x0, now 0x80000000

Read back through /dev/mem: both words are 0x80000000. On the kernel without this PR, the P word (+0x60, the boot core's) is 0x00000000, as the description says.

s2idle. rtcwake cannot wake the J704 (the SMC RTC is not a wakeup source), so each wake was a key press on the internal keyboard. The right-port USB gadget refuses to suspend after a resume (dwc3 41a280000.usb: dwc3_plat_suspend returns -11, on the kernel without this PR too), so the three-cycle run unbinds it first.

  • Three cycles in one boot: three s2idle entries and exits, each woken by a key, no device refusing to suspend.
  • Single cycles on three more boots of this kernel: two woke on the key. In the first of them, the boot also ran the cpuidle and perf checks above. It entered s2idle, did not wake on the key, and the Mac reset itself about 3.5 minutes later. The journal stops before the suspend, so there is nothing more to go on. An exact repeat of that boot woke normally, and so did a boot of this kernel with only the power gate disabled. So that is one hang in six s2idle entries on this kernel, not reproduced. I can't tie it to this PR, but I wanted it on record.

Deep sleep stays off: no sleep controller node on the J704 yet.

Unrelated to this PR, seen in the same boots: with #2325's AVE enabled, the J704 on 27.2 logs apple-ave ...: unsupported firmware (text CRC 24eb4625), since the driver knows only the 26A428 encoder firmware.

AI-assisted, tested by me on the hardware.

Conflicts: t8142-j813.dts, t8142-j815.dts (took integration: #1806 moved the board enables to t8142-j813-j815.dtsi and cluster_pwrgate there); dropped the now-redundant venc/ANE/JPEG enables from t8142-j813-j815.dtsi.

Signed-off-by: Ryan Murray <[email protected]>
Via the updated dtfill/t8142-media-default (#2325). No textual conflicts; t8142-j813-j815.dtsi: dropped the cluster_pwrgate copy integration added there (now in t8142.dtsi), t8142-j813-j815-sleep.dtsi comment points at t8142.dtsi.

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

Copy link
Copy Markdown
Contributor Author

Merged integration/aurora (d1b022d, via the updated #2325 branch); no textual conflicts, dropped the duplicate cluster_pwrgate integration added to t8142-j813-j815.dtsi (now in t8142.dtsi); t8142-j704/j813/j815 dtbs and cpuidle-apple.o build (J813/J815 differ from #2325 only by the implicit pmu status=okay).

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 22, 2026 10:34

@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 review of 7549efa949b3f1e1761fd93ed12a750fe4fd8511 (incremental diff over #2325 427ad2c57bc0 and full diff against main).

The hardware design of the incremental change is sound: cluster_pwrgate (reg PMGR +0x0 / +0x60), cpu_pmu (apple,t8142-pmu), and t8142-psci-idle.dtsi are T8142 SoC-level facts shared across J704, J813, and J815. apple-cluster-pwrgate.c maps the two words unclaimed via of_iomap() (no conflict with dcp_power or peripheral_clocks), all references to t8142-j813-psci-idle.dtsi are updated (t8142-j813-j815.dtsi and drivers/cpuidle/cpuidle-apple.c), and cpuidle-psci remains safely inactive unless /psci is present.

Blocking items

  1. Merge conflict against main (CONFLICTING / DIRTY) and stacking: arch/arm64/boot/dts/apple/t8142-j813-j815.dtsi conflicts at EOF with #1905 (4ac9958640, SIO AES enables) via #2325. Because this PR targets main while stacked on #2325, please restack/update cleanly once #2325 resolves its main conflict (preserving &ps_sio, &ps_aes, &sio_dart, &aes) and re-verify dt-checks and host-tests.
  2. Misplaced cluster_pwrgate node detaches mcc's doc comment in arch/arm64/boot/dts/apple/t8142.dtsi: cluster_pwrgate: power-gate@380724000 and its block comment are inserted directly between mcc's block comment (/* System level cache planes: ... */) and mcc: memory-controller@220000000. Please place cluster_pwrgate either before mcc's comment or in its own position (e.g. after pmgr, matching t8140.dtsi) so mcc's comment stays attached to mcc.
  3. §5 hardware evidence gaps on the updated head:
    • All hardware rows (@m0d16l14n1 J815, @term-guy J704, @gig3m J813) ran on pre-merge 95dda1cb24eb rather than the current head 7549efa949b3 (and will need refreshing after the rebase onto main), and none report the §5 regression counters (0 SELinux denials, 0 failed units, 0 new kernel errors).
    • On J704 (the only board newly gaining t8142-psci-idle.dtsi), the test booted under spin-table (apple_idle, no /psci node), so cpuidle-psci was not exercised on J704. If J704 does not yet have a PSCI monitor build to test against, please state that explicitly as a known limitation alongside the J704 apple_idle verification.
    • @term-guy's J704 s2idle testing observed 1 hang + ~3.5 min reset out of 6 entries (unattributed, not reproduced on repeat). Because cluster_pwrgate directly enables boot P-core power gating in WFI/s2idle, please confirm clean multi-cycle s2idle repeatability on the rebased head (or confirm that failure is unrelated).

Checklist summary (§1–§6)

  • §1 No model gating: Pass — moves cluster_pwrgate, cpu_pmu, and PSCI idle states into shared t8142.dtsi / t8142-psci-idle.dtsi.
  • §2 Production-ready: Pass — standard DT nodes, no cmdline parameters or workarounds.
  • §3 Safety / hardware correctness: Pass on DT/driver register definitions and of_iomap sharing; s2idle stability tracking noted under §5 above.
  • §4 Clean-room and attribution: Pass — all 4 commits carry human author/committer and Signed-off-by: only, with no AI trailers in commits.
  • §5 Evidence: Incomplete — exact-head CI on 7549efa949b3 is green (dt-checks and host-tests pass), but hardware rows predate the merge, omit §5 regression counters, did not exercise cpuidle-psci on J704, and include an unresolved 1/6 J704 s2idle hang.
  • §6 Naming: Pass.

Minor doc nit (non-blocking): the PR description and commit 95dda1cb24eb still state that cluster_pwrgate existed only in t8142-j813.dts and that J815 gains it, whereas #1806 already moved cluster_pwrgate into t8142-j813-j815.dtsi on main (so only J704 gains it now).

@github-actions github-actions Bot added area:bringup Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) merge-conflict Conflicts with the base branch (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 7549efa9: not ready yet

Check Detail
CI at head ok 2 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes no requested by DjDeveloperr
Hardware row at head ok comment at 7549efa9
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:bringup

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label 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 7549efa949b3

Blockers:

  1. A hang was seen with this change: term-guy's J704 s2idle testing hung once in 6 entries (then reset after about 3.5 min), and it wasn't reproduced or explained. cluster_pwrgate turns on P-core cluster power gating in WFI/s2idle on the J704, so this is the first suspect. Fix: a multi-cycle s2idle run on the J704 at the updated head (at least 10 entries) that comes back clean every time, or the same hang rate without cluster_pwrgate, showing it's unrelated.
  2. The branch conflicts with main through #2325 (the SIO AES block from #1905 at the end of t8142-j813-j815.dtsi). It merges after #2325, once that's updated.

Checked: no Apple material, no board gates: cluster_pwrgate, cpu_pmu and t8142-psci-idle.dtsi are T8142 SoC-level facts. apple-cluster-pwrgate.c maps its two words without claiming them, cpuidle-psci stays off without /psci, and the renamed include is updated everywhere. dt-checks and host-tests green. This replaces my earlier review. Nit: cluster_pwrgate sits between mcc's comment and mcc in t8142.dtsi; move it after pmgr, as in t8140.dtsi. J704 booted under spin-table (apple_idle), so cpuidle-psci itself is untested there; say so in the body.

Evidence

Read 7549efa9 (incremental over #2325) and term-guy's J704 notes.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 24, 2026 19:40

Superseded by the review at 7549efa

@m0d16l14n1

Copy link
Copy Markdown
Contributor

Can we merge it?

@gig3m

gig3m commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

J813 (MacBook Air 13" M5) row at 7549efa949b3, in m0d16l14n1/linux j815/prtest-r8 7b4bbe9 plus the local XRGB plane patch: unchanged, PASS.

  • cpuidle: apple_idle driver, both idle states present on CPUs 0-9 and both in use on this boot (CPU0 8762 and 861640 entries, CPU4 631 and 684853, CPU9 5077 and 669508).
  • PMU: hw perfevents: enabled with apple_t8142_pmu PMU driver, 10 (0,000003ff) counters available.
  • Cluster power gate: the sleep driver reads it at probe (pwrgate wake 0x80000000 0x80000000 ... clusters 0xf 0xf), and three deep sleeps on this tree each restarted the cores with "9 cores started in one burst" and 9 "Booted secondary processor" lines, CPUs 0-9 online.
  • 0 failed units, 0 WARN/BUG/Oops.

Assisted-by: LLM (Claude:Opus 5.5)

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 25, 2026
@term-guy

Copy link
Copy Markdown
Contributor

J704 (MacBook Pro 14" M5) s2idle row at 7549efa9: 12 of 12 s2idle entries woke on a key press, 0 hangs (suspend_stats success 12, fail 0). This is for blocker 1.

Kernel: this head merged into main a851ca0 (no conflicts; only this PR's 7 files came in), with the J704 GPU/display/audio heads on top (linux#2093 acddceeb, #2603 899dc80a, #2587 669d02c5). macOS 27.2 stub, booted through aura main + aura#398. The J704 runs spin-table (apple_idle), so cpuidle-psci itself is still untested here.

Power gate on: both words read back 0x80000000 (E +0x0, P +0x60) before the run. apple_t8142_pmu registers 10 counters.

Run: 12 entries, 20 s apart, each woken by a key press. 11 woke 2-17 s after entry; the 8th 2 min 14 s after, because the key was pressed late. 12 entries and 12 exits in the journal, no aborts. The USB gadget was unbound for the run, because its suspend refuses s2idle (-EAGAIN, as on the installed kernel). Afterwards: deep-idle residency 99.6 % on CPU0 (the boot core) and 99.4-99.8 % on the other cores; 0 failed units. The one AVC denial is from my test script's own setup, before the first entry.

On the first entry, as on every run on 11-20:

  • apple_pmp ... PMP firmware crashed, once per boot (first resume only). The 11-20 control runs had it too: the installed kernel without this PR, and this PR without cluster_pwrgate. So it is not from this change.
  • dwc3-apple ... genpd_prepare returns -11, once per entry, without aborting it.

Remaining kernel err lines: all known (of_irq_parse_pci for the PCIe devices, repeated as Bluetooth re-probes after each resume; the reserved-mem overlap notes; the unused Secondary DAI).

Against 11-20: 1 hang in 6 entries then, 0 in 12 now. The 11-20 hang (#1156) stays unexplained and wasn't reproduced either time. This run is at the current head; once the branch is updated after #2325 I can repeat it.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Picking this up for FIXUP-A (its lane ended). Blocker 1 needs a J704. There's no M5 in our lab, so @term-guy, could you run at least 10 s2idle entries on the J704 at this head once it's updated after #2325, or the same count without cluster_pwrgate to show the earlier hang is unrelated? Blocker 2 waits on #2325. When that merges I'll forward-merge main here and fold in your nit (cluster_pwrgate after pmgr in t8142.dtsi, and a body note that the J704 ran under spin-table, so cpuidle-psci is untested there) in the same push.

@term-guy

Copy link
Copy Markdown
Contributor

@RyanTheTide thanks for picking this up. #2325 is already in: it merged on 11-24 (8a1af390), and this head (7549efa9) merges cleanly into current main (99edb763, checked with git merge-tree). So the forward merge, cluster_pwrgate after pmgr and the spin-table body note can go in now.

The J704 run at the current head is in #2328 (comment): 12 of 12 s2idle entries entered and woke on a key, with cluster_pwrgate in place. Once your push lands I'll repeat at least 10 entries on the J704 at the new head and post the row.

@term-guy

Copy link
Copy Markdown
Contributor

J704 s2idle at main 99edb76 + 7549efa9 (merged locally without conflicts, the tree the forward merge gives; cluster_pwrgate is still at its current place, which changes no property): 12/12 on boot #1234, and 33 of 34 entries over three boots with cluster_pwrgate, with one resume hang. Details below.

Setup for #1232-#1234: test kernel 7.3.0-t29+ from that tree (no other PRs, so no GPU on this kernel; KDE shows only its cursor), its own t8142-j704.dtb + the ESP partition in /chosen, Fedora 44 root, macOS 27.2 (26B123) firmware, aura main + #398 chainloaded, RAM only. Each run: tools/s2idle-cycles.sh 12 detached (USB gadget unbound first, since its suspend refuses s2idle with -EAGAIN), echo freeze > /sys/power/state every 20 s, each entry woken by a key press (there is no rtcwake on the J704), logged over Wi-Fi.

Boot Kernel cluster_pwrgate Result
#1227 (11-26, posted above) main a851ca0 + linux#2587/#2093/#2603 + 7549efa9 on 12/12
#1232 main 99edb76 + 7549efa9 on 9/10: entry 10 did not resume
#1233 same, the node status = "disabled" in the DTB (the initcall skips it) off 12/12
#1234 same as #1232 on 12/12

The #1232 hang: entry 10 at 288 s of uptime logged PM: suspend entry (s2idle) and nothing after. The key press lit the keyboard backlight, but the panel stayed dark, and the Mac reset about 90 s later (watchdog). Entries 1-9 of that boot were like every other entry. I have not reproduced it since: #1234, the same kernel, DTB and chain, ran 12/12. So with the gate on that is 1 hang in 34 entries, and with it off 0 in 12. That is not enough to tie the hang to the gate or to clear it.

On every boot, with and without the gate: the PMP firmware crashes once, on the first entry only (as on 11-20 and in #1227); dwc3-apple genpd_prepare returns -11 on each entry (non-fatal); the msr-ase-core power state does not reach 0xf; suspend_stats on the clean boots 12 success / 0 fail; 0 failed units.

Once the forward merge is pushed I'll run the same count at the new head.

This branch has not been deployed

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

Labels

area:bringup 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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants