Skip to content

J815 test tree: deep sleep + hibernation on the 27.2 stack, latest M5 PRs, DCP scanout-DART flush wait - #1

Closed
m0d16l14n1 wants to merge 452 commits into
j815/test-portsfrom
j815/test-next
Closed

m0d16l14n1 wants to merge 452 commits into
j815/test-portsfrom
j815/test-next

Conversation

@m0d16l14n1

@m0d16l14n1 m0d16l14n1 commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

J815 test tree: deep sleep (S2R) + hibernation (S4) on the current 27.2 stack, the latest M5 PRs, and a DCP scanout-DART fix.

Update 2026-11-16: first real T8142 deep sleep and wake on J815

On J815 boot e1d118f8 the SoC went down and came back: aura's resume stub returned to Linux (boot object resumes 0 -> 1, PMU stage f803 0x52), the sysfs write returned 0, PM: suspend exit, and the display and NVMe were back. The script's verdict was RESULT: REAL deep sleep and wake OK. This is the first T8142 sleep on J815 that resumed instead of hitting the WD2 reset at the commit.

What got the sleep engine past the commit. Every power word Linux left on was compared with macOS's own entry (J815 26B131 trace) and with macOS's state at its commit (J813 end state from Thomas's trace):

  • External DCPs (apple_sleep.dispext): the T8142 profile only lowered the internal DCP, but both DCPEXTs are bound and their domains were up. Their DARTs' PS write-disable bits were also set. They're now lowered with the display in macOS's order (DISPEXT0, DISPEXT1, DISP), with the write-disable bits cleared and the firmware stopped cold.
  • Words macOS has off and nothing in Linux lowered (apple_sleep.extra_off): SIO_CPU (on from iBoot, no driver on J815), GLOBAL_AUX_CTRL0/1, and, if on, FPWM0, the PCIe OCLAs, ATC2/3 and the displays' ADMA words. They're lowered children first using the J815 ADT's PMGR parent tree, and restored at the wake.
  • From Thomas's PRs, ported: PMP's domain off after its final stop (pmp_off, J813 S2R: SEP setup, PMP shutdown and GPIO IRQ recovery #4) and the PMU RTC alarm after the S2R timer (J813: T8142 S2R on #2043: PMU post-timer, DCP 27.2, test changes (the commit still resets) #3).
  • Diagnostics: a commit digest in PMU scratch, the dry run's full list of power words on (marked against macOS's commit), and a per-core start trace after the wake.

Still open:

  • Only the first core started in each complex comes back after the wake (CPU1/E0 and CPU7/P1); the rest time out. The new cpu_on_trace build is meant to show where they stop.
  • The external DCPs' firmware isn't restarted after the wake. T6050's v27 late stop is the in-tree model for that.
  • The SMC woke this sleep after 0.46 s, so staying asleep isn't proven yet.
  • Wi-Fi/BT after a wake is untested. The test run unbound the radio host, but the radio's PCIe link did retrain.
  • cs42l84 resume returned -62.

New on this branch since the last update (first-parent)

Commit What
a1f7579 Merge aurora-silicon#1963 (DjDeveloperr, T6050 suspend to RAM): the per-SoC sleep framework T8142 now runs on
0a9c2e4, 37da981 SPMI gen-4 exchange recovery and the tipd SSPS sleep rules on the M5 Airs
8d5fafd, a3b7e53 T8142 profile from macOS's own sleep; SMC sleep sequence in the last stop
7168e52 arm64 spin table: optional EL1 last WFI; a timed-out core start can be retried
249a317, 133e9e0 apple-nco and MCA: registers restored after a sleep that cuts the power
0125d45 DCP and ANS sleep stops on by default (appledrm.s2r_untested, nvme_apple.sleep_untested)
17cade7 SMC sleep notices at native-speed spacing (from gig3m's 10-core J813 trace)
02d0ba0 AOP endpoints stopped for s2idle too on T8142
8d0f252 T8142 deep sleep reaches a real wake on J815 (dispext, extra_off, pmp_off, PMU alarm, diagnostics)

Built as Image eb0cfccf (the sources of this head), DTB 06e68d07; the run above was on 1369f0b3, which is the same minus the core-start trace and the retry fix.

Merged into this fork

Acknowledgements


Earlier description

Base: j815/test-ports (edc9ca1), the kernel that boots today on the macOS 27.2 (26B123) stub. This PR is the delta on top of it, so it can be tested and reviewed in pieces. The loader side is m0d16l14n1/aura#1 (j815/b13-sleep-hib).

@gig3m, this includes everything from your J813 runs on aurora-silicon#1806: the dcpext phandle, the clock-ids, the DPTX controller on 0x24 with the ports on 0x2a, and DP audio. The aura PR has your ssw-tunables fix with credit. There's one new thing that may affect your J813 too: the disp0 DART flush wait below. If you see TLB command 0x1 for stream 0 timed out at KWin start on the J813, this branch should either make it go away or print how long the flush really takes.

What's in it (first-parent order)

Commit What
d32ac2e Merge latest integration/aurora (7c71d6d, +12)
ade2dc8 Merge aurora-silicon#1477 at 59454c7 (fbalazsy, J616s hibernation + S2R, reworked since our a7f9a76 port; also split as aurora-silicon#1904-aurora-silicon#1916). Clean merge
192a56c J815 T8142 deep sleep + hibernation, carried from the existing branches (details below)
0605bbc Merge aurora-silicon#1732 (DjDeveloperr): J813 Touch ID, T8142 SEP profile for J813 + J815
ca711e2 Merge aurora-silicon#1242 (rolotrealanis98): name the cause and the clients of every M5 GPU recovery (diagnostics only)
ea275d9 Merge aurora-silicon#1863 (niteria): H17 ANE idle park. T8142 uses this backend (macos_sleep, not warm). Off with ane.idle_park_ms=0
8ec9aa9 Merge aurora-silicon#1847 (dmitzsaz): J704 PMP always-on, trackpad actuator, MCC (DTS only)
d2737f1 iommu: apple-dart: let a scanout DART's TLB command wait for its frame (new, the DCP fix)

Our own open PRs (aurora-silicon#1532, aurora-silicon#1534, aurora-silicon#1805, aurora-silicon#1806, aurora-silicon#1879, aurora-silicon#1880, aurora-silicon#1881, aurora-silicon#1899, aurora-silicon#1900, aurora-silicon#1905-aurora-silicon#1908) and aurora-silicon#1683/aurora-silicon#1696 were already in j815/test-ports. I compared each PR's current head with the tree, and the only differences are DTS ordering and newer integration context.

192a56c: where the sleep/hib work comes from

Nothing was rewritten. The existing work was carried over:

  • j815/test-sleep 63034e53 (worktree linux-sleep, 12 commits on test-pr3): AIC3 config loss, PMC DCS vote, DART GAPF slice, NVMe T8142 sleep values, G17 domain raise before the commit stop, DCP fw27 sleep calls + per-SoC layout, MCC ways off, DCP DART PS write-disable, T8142 on the per-SoC sleep ops (dry-run gated), DCP A500 tag gate, pen deep-sleep WFI, J815 sleep DT incl. the boot core's power gate (pwrgate +0x60).
  • j815/test-hib b6c059001011 (worktree linux-hib2): the b47-b60 hibernation work. That's the M5 GPU cold republish, the appledrm display hold while the initramfs may resume (the hibernation root cause of 11-13), PMU breadcrumbs through the restore, the boot-CPU release-address layout fix, and the sleep mailbox re-read after a restore.
  • Two fixes that were only uncommitted in those worktrees, i.e. the never-booted esp-bundle-sleep3:
    • sleep_asc_running(): a coprocessor's ASC run bit is read only at full power. Boot 14343f67 reset at .enter without it, the b29 fix that was lost in the port. In the same fix, a dry run writes no power word (lower_stray(dry)), and the PMU step notes 0x20-0x28 are back.
    • sleep_restart: true for the T8142 GPU (boot 08ab098a: genpd_prepare -16).
  • Resolution: 26 of the 38 files are byte-identical between J616s (M4 Pro) at EL2: hibernation and suspend-to-RAM aurora-silicon/linux#1477 a7f9a76 and 59454c7, so they take test-hib's resolution unchanged. The other 12 were 3-way merged. Three needed hand fixes:

d2737f1: DCP, the disp0 DART TLB timeout

On every 27.2 boot (087491fd, 9a636e2e, 6eff5253, fa897ab0, 09454ec2), and since 11-10 on 27.0, this appears 1-4 times at KWin start and again at unlock after a sleep:

apple-dart 286300000.iommu: TLB command 0x1 for stream 0 timed out (0x8600e100)
  • 0x8600e100 = busy, FLUSH_SID with V2|RANGE|STT, stream 0, which is disp0's scanout stream. It is still busy after the 2 ms poll.
  • The map fails and KWin logs drmPrimeFDToHandle failed / Failed to create framebuffer. About 80 ms later the next import works, so the flush does finish, just later than we wait.
  • The likely cause: the scanout DART holds a ranged invalidation until the pipe is done with the frame it is reading (16.7 ms at 60 Hz).
  • macOS gives no sequence to copy here. On T8142 the SPTM does DART maintenance, and our hypervisor DCP traces (logs/tether/m4air-20261114-08*-display) see only the DCP mailbox. Their DART dump does confirm disp0 rev 0x0204 (PARAMS 0x7e323010 0x301100ff 0x2a2a0204 0x21020) with streams 0 and 16 live.
  • Change: a new apple,tlb-busy-timeout-us (default unchanged at 2000), set to 34 ms (two frames) on the J813/J815 disp0 DART in t8142-j813-display.dtsi.
  • A command that would have timed out under the old wait now logs TLB command 0x1 (range) took N us. So the next boot either confirms the frame-wait theory or shows the timeout with its real wait.

Left out on purpose

Build and checks

  • RECONFIG=1 KSRC=linux-next EXTRA_CONFIG="tools/config/j815-ports.config tools/config/j815-hib.config" tools/build-kernel.sh full: rc 0, no new errors.
  • Image c718fff0, t8142-j815.dtb 52bdecd5, t8142-j813.dtb 40c0742a, t8142-j704.dtb e4f67ad9.
  • Known harmless warning: SPMI_CMD_WRITE redefined in sleep-internal.h against <linux/spmi.h>. The one raw PMU write comes after it, so it uses Apple's value, and test-hib had the same includes.
  • dt_binding_check on iommu/apple,dart.yaml and CHECK_DTBS for J815/J813/J704 against it: clean.
  • The J815 DTB contains sleep-controller@380700000, power-gate@380724000, display-power@380724000, the DCP DART ps-wr-dis, usb-pd@8 (MagSafe) and the disp0 apple,tlb-busy-timeout-us.
  • The §7 guard against lost driver hunks: no file deleted vs test-ports, and every removed line that mentions T8142/J813/J815 was checked; they are reworded comments from arm64/sep: describe J813 Touch ID and admit its T8142 profile aurora-silicon/linux#1732/J616s (M4 Pro) at EL2: hibernation and suspend-to-RAM aurora-silicon/linux#1477. J815 mentions in drivers/sound/dts went 75 → 110.
  • KUnit and host tests were not run.

How to test (nothing deployed)

Stage 2 must come from m0d16l14n1/aura#1, built on b13 like the enrolled Stage 1.

Stage 1: that branch carries the live ANS hand-off, not the power cycle. So it needs the c6845008 Stage 1 (aurora-stage1-c6845008.macho). Behind the ans-cycle Stage 1 (md5 1f2b96ad) it can't start ANS. Re-enrol in 1TR first, or rebase aura#1 onto the cycle branch once that works.

  1. Boot as usual and check the DCP fix. dmesg | grep -E 'TLB command|286300000' should show either nothing, or took N us, which confirms the theory.
  2. Deep sleep:
    • dmesg | grep 'probe: pwrgate' must read 0x80000000 0x80000000.
    • Run sudo sh /run/aurora/aurora-sleep-test step dryrun and expect dry run: every check passed. If it resets, PMU note 0x2x names the check.
    • Then run deep, with apple_sleep.untested_commit=1 for a real commit.
  3. Hibernation:
    • aurora-hib-test status, then arm + reboot. The aurora,hibernate-info and aurora,hibernate-refused props tell you whether aura took the layout.
    • Then ladder, test-resume, real.
  4. ANE: after 5 s idle, H17 ANE: idle 5000 ms: parked until the next request should appear. The next request boots it from the preload.

Risks: none of the sleep, hibernation or DART change has run on this stack. The M5 GPU warm restart after a real deep sleep has never run on any stack. Deep sleep stays opt-in (apple_sleep.deep) and dry-run gated (apple_sleep.untested_commit).

Assisted-by: Claude Opus 5.5

fbalazsy and others added 30 commits November 14, 2026 17:16
The boards whose transport is restarted in place after a resume were one
expression that grew by an OR with the second board, with the chip IDs
repeated in it. Make it a table of chip and machine pairs that the
admission function walks; the next board is a row.

The probe of a function the sleep reset compared the boot stage and the
RTI status with a bare 2. Name the two values a running firmware shows.

No change in behaviour: the same two pairs are admitted and the same
values are compared. tools/asahi: the identity test takes the table with
the function and gets a row on the other row's board as mutants, and the
resume test compiles the table ahead of the functions.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The HCI core suspends and resumes every controller from a PM notifier of
its own, before tasks are frozen and after they are thawed. The system
sleep callbacks of this driver call hci_suspend_dev() and
hci_resume_dev() too, so each ran twice per sleep, the second time
without commands but with its management events sent again.

Where a suspend to RAM takes the firmware, the notifier's resume races
with the driver: the driver leaves the core suspended until the queued
reset has booted the firmware, and the notifier resumes it as soon as
tasks are thawed. The reset is queued on a freezable workqueue and
normally has the request lock by then, so the notifier waits for it or
finds the controller down and does nothing. If the notifier ever gets
there first, it sends the core's resume commands to a function without
firmware, which fails each of them at error level.

Give the board table a property for such a board and set
HCI_QUIRK_NO_SUSPEND_NOTIFIER for it, as the MT7932 driver does for the
same reason: the driver's callbacks are then the only ones. The core is
suspended from the device suspend callback, after the freeze, and
resumed from the device resume callback or, after a cold wake, behind
the reset. Userspace sees one suspend and one resume event per sleep.

The BCM4378 on a J493 keeps the notifier.

tools/asahi: the identity test holds the quirk to the BCM4388 on a
J616s, with the property moved and removed as mutants.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
On a board whose suspend to RAM takes the firmware, every wake printed
the window and the two status words it found. That is the expected
state there, and the restart that follows says why it runs; keep the
values for debugging. The comment names the chip the values were read
on instead of the machine.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Three comments of the H16 backend named a firmware class with a quoted
test, a workload and a bring-up observation. Say what the firmware does
with the queued-request flag, what the program window has to hold and
why an engine quarantined at its start must not refuse a sleep.

An engine quarantined at its start is powered off by the first sleep and
stays off; say so once, not at every later sleep.

No change to how the engine is handled.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
A kernel that attached the enclave refuses to load a hibernation image
over it: its PM_RESTORE_PREPARE notifier returns NOTIFY_BAD. The PM
core then sends PM_POST_RESTORE to the notifiers that ran before the
one that refused, not to that one. The notifier had already marked a
sleep as held before it asked the driver, and nothing took the mark
back: diag/sleep read "held" for the rest of that boot, or until a
later sleep ended, although the boot went on with the enclave in use.

Mark the sleep only once the restore is accepted.

The host test runs the notifier now: a refused restore leaves nothing
held, an accepted one is released by PM_POST_RESTORE, and a mutation
that marks the sleep before the refusal is caught.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
An adopted MTP session keeps the buffers it negotiated with the boot
stage that started it, so on boards where the firmware cannot give them
up a request for a buffer the inventory does not list is refused. Probe
decides that for a session with an inventory, for T8132, and for the
J614s MTP. The restore after a hibernation adopts the session of the
resume boot the same way but decided again with a copy of the rule that
lacked the J614s: there a session adopted with an empty inventory
refused new buffers after probe and granted them after a resume from
disk, replacing storage the firmware still uses.

Take the decision in one helper, and in the restore make it before the
new session's receive path starts, as probe does.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
A resume from disk goes through a boot. The codec then holds its reset
defaults, or what the kernel that loaded the image wrote, while the
restored kernel's register cache holds the state of the image. The
restore callback was the resume one, which writes the registers back
only after a firmware-driven suspend: after a hibernation the codec
kept the wrong registers, the plug detection and the interrupt masks
among them, and a jack plugged before the hibernation stayed reported
although nothing drove it any more.

Give the restore its own callback: after a real restore it resets the
codec, writes the cache back and reports a jack gone, as the resume
does after a suspend that cut the power. A hibernation given up before
its image goes on as before.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
A resume from disk goes through a boot, and the PMU's alarm does not
come back as the image left it. The kernel that loads the image stops
an alarm that is no longer ahead when it binds this driver, and the
boot firmware leaves the comparator close to the end of its range when
it has no wake of its own. An alarm whose time passed with the machine
off had its event acknowledged there. The restored kernel's RTC core
still counted the alarm as set: its time stayed in wakealarm, a new
alarm was refused as busy, and an alarm still ahead never fired.

After a real restore, have the RTC core go through its timers: an alarm
that is due is reported, a later one is written to the PMU again, and
with none the PMU's alarm is stopped.

The power-off callback does not cover this. Only a hibernation that
powers off through platform hibernation ops calls it, and no Apple
machine has those: the power-off or reboot after the image leaves the
alarm armed. Say so where the callback and the prepare comment claimed
otherwise.

The host test covers the restore, with two mutations.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
… disk

After a resume from disk the block holds what the boot loader and the
kernel that loaded the image set up, while the register cache of the
restored kernel still holds the words of the image. The early restore
wrote back only the pins set up as interrupts and left the others to
their consumers. A consumer does not reach the pin either: its write
goes through regmap_update_bits(), which compares with the cache and
skips a word the cache already has. An output set again to the level
it had before the hibernation, and a pin function selected once at
probe, stayed as the boot left them.

Compare every pin this driver has written with the block, and write the
cached word back where they differ. The write is the one the resume
from a suspend that cut the block's power uses: the configuration
first, the input enable in a write of its own, the lock last, and a
locked pin left alone.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
While Linux is away the queue keeps being used: aura's wake path and
the platform's sleep code write the PMU through it. Every command the
driver sent was answered before the suspend, so a reply still waiting
at the resume is someone else's, and the next command takes it as its
own. On the M4 Max that was the RTC's acknowledge of the alarm that
woke the machine ("unexpected SPMI response 0x8b30"), after which the
RTC refused every later suspend.

Read such replies out at resume_noirq after a firmware-driven suspend.

Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
After a resume from disk the controller holds the masks and the pending
interrupts of the kernel that loaded the image. The driver rewrote them
in the noirq restore and, for a controller in a PM domain, in the early
restore, with a flag to keep the two apart: for a device in a domain
genpd calls the driver's noirq resume, not its noirq restore.

The early restore runs for every controller, in a domain or not, and
still before any device on the bus is restored. There the rewrite can
also take the command lock, so that no reply is acknowledged away under
a command. Do the rewrite there only: the noirq restore becomes the
noirq resume, as genpd already made it for the controllers in a domain,
and the flag goes.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The sleep commit writes the WKTP key ahead of 'slpa', and the wake
writes it again once it is a full one. That is what the T6041's SMC
needs: without the second write it goes on treating the time awake as
a dark wake, keeps its own fan policy against a manual request and
asks for a sleep under thermal load. The writes sat in the commit path
every SoC shares, so the T8140's sleep sequence, which was established
without the key, gained two commands that have not been run there.

Key the writes on match data, set for apple,t6041-smc. Every other SMC
gets the sequence it had.

The KUnit cases run the sleep order and the refused commit for both
kinds of SMC.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
After a suspend that cut a block's power a T6041 pin takes its word in
steps: the configuration, the input enable in a write of its own, the
lock last. Written whole, the pin reads 0 for good. The helper that
does this replaced the single write for every block, the uncached
T8140 blocks included: the single write is what has been run there,
and the helper also leaves alone a pin that reads locked.

Select the stepwise write through match data, set for
apple,t6041-pinctrl. Every other block gets its word whole again.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The receive interrupt handler first reads the FIFO count and, below
the programmed threshold, writes the threshold again and treats the
interrupt as spurious. That repairs one situation: after a resume from
disk the threshold register holds what the boot left, while the
restored interrupt state says that receive is armed. But it ran on
every receive interrupt of every SoC, with a register read of its own,
and it held back an interrupt that came early for any other reason,
which the clients have always handled by reading what is there.

Run it only in a kernel that was restored from an image. Elsewhere the
handler takes every receive interrupt as it did.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The FIFO interrupt chip passed a wake request on to its parent
interrupt at the AIC, on the grounds that a suspend to RAM masks every
AIC interrupt that is not a wakeup source. Nothing does: the AIC chips
skip set_wake themselves, and a firmware-driven suspend masks every
AIC interrupt and brings the masks back from the IRQ core's books. No
client arms a FIFO interrupt for wake either: data that has to wake
the system is reported with pm_wakeup_hard_event().

Put IRQCHIP_SKIP_SET_WAKE and its comment back. No functional change:
nothing called the callback.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Two module parameters chose what the sleep commit and the full wake
write to WKTP while the values were being established. They are: 2 at
the sleep request, 0 once the wake is a full one. Nothing sets the
parameters to anything else, and a value written from user space into
the sleep sequence is no interface to keep.

Remove sleep_wktp and wake_wktp and write the two values.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The parameter turned on the implementation defined PMUv3 traps for KVM
guests on the T6040 cores, which are not in apple_cpus, until the
traps are verified there. They have not been, the parameter is off by
default, and a boot parameter is no place for a test switch: once the
traps are verified, the two MIDRs belong in apple_cpus.

Remove the parameter and its documentation. The file is again as it
was before the parameter: guests on these cores see no PMU.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The T6041's AIC is the AICv3 of the T8140 and loses the same state when
a firmware-driven suspend cuts its power. It was admitted to the save
and restore by a helper that looked for the T6040 sleep controller in
the device tree and for its driver in the configuration, next to the
fw_suspend flag the T8140 entry carries for the same purpose.

Give apple,t6041-aic3 an entry of its own with fw_suspend set and drop
the helper. The save runs only under a firmware-driven suspend, so a
board without the sleep controller does nothing more than keep an
unused array.

A kernel built without the T6040 sleep driver gains something: the
syscore, and with it the mask resync after a resume from disk, used to
be registered only with that driver configured, so such a kernel came
back from hibernation with the masks of the kernel that loaded the
image.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The masks are rewritten from the IRQ core's books on every syscore
resume that did not follow a firmware-driven suspend, on the grounds
that a resume from disk is the only other one that loses them. The
resume that follows the snapshot of a hibernation, in the kernel that
goes on to write the image, got the same rewrite with the values
already there.

Ask the PM core whether this kernel was restored from an image, and
rewrite the masks only then.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
A kernel restored from a hibernation image finds in the AIC the masks
of the kernel that loaded the image: that one masked every IRQ at its
init and unmasked what it used itself. This does not depend on the SoC
or on the AIC's version, but the syscore that puts the masks back was
registered only for the SoCs with a firmware-driven suspend.

Register it whenever hibernation is built in. The save and restore
around a firmware-driven suspend stay with the SoCs that have one: the
array for it is allocated only there, and the suspend callback returns
at once anywhere else. On a machine that never resumes from disk
nothing changes: the resume callback writes only in a restored kernel.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The kernel hibernates on Apple silicon only where the boot object says,
in /chosen, that it keeps the same memory layout on every boot, and it
reads the device tree of the resuming boot at the address the boot
object gives there. Neither property had a binding, and their prefix
was not a registered one.

Register the prefix and describe the two properties. The prefix is the
name of the boot loader that defined them, as u-boot's is: its released
versions publish the properties under this name, so a kernel that
looked for another one would not hibernate with any of them.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The helper that reads the ASC's CPU run bit came with the hibernation
callbacks, while the hand-off check and the removal read the same bit
with a copy of the expression. Move the helper up and use it there.

The three tests that read the bit with readl() are left as they are.

No functional change: every path reads the bit as often and at the
same point as before. With five users the compiler no longer inlines
the helper.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
After a resume from disk the driver repeats what probe does with a
freshly woken SMC: start the endpoint, send the initialization, wait
for it, check the boot stage and read the key count. The restore had
its own copy of the five steps.

Put them in one function. Probe now initializes the completions, the
driver data and the notifier head before the handshake instead of in
the middle of it, and the restore resets the completions before the
endpoint starts instead of after; none of that reaches the SMC, which
sees the same messages in the same order. The messages of a failed
handshake are the same at probe and at restore now, each with its
error code.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Probe masks every interrupt and drops what is latched before it sets
the controller up, and the restore after a hibernation starts with the
same loop. Give the loop a function.

No functional change: the same writes in the same order.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
A T6040 or T6041 PCIe-C DART that lost its state lost its probe
tunables with it, and the resume applies them again before the reset.
It found those DARTs by testing the compatible on every resume. Like
the other per-SoC properties of a DART, record it in a flag at probe,
where the tunables are applied the first time.

No functional change: the flag is set exactly where the three
conditions of the resume held.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
A T6040 port with a PCIe-C host is stopped for system sleep from a
worker: a PCIe endpoint driver that the stop unbinds may unregister a
PM notifier, which has to wait until the PM notifier chain is idle. The
router's .prepare waits for the worker.

A sleep that is abandoned before that .prepare (a wakeup event while
tasks freeze, a task that does not freeze, a notifier or an earlier
device that refuses the sleep) reaches PM_POST_* with the worker still
running. The notifier then waited for it for up to 60 s, inside the
chain, while the worker, with such an endpoint behind the port (the
USB Ethernet of a Thunderbolt dock, for one), waited for the chain. The
wake stalled for the whole 60 s. The notifier then gave up without
queueing the restart, so the port stayed closed until the next system
sleep: cable changes were only recorded, a replug included.

Do not wait in the notifier, and do not take the lock there while the
stop may hold it: mark the stop as left behind and let the restart
work wait for it. The next sleep may begin before that work has run.
The stop then serves that sleep as well, as its .prepare waits for it,
and the restart work stands down, so that PM_*_PREPARE does not have
to wait for the work, and through it for the stop, either.

sleep_hibernating is written by the PM notifier and read by .complete,
which the PM core runs one after the other, so it does not need the
lock that the notifier now avoids.

A deferred stop can still run while tasks freeze; say so where it is
queued, and put the comment about unfrozen work back on the direct
teardown it was written for.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
When a router stops, the AP takes LSTX back as a GPIO at the level
the router left it. For T6040 that became "high unless the router
drives the pin low", so that a pin its firmware released is held high
as well, but the rule was keyed on type7. T6050 is Type 7 too: for it
a released pin (LSTX control 0) changed from low to high, and for it
and for T8132 the control word was now read at every stop, also with
the cable gone, where it had only been read with the cable still in.
Neither can be checked on a T6040.

Give the rule its own match data field, set for T6040 only, and put
back the statement that the other routers had. For T6040 nothing
changes.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Which DP IN adapter of a T6040 router reaches which display pipe is
not known, so no DisplayPort tunnel can be set up through it. The
policy for it was wired up all the same: the M3 policy in the match
data, T6040 and T6041 in the list of SoCs with a qualified route, an
override in probe that disabled it again, and a t6040_dp_tunnels
parameter to lift the override.

Describe the router as what it is, without a DP IN policy, as the
match data had it before, and drop the parameter, the two entries, the
override and the test cases for the entries. With the parameter at its
default, which is the only way it was used, the router ends up with
the same disabled policy as before. A display on a T6040 Type-C port
is driven in DisplayPort alternate mode by the port's PHY and does not
go through the router.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The image of a hibernation is made after tipd_suspend(), which
disables the event interrupt and arms it as a wakeup source on a
controller that wakes the system, asserts the reset line on one that
does not, and stops the poll of a controller without an interrupt. A
resume from the image that restores the controller in place set the
controller up again but gave none of that back: such a controller
would have come out of hibernation with its event interrupt still
disabled, or without its poll, and no port event after it.

The SN201202x controllers of the Apple T6040, the only ones restored
in place so far, have an event interrupt, no wakeup-source and no
reset line, so nothing was left undone on them. Split the part of
tipd_resume() that undoes tipd_suspend() out and call it at the end of
the set-up after a cold boot as well.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
After a resume from disk the port controller is set up again in place,
but its port is only revalidated once the USB role switch of the
connector is there: the USB controller that provides it is bound again
after the resume and registers a new switch then. That last step was
left to user space, which had to write "roles" to the hib_resume
attribute after binding the USB controller. Without the write the port
stayed as the image had left it, with no cable event applied, until
the next system sleep; and two writers at once could both pass the
unlocked test of the pending flag and revalidate twice.

Do it in the kernel. If the lookup succeeds when the restore
completes, as it does for a connector without a role switch, the port
revalidates there. Otherwise the driver looks again whenever a USB
controller with a role switch has bound, from a notifier on the
platform bus that acts only while a port waits. The pending flag is
tested and cleared under the controller's lock.

hib_resume stays: it still reads "roles-pending" after an in-place
restore until "roles" is written or the next sleep, which is what
existing user space checks before it decides to probe the controller
again, but the write no longer does the work and no longer fails while
the USB controller is unbound.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
gig3m pushed a commit to gig3m/linux that referenced this pull request Nov 15, 2026
T8142 has no GAPF slice for the DCP DART. Its SPTM (27.2.1) keeps a bit
per DART in a shared PS write-disable register instead
(/chosen/dart-ps-wr-dis-entries): set, the fabric rejects writes to the
power word of the coprocessor CPU behind the DART. The driver clears
that bit where it clears GAPF bit 4 on T8140, for a DCP firmware stop,
and sets it again after. Only this DART's bit of the register is
changed.

A GAPF slice is handled as before. Nothing of the shared register's
boot value is written back, only this DART's bit.

From m0d16l14n1's J815 sleep work (m0d16l14n1#1, 192a56c),
taken out on its own for the DPMS firmware stop.

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
gig3m pushed a commit to gig3m/linux that referenced this pull request Nov 15, 2026
T8142's display power node has the power gate and power state words
only: its PMC keeps no count of the powered coprocessors, so there is no
pmc-dcp word.

From m0d16l14n1's J815 sleep work (m0d16l14n1#1, 192a56c).

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
gig3m pushed a commit to gig3m/linux that referenced this pull request Nov 15, 2026
hw.s2r stops the internal DCP's firmware and powers its domains off when
the display is turned off, and restarts it warm on DPMS on. Only T8140
had the data for it. This adds what T8142 needs:

- the power words and DART streams become a per-SoC layout
  (dcp_s2r_layout), with T8140's values unchanged and T8142's derived
  from the macOS 27.2.1 device tree and PMGR (DISP_SYS at 0x290,
  retention words 0x11cc/0x11f0, no exclave streams, no pmc-dcp);
- firmware 27.0's sleep calls: set_power_state and the AP link release,
  which 27.0 still dispatches as A500, and D572 (powerUpDART). A build
  whose table has no tag for the release (27.2 and later moved it) is
  not offered the stop, and T8142 is offered it on firmware 27.0 only;
- T8142 has no DCP secure mailbox (no dcp-exclave-mailbox in the 27.0 or
  the 27.2.1 device tree of a J813), so the stop no longer requires one
  on this SoC (s2r_no_secure_port).

The stop stays off by default on T8142 (appledrm.s2r_untested=1 enables
it).

This is a screen-off (DPMS) power saving. No firmware-driven system
sleep has run on T8142, and a SoC behind appledrm.s2r_untested does not
take the stop's system sleep path.

Tested on a J813 (MacBook Air 13" M5, firmware 27.0) on this series,
with and without appledrm.s2r_untested=1: DPMS off stops the firmware,
DPMS on restarts it ("RTKit: Initializing") and the panel comes back at
its brightness, 6 of 6 cycles. System power with the screen off (SMC
PSTR, on battery, 12 and 15 samples): 2.72 W without the stop, 1.81 W
with it.

The driver part is from m0d16l14n1's J815 sleep work
(m0d16l14n1#1, 192a56c), without its hibernation and deep
sleep pieces; the secure mailbox change and the J813 test are new.

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
aurora-silicon#1963's sleep engine (early-context regions, the SMC "saved" policy lane,
the coprocessor registry passes) on top of the J815 test stack, which
carries the T8142 sleep and hibernation work.

Fix-ups for the merge:
- drm/asahi: g17: asahi_g17_ps_on() takes the device; the M5 provider
  lookup moved below the declaration it needs.
- pci: apple: the parked port's DART and root-port state belong to the
  port, not to a restore entry.
- soc: apple: t6050-aop: apple_sleep_coproc_register_first() takes its
  pass.
- usb: dwc3: apple: the role-switch init uses the role directly.
- ASoC: cs42l84: drop the second copy of the firmware-sleep reset path
  that the merge brought in.

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <nekreshen@yandex.ru>
aurora-silicon#1963 drains a generation 4 controller's late reply after a failed
exchange, on the J714s only. The J813 and J815 (MacBook Air, M5) have the
same generation 4 nub-spmi controllers, and their deep sleep writes the
PMU on the same queue, so a stray reply there would refuse every later
command in the sleep. Take the J714s's recovery on both.

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <nekreshen@yandex.ru>
macOS 27.2.1's sleep entry on the J815 sends the system power state
command (SSPS, S3) to both port controllers over nub-spmi-a0, as on the
J714s (26B131 trace: usid 10 and 8; the third port is the debug link).
The J813 and J815 SN201202x controllers sit on the same generation 4
SPMI, and their sleep node asks for the command (apple,sleep-ssps), so
apply the J714s's rules there as well. Only a firmware-driven sleep sends
it.

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <nekreshen@yandex.ru>
Bring the T8142 suspend-to-RAM path in line with what macOS 27.2.1 does,
from two traces of its sleep entry under aura's virtualized SPTM: our
J815 one (26B131, two cores, the whole entry to the S2R timer start,
262144 records) and gig3m's J813 one (ten cores, the same build, with
the memory controller hooked). Where both hooked a block, the two agree
write for write. Still gated: the commit runs only with
apple_sleep.untested_commit=1, and nothing here has slept a Mac yet.

From the J815 trace:
- SPTM's per-DART PS write-disable bits (/chosen/dart-ps-wr-dis-entries):
  while one is set, the PMGR drops writes to that DART's power word.
  Clear the four macOS's SPTM clears during its entry (SEP, centauri,
  PMP, SIO DMA; the DCP's stays with the DART driver), only bits that
  are set, and report the words after the wake.
- The watchdog's page 2 (+0x2c |= 0x20) before WD2, restored at the wake.
- APCIe gen 4 lowering in macOS's order, PHY_SW before SYS_ST.
- A "last" coprocessor class in the registry
  (apple_sleep_coproc_register_last()): those stop after every other,
  for the SMC's sleep sequence. aurora-silicon#1963's first-stop passes become four.

From the J813 trace (gig3m's gist 89aedeca, 2026-11-15), the memory
side, 4.6 to 2.7 ms before the S2R timer, which T8142 skipped
entirely: each AMCC plane's +0x28000 word cleared two bits at a time in
macOS's order, the six SoC NI tables zeroed, the eight DCS channels'
enables stepped down and their lanes strobed (T8140's algorithm from
+0x580, with +0x680 rewritten first and only the enabled lanes), then
the clock word 0x380038000 <- 0x30000. It runs after the SoC and DCS
perf states, as on T8132. The J815 ADT's /arm-io/mcc has the same
layout (socni-count 6, dcs-count-per-amcc 8, plane mask 0xf).

The sleep node moves to t8142-j813-j815-sleep.dtsi, shared by both Airs,
with the 19 memory-side regions added. The SoC data test now expects an
MCC step on every SoC and checks the SoC NI tables and the PSWRDIS
table; T8142 is matched but untested. SPMI_CMD_WRITE becomes
SLEEP_SPMI_CMD_WRITE (it clashed with <linux/spmi.h>).

Known gap: apple,sleep.yaml has no t8142 entry yet.

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <nekreshen@yandex.ru>
The SMC's sleep commit (MBSE slpw, then slpa, then the AP idle notice)
belongs at the very end of a T8142 sleep, after every other coprocessor
has stopped, as macOS 27.2.1 does it on the J815 (26B131 trace): warning
to slpa 434 ms, slpa to the idle notice 3 ms, the notice to the S2R timer
41 ms. aurora-silicon#1963's "saved" policy lane only exists on the J714s.

Add apple,t8142-smc: commit_at_stop, a stop registered last
(apple_sleep_coproc_register_last()) and the three gaps per SoC, falling
back to the defaults elsewhere. A gated dry run no longer commits the
SMC. pmVC is not sent: its value is still unknown.

The notice test passes the new MBSW argument.

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <nekreshen@yandex.ru>
…d-out core again

A platform sleep driver can ask for the parked cores' last deep WFI at EL1
(spin_table_pen_deep_el1()), with the MMU off, every exception masked and
stage 2 off, instead of at the kernel's EL.

A core powered on again after a sleep stays in spin_table_cpus_off until its
own cpu_postboot. Before, the bit was cleared before the start, so a core
whose start timed out was never pulsed again on the next online attempt.

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <nekreshen@yandex.ru>
Suspend-to-RAM through the platform's firmware path takes the NCO channels'
registers, and the audio clusters came back with no clock. Each channel's
control, divider and increments are saved in suspend_late and written back in
resume_early, the divider first and the enable last, as set_rate does. A sleep
that kept the power writes the same values again.

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <nekreshen@yandex.ru>
…cuts the power

hw_params, startup and prepare are the only places a stream's cluster, serdes,
port and DMA adapter setup is written, and an open stream (speakersafetyd keeps
the sense capture open) keeps it across a sleep. A deep sleep takes those
registers. Each cluster's are saved after ASoC suspended the streams and written
back before anything resumes them: configuration first, then the port routing,
the enables last. A back end restores only its port words.

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <nekreshen@yandex.ru>
appledrm.s2r_untested and nvme_apple.sleep_untested now default to 1. On J815
both stops have passed every DPMS off/on, a 4 h s2idle and every deep-sleep dry
run, and the first real T8142 deep sleep and wake (boot e1d118f8) ran with both.
Without them a deep sleep is refused. 0 keeps the old behaviour.

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <nekreshen@yandex.ru>
The J815 trace's gaps were stretched by the tracer trapping on two CPUs. The
same entry on a J813 at native speed on all ten cores (gig3m, trace s12) has
slpw to slpa 192 ms and slpa to the AP notice 0.85 ms; the last stop now uses
those spacings.

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <nekreshen@yandex.ru>
macOS sends every AOP endpoint its sleep message (0xa4) and the AP idle notice
before it sleeps (J813 27.2 trace, endpoints 0x20..0x2c). With them running, the
lid-angle and HID streams woke s2idle every second on J815. T8142's config sets
sleep_in_s2idle; the other SoCs keep the firmware-suspend-only behaviour.

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <nekreshen@yandex.ru>
The first real T8142 suspend-to-RAM and return (J815 boot e1d118f8): the SoC
went down, aura's resume stub returned to Linux (boot object resumes 0 -> 1),
sysfs returned 0, display and NVMe came back.

What got the sleep engine past the commit, against macOS's own entry (J815
26B131 trace) and the J813 end state (Thomas Glanzmann's trace):
- dispext: the external DCPs (DISPEXT0/1) are lowered with the display, in
  macOS's order, their DARTs' PS write-disable bits cleared (they were set) and
  their firmware stopped cold; restored after a refusal and at the wake.
- extra_off: the OS-managed words macOS has off at its commit that no other
  step lowered (SIO_CPU, GLOBAL_AUX_CTRL0/1, FPWM0, the PCIe OCLAs, ATC2/3, the
  displays' ADMA words), children first, each only if on; restored at the wake
  once the parent is on.
- pmp_off: PMP's domain off after its final stop (Thomas, #4).
- the PMU's RTC alarm after the S2R timer (Thomas, #3),
  boot_auto (XNU's boot-time AUTO_ENABLE words), ps_keep, the clkgen and
  memory-side restores, mem_boot/mem_floor experiments (off by default).

Diagnostics: a commit digest in PMU scratch 0x8308..0x831e only (from 0x831f
the scratch holds data that isn't Linux's), the dry run's full list of power
words on (marked against macOS's commit state), and a per-core start trace
after a wake (apple_sleep.cpu_on_trace).

Open: only the first core started in each complex comes back after the wake;
the external DCPs' firmware isn't restarted; the SMC woke this sleep after
0.46 s.

Assisted-by: Claude Opus 5.5
Signed-off-by: Nick <nekreshen@yandex.ru>
sithglan pushed a commit to sithglan/aurora-linux that referenced this pull request Nov 16, 2026
iBoot leaves the boot core's power-gate enable (P core 0,
/arm-io/pmgr reg[34] + 0x60) clear on T8142, so the boot core never
powers down in WFI. The node lists the E and P clusters' first words,
which apple-cluster-pwrgate sets early in boot. T8132 and T8140
describe the same words; there they are enabled for deep sleep, here
for idle power.

Tested on a J813 (MacBook Air 13" M5, firmware 27.0), same kernel with
and without the node, on battery, SMC PSTR:
- PCPU_0's power state word reads off in idle with the node, on
  without it;
- screen off, idle: 2.72 W without, 2.54 W with (12 samples each);
- screen on, idle: 3.93 W without, 3.83 W with (3 samples each).
All 10 cores come up and the system runs as before.

The register layout is from m0d16l14n1's J815 sleep work
(m0d16l14n1#1).

Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
sithglan pushed a commit to sithglan/aurora-linux that referenced this pull request Nov 16, 2026
iBoot leaves the boot core's power-gate enable (P core 0,
/arm-io/pmgr reg[34] + 0x60) clear on T8142, so the boot core never
powers down in WFI. The node lists the E and P clusters' first words,
which apple-cluster-pwrgate sets early in boot. T8132 and T8140
describe the same words; there they are enabled for deep sleep, here
for idle power.

Tested on a J813 (MacBook Air 13" M5, firmware 27.0), same kernel with
and without the node, on battery, SMC PSTR:
- PCPU_0's power state word reads off in idle with the node, on
  without it;
- screen off, idle: 2.72 W without, 2.54 W with (12 samples each);
- screen on, idle: 3.93 W without, 3.83 W with (3 samples each).
All 10 cores come up and the system runs as before.

The register layout is from m0d16l14n1's J815 sleep work
(m0d16l14n1#1).

Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
@m0d16l14n1 m0d16l14n1 closed this Nov 17, 2026
gig3m added a commit to gig3m/linux that referenced this pull request Nov 17, 2026
iBoot leaves the boot core's power-gate enable (P core 0,
/arm-io/pmgr reg[34] + 0x60) clear on T8142, so the boot core never
powers down in WFI. The node lists the E and P clusters' first words,
which apple-cluster-pwrgate sets early in boot. T8132 and T8140
describe the same words; there they are enabled for deep sleep, here
for idle power.

Tested on a J813 (MacBook Air 13" M5, firmware 27.0), same kernel with
and without the node, on battery, SMC PSTR:
- PCPU_0's power state word reads off in idle with the node, on
  without it;
- screen off, idle: 2.72 W without, 2.54 W with (12 samples each);
- screen on, idle: 3.93 W without, 3.83 W with (3 samples each).
All 10 cores come up and the system runs as before.

The register layout is from m0d16l14n1's J815 sleep work
(m0d16l14n1#1).

Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
gig3m pushed a commit to gig3m/linux that referenced this pull request Nov 17, 2026
T8142 has no GAPF slice for the DCP DART. Its SPTM (27.2.1) keeps a bit
per DART in a shared PS write-disable register instead
(/chosen/dart-ps-wr-dis-entries): set, the fabric rejects writes to the
power word of the coprocessor CPU behind the DART. The driver clears
that bit where it clears GAPF bit 4 on T8140, for a DCP firmware stop,
and sets it again after. Only this DART's bit of the register is
changed.

A GAPF slice is handled as before. Nothing of the shared register's
boot value is written back, only this DART's bit.

From m0d16l14n1's J815 sleep work (m0d16l14n1#1, 192a56c),
taken out on its own for the DPMS firmware stop.

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
gig3m pushed a commit to gig3m/linux that referenced this pull request Nov 17, 2026
T8142's display power node has the power gate and power state words
only: its PMC keeps no count of the powered coprocessors, so there is no
pmc-dcp word.

From m0d16l14n1's J815 sleep work (m0d16l14n1#1, 192a56c).

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
gig3m pushed a commit to gig3m/linux that referenced this pull request Nov 17, 2026
hw.s2r stops the internal DCP's firmware and powers its domains off when
the display is turned off, and restarts it warm on DPMS on. Only T8140
had the data for it. This adds what T8142 needs:

- the power words and DART streams become a per-SoC layout
  (dcp_s2r_layout), with T8140's values unchanged and T8142's derived
  from the macOS 27.2.1 device tree and PMGR (DISP_SYS at 0x290,
  retention words 0x11cc/0x11f0, no exclave streams, no pmc-dcp);
- the firmware 27 sleep calls: set_power_state, D572 (powerUpDART) and
  the AP link's release, which 27.0 dispatches as A500 and 27.2 as A550
  (aurora-silicon#2063, the first commit of this series). A build whose table has no
  tag for the release (27.3 so far) is not offered the stop;
- T8142 has no DCP secure mailbox (no dcp-exclave-mailbox in the 27.0 or
  the 27.2.1 device tree of a J813), so the stop no longer requires one
  on this SoC (s2r_no_secure_port).

The stop stays off by default on T8142 (appledrm.s2r_untested=1 enables
it). On firmware 27.2 it also needs the DCP to run the firmware 27
interface there, which aurora-silicon#1683 ("drm/apple: dcp: T8142: Drive the macOS
27.2 firmware") adds; without it a 27.2 J813 runs H17P and the stop is
not offered.

This is a screen-off (DPMS) power saving. A SoC behind
appledrm.s2r_untested does not take the stop's system sleep path.

Tested on a J813 (MacBook Air 13" M5) with appledrm.s2r_untested=1:
- firmware 27.0, on this series with and without the option: DPMS off
  stops the firmware, DPMS on restarts it ("RTKit: Initializing") and
  the panel comes back at its brightness, 6 of 6 cycles. System power
  with the screen off (SMC PSTR, on battery, 12 and 15 samples): 2.72 W
  without the stop, 1.81 W with it.
- firmware 27.2 (t8142dcp 26B123), with the A550 entry: DPMS off logs
  "IOMFB: power on -> off" and "power_down_M3: disabling M3", DPMS on
  restarts the firmware ("RTKit: Initializing") and the panel comes back
  at its brightness, 3 of 3 cycles. Screen-off system power (SMC PSTR,
  on AC at the charge limit, 8 samples per cycle, 3 cycles each, the
  same boot setup with appledrm.s2r_untested=0 for the other side):
  4.84 W without the stop, 3.91 W with it.

m0d16l14n1 ran it on a J815 on firmware 27.2 with the A550 entry: 4 DPMS
cycles over 3 boots, the firmware stopped and restarted each time.

The driver part is from m0d16l14n1's J815 sleep work
(m0d16l14n1#1, 192a56c), without its hibernation and deep
sleep pieces; the secure mailbox change and the J813 test are new.

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
gig3m pushed a commit to gig3m/linux that referenced this pull request Nov 17, 2026
T8142 has no GAPF slice for the DCP DART. Its SPTM (27.2.1) keeps a bit
per DART in a shared PS write-disable register instead
(/chosen/dart-ps-wr-dis-entries): set, the fabric rejects writes to the
power word of the coprocessor CPU behind the DART. The driver clears
that bit where it clears GAPF bit 4 on T8140, for a DCP firmware stop,
and sets it again after. Only this DART's bit of the register is
changed.

A GAPF slice is handled as before. Nothing of the shared register's
boot value is written back, only this DART's bit.

From m0d16l14n1's J815 sleep work (m0d16l14n1#1, 192a56c),
taken out on its own for the DPMS firmware stop.

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
gig3m pushed a commit to gig3m/linux that referenced this pull request Nov 17, 2026
T8142's display power node has the power gate and power state words
only: its PMC keeps no count of the powered coprocessors, so there is no
pmc-dcp word.

From m0d16l14n1's J815 sleep work (m0d16l14n1#1, 192a56c).

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
gig3m pushed a commit to gig3m/linux that referenced this pull request Nov 17, 2026
hw.s2r stops the internal DCP's firmware and powers its domains off when
the display is turned off, and restarts it warm on DPMS on. Only T8140
had the data for it. This adds what T8142 needs:

- the power words and DART streams become a per-SoC layout
  (dcp_s2r_layout), with T8140's values unchanged and T8142's derived
  from the macOS 27.2.1 device tree and PMGR (DISP_SYS at 0x290,
  retention words 0x11cc/0x11f0, no exclave streams, no pmc-dcp);
- the firmware 27 sleep calls: set_power_state, D572 (powerUpDART) and
  the AP link's release, which 27.0 dispatches as A500 and 27.2 as A550
  (aurora-silicon#2063). A build whose table has no
  tag for the release (27.3 so far) is not offered the stop;
- T8142 has no DCP secure mailbox (no dcp-exclave-mailbox in the 27.0 or
  the 27.2.1 device tree of a J813), so the stop no longer requires one
  on this SoC (s2r_no_secure_port).

The stop stays off by default on T8142 (appledrm.s2r_untested=1 enables
it). On firmware 27.2 it also needs the DCP to run the firmware 27
interface there, which aurora-silicon#1683 ("drm/apple: dcp: T8142: Drive the macOS
27.2 firmware") adds; without it a 27.2 J813 runs H17P and the stop is
not offered.

This is a screen-off (DPMS) power saving. A SoC behind
appledrm.s2r_untested does not take the stop's system sleep path.

Tested on a J813 (MacBook Air 13" M5) with appledrm.s2r_untested=1:
- firmware 27.0, on this series with and without the option: DPMS off
  stops the firmware, DPMS on restarts it ("RTKit: Initializing") and
  the panel comes back at its brightness, 6 of 6 cycles. System power
  with the screen off (SMC PSTR, on battery, 12 and 15 samples): 2.72 W
  without the stop, 1.81 W with it.
- firmware 27.2 (t8142dcp 26B123), with the A550 entry: DPMS off logs
  "IOMFB: power on -> off" and "power_down_M3: disabling M3", DPMS on
  restarts the firmware ("RTKit: Initializing") and the panel comes back
  at its brightness, 3 of 3 cycles. Screen-off system power (SMC PSTR,
  on AC at the charge limit, 8 samples per cycle, 3 cycles each, the
  same boot setup with appledrm.s2r_untested=0 for the other side):
  4.84 W without the stop, 3.91 W with it.

m0d16l14n1 ran it on a J815 on firmware 27.2 with the A550 entry: 4 DPMS
cycles over 3 boots, the firmware stopped and restarted each time.

The driver part is from m0d16l14n1's J815 sleep work
(m0d16l14n1#1, 192a56c), without its hibernation and deep
sleep pieces; the secure mailbox change and the J813 test are new.

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
DjDeveloperr pushed a commit to aurora-silicon/linux that referenced this pull request Nov 17, 2026
hw.s2r stops the internal DCP's firmware and powers its domains off when
the display is turned off, and restarts it warm on DPMS on. Only T8140
had the data for it. This adds what T8142 needs:

- the power words and DART streams become a per-SoC layout
  (dcp_s2r_layout), with T8140's values unchanged and T8142's derived
  from the macOS 27.2.1 device tree and PMGR (DISP_SYS at 0x290,
  retention words 0x11cc/0x11f0, no exclave streams, no pmc-dcp);
- firmware 27.0's sleep calls: set_power_state and the AP link release,
  which 27.0 still dispatches as A500, and D572 (powerUpDART). A build
  whose table has no tag for the release (27.2 and later moved it) is
  not offered the stop, and T8142 is offered it on firmware 27.0 only;
- T8142 has no DCP secure mailbox (no dcp-exclave-mailbox in the 27.0 or
  the 27.2.1 device tree of a J813), so the stop no longer requires one
  on this SoC (s2r_no_secure_port).

The stop stays off by default on T8142 (appledrm.s2r_untested=1 enables
it).

This is a screen-off (DPMS) power saving. No firmware-driven system
sleep has run on T8142, and a SoC behind appledrm.s2r_untested does not
take the stop's system sleep path.

Tested on a J813 (MacBook Air 13" M5, firmware 27.0) on this series,
with and without appledrm.s2r_untested=1: DPMS off stops the firmware,
DPMS on restarts it ("RTKit: Initializing") and the panel comes back at
its brightness, 6 of 6 cycles. System power with the screen off (SMC
PSTR, on battery, 12 and 15 samples): 2.72 W without the stop, 1.81 W
with it.

The driver part is from m0d16l14n1's J815 sleep work
(m0d16l14n1#1, 192a56c), without its hibernation and deep
sleep pieces; the secure mailbox change and the J813 test are new.

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
DjDeveloperr pushed a commit to aurora-silicon/linux that referenced this pull request Nov 17, 2026
T8142 has no GAPF slice for the DCP DART. Its SPTM (27.2.1) keeps a bit
per DART in a shared PS write-disable register instead
(/chosen/dart-ps-wr-dis-entries): set, the fabric rejects writes to the
power word of the coprocessor CPU behind the DART. The driver clears
that bit where it clears GAPF bit 4 on T8140, for a DCP firmware stop,
and sets it again after. Only this DART's bit of the register is
changed.

A GAPF slice is handled as before. Nothing of the shared register's
boot value is written back, only this DART's bit.

From m0d16l14n1's J815 sleep work (m0d16l14n1#1, 192a56c),
taken out on its own for the DPMS firmware stop.

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
DjDeveloperr pushed a commit to aurora-silicon/linux that referenced this pull request Nov 17, 2026
T8142's display power node has the power gate and power state words
only: its PMC keeps no count of the powered coprocessors, so there is no
pmc-dcp word.

From m0d16l14n1's J815 sleep work (m0d16l14n1#1, 192a56c).

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
DjDeveloperr pushed a commit to aurora-silicon/linux that referenced this pull request Nov 17, 2026
iBoot leaves the boot core's power-gate enable (P core 0,
/arm-io/pmgr reg[34] + 0x60) clear on T8142, so the boot core never
powers down in WFI. The node lists the E and P clusters' first words,
which apple-cluster-pwrgate sets early in boot. T8132 and T8140
describe the same words; there they are enabled for deep sleep, here
for idle power.

Tested on a J813 (MacBook Air 13" M5, firmware 27.0), same kernel with
and without the node, on battery, SMC PSTR:
- PCPU_0's power state word reads off in idle with the node, on
  without it;
- screen off, idle: 2.72 W without, 2.54 W with (12 samples each);
- screen on, idle: 3.93 W without, 3.83 W with (3 samples each).
All 10 cores come up and the system runs as before.

The register layout is from m0d16l14n1's J815 sleep work
(m0d16l14n1#1).

Assisted-by: Claude Fable 5.2
Signed-off-by: Kyle Arrington <kyle@arrington.co>
m0d16l14n1 pushed a commit that referenced this pull request Nov 26, 2026
make pacman-pkg rebuilds and relinks the kernel (the build number goes
from #1 to #2), so the standalone Image.gz and modules tarball were not
the binaries in the Arch package, and the QEMU smoke run booted the
former. When the Arch packages build, take Image.gz (decoded from the
package's EFI zboot vmlinuz), the modules tree (with depmod run against
the package's System.map), the DTBs, the config and System.map from
the runtime and headers packages, so every asset and the smoke run use
the binaries that ship. Without makepkg the previous direct path stays.

Checked against the Arch packages of run 45429366862: the staged Image
equals the zstd payload of the package's vmlinuz byte for byte; 5915
modules with modules.dep; 1629 DTBs.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
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.

10 participants