Skip to content

J616s at EL2: hib=1 fixed layout, T6040 S2R windows, the 26.7 display handoff and the S2R wake path - #148

Merged
RyanTheTide merged 15 commits into
aurora-silicon:mainfrom
fbalazsy:j616s/el2-hib-s2r
Nov 12, 2026
Merged

RyanTheTide merged 15 commits into
aurora-silicon:mainfrom
fbalazsy:j616s/el2-hib-s2r

Conversation

@fbalazsy

@fbalazsy fbalazsy commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

J616s (MacBook Pro 16" M4 Pro, T6040) with Linux at EL2: a fixed memory layout for hibernation (hib=1), the windows the T6040 suspend-to-RAM driver reads, the display handoff on a 26.7 machine, and a fix for the S2R wake path. Replaces #66, whose monitor and boot-object path #77 removed.

Kernel side: aurora-silicon/linux#1477 (on linux #1445).

Base: main 87c31c2. 15 commits.

Commits

Area Commit What it does
Build build: put hv_sprr.o back in .text .init is full on main (756 bytes left with the gcc of the build workflow); the kboot changes below add 5384 bytes and the raw image no longer links. hv_sprr.o (6792 bytes, guest-only) goes back to .text, which has room. The commit message has the bytes left for gcc 13.3.0, clang 22.1.8 and clang 23.1.4 in the Stage 1, ESP Stage 2 and RELEASE configurations.
Firmware version firmware: count every 26.7.x iBoot of the 18000.161.10 train as 26.6.2 for the component handoffs A J616s installed from Recovery runs 26.7.1 with iBoot mBoot-18000.161.10.701.1. The coprocessor images this iBoot loads match 25G83 (26.6.2) by text SHA-256. firmware_os_components() derives the handoff version from the iBoot train the boot reads, not from a chip ID. The OS version in the DT stays the detected one, and the kernel still checks every image it takes over.
Tests tests: give the PMP boot data fixture ARRAY_SIZE; tests: give the payload harness firmware_os_components() Keep run-pmp-boot-data.sh and the payload harness compiling with the two commits they precede.
PMP kboot: pass the PMP's optional boot arguments on every chip Not gated on T6040.
Hibernation kboot: fixed T6040 memory layout for hibernation at EL2 (hib=1) Opt-in through the Stage 2 payload line hib=1. The heap restarts at a fixed address and the DT handed to Linux is copied into a fixed 2 MiB slot below it. The layout is published in /chosen/aura,hibernate-layout and /chosen/aura,hibernate-dt. If the fixed range meets a CTXR/CTRR range, the firmware RO range, an MCC carveout or an ADT memory-map entry, the layout is refused, kboot says why, and Linux then refuses to hibernate. Without hib=1 nothing changes.
Hibernation ctxr_exec: a window at the same address on every boot, on request; kboot: hib=1: run the OS in the fixed CTXR exec window A restored image runs from the pages it was saved from.
Display handoff kboot: T6041 display handoff: publish the components firmware as compat; … publish the components release as firmware-version too; tests: T6041 display handoff host The DCP nodes carry the release of the firmware that actually runs (26.6.2 components on a 26.7 machine), with a host test for the 26.7 train.
S2R kboot: publish the ANS storage-apcie shared block for T6040 S2R Read by the T6040 sleep controller for the APCIe lower/raise.
S2R kboot: publish the DCP apple,display-power window for T6040 S2R; kboot: publish the DCPEXT apple,display-power window for T6040 S2R The display power words the S2R entry and wake drive.
S2R smp: never wait on the DockChannel when a S2R wake returns to the OS The boot core back from a sleep wrote one line to the DockChannel and waited up to 1 s per byte for FIFO room. A T6040's OS keeps the DockChannel off, so nothing drains the FIFO: the wake sat there for tens of seconds and the SMC's AP watchdog reset the SoC about a minute after the sleep. The line is now written only if all of it fits.

Review points from #66:

  1. Gating: the layout is only active with hib=1; the S2R windows are T6040-only and additive.
  2. The fixed version override is gone; the handoff version comes from the iBoot string the boot reads.
  3. test_smp_handoff_gate.py passes on this branch.
  4. The boot_storage fix and the T6040 boot-core power gate are on main (kboot: let the T6040 boot core power-gate too #119) and not here.

Tests

Host, on this head against main 87c31c2:

  • Stage 1, ESP Stage 2 and RELEASE builds link with gcc 13.3.0, and the RELEASE Stage 1 and ESP Stage 2 builds with clang 22.1.8 and 23.1.4 (BUILTIN_LOGO=aurora); every commit of the series links with gcc 13.3.0. Bytes left per configuration are in the first commit. Without that commit the gcc builds fail to link (4628 bytes over in .init).
  • tests/run-pmp-boot-data.sh passes; format-check passes with clang-format 20.1.8.
  • pytest as in test.yml, gcc variant: 682 passed, 9 skipped, 1 xfailed, 2 failed (test_loadobjs.py, on main too in this environment). llvm variant with clang 23.1.4: 677 passed, 6 failed, the same six on main. The tests main changed with its T6050 ANE and AVE hand-offs pass on this head.

Hardware (J616s, firmware 26.7.1; this head as Stage 2 from the ESP, tag 1.0.0b10-ga1db45bc; kernel = linux#1477 head):

Test Result
Cold boot Desktop with the internal panel and two external displays, 14 CPUs, NVMe, Wi-Fi, Bluetooth, camera, ANE. The firmware hand-offs in the tree handed to Linux (memory regions of ANE, AOP, the three display processors, ISP and SEP, 31 reserved-memory nodes) are the same as with this series on the previous main.
Suspend-to-RAM (RTC wake after 20 to 45 s) 3 of 3, two before the hibernation and one after it: 14 CPUs, the same compositor process, all three displays, NVMe, USB, Wi-Fi and Bluetooth after each.
Hibernation with hib=1, reboot into the resume Image restored, same desktop session, three displays. A suspend-to-RAM after it passed.

.init is the full slot: since 2893294 it holds kboot.o's text next to the
guest-only hypervisor objects, and on main it has 756 bytes left in a
Stage 1 or ESP Stage 2 build with the gcc of the build workflow (13.3.0).
The T6040 hibernation layout and sleep hand-offs that follow add 5384
bytes to kboot.o. With them .init passes its 128 KiB step, .text starts
64 KiB later and the raw image does not link: "Code and data reach the
DCP log buffer after stage 1!".

.text has room left: 27 KiB in those builds, 12 KiB when clang 23.1.4
links a RELEASE Stage 1 and 10 KiB with clang 22.1.8. Put hv_sprr.o back
there: 6792 bytes (7360 and 7444 with the two clangs) that only run
while aura hosts a guest, moved to .init by 569a39a when clang's .text
was full. hv_vm.o, moved by the same commit, and the three small
hypervisor objects stay in .init: hv_vm.o would free more of .init
(8708 bytes) but leave clang 22.1.8 with 904 bytes of .text.

Bytes left with the whole series, on 87c31c2:

                                       .init   .text
  gcc 13.3.0, Stage 1                   2164   20380
  gcc 13.3.0, ESP Stage 2               2164   22540
  gcc 13.3.0, RELEASE Stage 1           3040   20716
  clang 23.1.4, RELEASE Stage 1        11688    4556
  clang 23.1.4, RELEASE ESP Stage 2    11692    6752
  clang 22.1.8, RELEASE Stage 1        11528    1872
  clang 22.1.8, RELEASE ESP Stage 2    11532    4128

The clang builds have BUILTIN_LOGO=aurora, as the stage1-clang job.
_file_vital_end stays 19 KiB under the limit, as on main.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…2 for the component handoffs

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
tests/run-pmp-boot-data.sh compiles dt_set_pmp() against
tests/pmp_boot_data.c. The next commit walks the optional boot arguments
in that function with ARRAY_SIZE(), which the fixture does not define:
without it the test stops compiling (implicit declaration, then
-Werror=sign-compare).

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
dt_set_pmp() copies the PMP nub's properties as apple,tunable-<name>, but
the PMP driver takes the firmware's optional boot arguments from
apple,dram-channel-disable, apple,pmc-msg-disabled and
apple,soc-chip-variant, and patches 0 when one is missing. A J616s nub
carries dram-channel-disable = 0xffff0000, so its firmware was told that
every DRAM channel is populated. Pass each of the three that the ADT has,
as four bytes, next to the tunables.

The T6040 tree also gets 64K more room for its PMP values and firmware
handoffs, as T6030 and T6031 do.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
load_fdt() asks firmware_os_components() for the release whose
component firmware the OS iBoot loads, since the 18000.161.10 train
counts as 26.6.2 for the handoffs. The harness that runs payload_run()
on the host still declared os_firmware for the old comparison, so it no
longer compiled and every test in it errored. Give it the function
instead, answering 26.6.2 as os_firmware did.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
A hibernation image restores every saved page to the frame it came from,
so the boot that resumes it must give Linux the same RAM and keep the
same ranges from it. Under the padded Stage 1 they move: iBoot picks
where in a 32 MiB range it loads the boot object, and what it places
after it, Stage 1's heap with the staged Stage 2, and this stage's heap
with the device tree and the firmware buffers kboot reserves follow.

With the Stage 2 payload line hib=1 on T6040, kboot_prepare_dt() fixes
what aura places, once the window is known and before it allocates the
tree:

- The heap restarts at a fixed address, 288 MiB plus 2 MiB above the
  32 MiB aligned start of RAM. Every boot object the J616s has loaded,
  unpadded or padded, sat 32 to 64 MiB above that start, so the 146 MiB
  padded Stage 1 ends at most 210 MiB above it and leaves 78 MiB for
  what iBoot places after it and both stages' heaps. The rover layout
  had the heap 160 MiB above, for objects without the window: this is
  that plus the window. heapblock_raise_base() moves the next
  allocation up; earlier allocations stay where they are.
- Everything from the start of RAM to a fixed end 128 MiB above that is
  kept from Linux, but the CTXR exec window, which stays the OS's. The
  two reservations go first in the map, since U-Boot drops one that
  overlaps a range it already recorded.
- The device tree Linux is started with is copied, as the last step
  before the handoff, into the 2 MiB slot below the heap.
  /chosen/aura,hibernate-layout holds the start of RAM and the fixed
  end, /chosen/aura,hibernate-dt the slot.

The layout is refused, with the reason printed and nothing changed, on
other chips, with an invalid or too small RAM extent, when the window,
aura, the boot arguments, what iBoot and Stage 1 placed or the heap
reach the slot, and when the fixed range meets a CTXR or CTRR range, an
MCC carveout, or an ADT memory-map or carveout entry other than the RAM
itself (region 24) and the region iBoot loads the object in (region 45).
A heap that later comes within 8 MiB of the fixed end, or a tree larger
than the slot, takes the properties out again. Linux then refuses to
hibernate. Without hib=1 nothing changes.

The J616s /memory stays the boot arguments' RAM, as on main: it does not
move between boots, and U-Boot places itself at the top of its first
range.

Where iBoot loads the object, and with it the window and this image,
is not fixed here: hibernation also needs the object where it was on the
boot that wrote the image.

tests/python/test_t6040_hibernate_layout.py runs the whole block with
real libfdt on a modeled J616s: the same layout and slot for objects at
both ends of the 32 MiB range and where a J616s put the padded Stage 1,
the window left to Linux and never under the fixed range, the
reservations first in the map, the slot copy as the kernel accepts it,
the same tree, heap and handoff as before without hib=1 or when
refused, each refusal and each withdrawal. The payload harness checks
that hib=1 asks for the layout, that a swallowed hib= line counts as
lost, and that Stage 1 does not hand the line on.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
On a J616s with macOS 26.7.1 the OS iBoot (mBoot-18000.161.10.701.1) loads
the 26.6.2 coprocessor images, and the handoff is checked against that
release (firmware_os_components()). apple,firmware-compat still carried
the detected OS release, 26.7.0, so the kernel's display gate, whose
desktop IOMFB is written for the 26.6.2 firmware, refused the handoff and
the panel stayed on the boot framebuffer. Publish the components release
as compat; apple,firmware-version keeps the OS release.

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

Since the display handoff calls firmware_os_components(), the T6041 and
T8122 display hosts no longer linked. Give both hosts the train rule and
the fw_versions entries they use, and add the J616s case that boots
26.7.1 with an 18000.161.10 train iBoot: published version 26.7.0,
compat 26.6.2. The scenario fails without the previous commit.

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

The DCP driver checks apple,firmware-version as well and refused 26.7.0
("is not 26.5.2 or 26.6.2"). The firmware handed over is the 26.6.2
image the 18000.161.10 train iBoot loads, so publish that release in both
properties, as the earlier J616s loader did.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
iBoot loads the boot object somewhere else on every boot: its slide moves
the object in 16 KiB steps inside a 32 MiB range, and the window above
aura's slot moves with it. Two EL2 boots of one padded Stage 1 on a J616s
had the window at 0x10006a00000 and 0x10006e00000, and the kernel a loader
places in it with it.

The object's physical address stays congruent to its virtual one modulo
32 MiB, and tools/macho_boot_object.py links it at 0xfffffe0007004000, so
its base lies 0x1014000 to 0x3010000 above the 32 MiB aligned start of
RAM, and CTXR_D ends the object's own size above that base. The part of
CTXR_D every placement arms above aura's slot is then the same on every
boot of one object: 96 MiB at 0x10008200000 on a J616s with the
installer's padding, 128 MiB at the same address for one padded for
256 MiB.

ctxr_exec_request_fixed_window() asks for that window before the window is
first looked up. It goes through the checks the window above aura's slot
does, and a boot it does not fit gets that window instead;
ctxr_exec_window_is_fixed() says which one the OS got. Where iBoot put
aura is logged with it. Without the request nothing changes: the checks
moved into ctxr_exec_window_unusable() unchanged, and the window, the
refusals and the log come out as before.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
A hibernation image is restored to the frames it was saved from, and the
restored kernel's secondaries execute only inside CTXR_D, so the kernel
has to be at the same address on the boot that resumes. With hib=1 on a
T6040, ask ctxr_exec.c for the window every placement of the boot object
arms, and refuse the layout on a boot that did not get it.

Move the device tree slot from 288 to 320 MiB above the 32 MiB aligned
start of RAM. The object lies 16 to 48 MiB above that, not 32 to 64 MiB:
28 placements seen on the J616s were all in that range, two at its
lowest. On the EL2 boots this stage's heap was 241 MiB above the object
when the tree was allocated, so up to 289 MiB above the start for the
highest object, past the old slot; the new one leaves 31 MiB.

aura's own image still moves with the object, inside the kept range:
Linux uses the spin-table release addresses only when it starts, and a
restored kernel reads this boot's S2R mailbox from the tree in the slot.

The new host test runs the real window code and the hibernation block on
every 16 KiB placement in the range, with CTXR_D, boot_args and the heap
where the two EL2 boots had them: one window, one layout and the same
tree on all 1987, the two EL2 boots' windows and log lines as aura logged
them without hib=1, and the boots past the range that the window no
longer fits refused.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
On T6040 the ANS NVMe storage link rides the internal PCIe host's shared
PHY block (power domain APCIE_PHY_SW), which a real system sleep lowers
and raises through the sleep controller. The t6040-sleep driver, following
aurora #1208's single-lane t8140 path, reaches that block through an
apple,apcie phandle and consumes, by reg-name, the axi2af/cio3pll/clkgen/
phy-block/rc/phy-ip windows plus the apple,tunable-* arrays the loader is
expected to publish. Our DT ships the host with config/rc/ports/phys only.

Add dt_set_t6040_sleep_apcie(): from the live ADT /arm-io/apcie0 it appends
the five shared windows (axi2af, cio3pll, clkgen, phy-block, phy-ip) to the
PCIe host node and publishes the six tunables (apple,tunable-axi2af,
-cio3pll, -clkgen, -phy, -phy-ip-pll, -phy-ip-auspma) from the matching
apcie-*-tunables ADT properties, then points the sleep controller at the
host with apple,apcie. rc already exists on the host node.

Validate-first and refusal-safe: every window is checked for presence and
exact size and every tunable for the kernel's own bounds before any DT
write; on anything missing or malformed, publish nothing and leave
apple,apcie unset, so the driver keeps s2idle the default and refuses a
real sleep with ANS stopped rather than driving a bogus block.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The in-tree apple-dcp driver lowers and raises the internal panel's
display power domains itself across a suspend-to-RAM that loses power
(U5), reaching them through an apple,display-power phandle on the DCP
node (dcp_t6041_display_power()). It consumes two windows by reg-name:

  ps       the SOC-East display power-state block (/arm-io/pmgr reg[2],
           0x502280000): DISP_SYS +0x258, DISP_FE +0x368, DISP_CPU
           +0x10000 (pmgr_disp).
  pmc-dcp  the shared PMS DCP-power voter (/arm-io/disp0 reg[4] +
           0xa9c14 = 0x5048a9c14), as the macOS entry trace recorded.

Our static T6040 DT ships no such node, so build it from the ADT and
point the internal DCP (apple,t6041-dcp, dcp@402e00000, the eDP panel)
at it, mirroring the apcie publish and aurora #1208's t8140 dcp_power
node. The two dcpext controllers use the west SOC-PS block and are
deferred. Refusal-safe: on any missing or unexpected window, publish
nothing and leave apple,display-power unset, so the driver returns
-ENODEV and skips the S2R display path rather than driving a bogus
block.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The two external display coprocessors (HDMI dcp@3a2e00000 -> DISPEXT0,
USB-C DP dcp@602e00000 -> DISPEXT1) need the same apple,display-power
handoff as the internal panel so apple-dcp can lower and raise their
display power domains across a suspend-to-RAM that loses power.

Their power-state words live in the west SOC-PS block (/arm-io/pmgr
reg[0] = 0x502800000), not the internal panel's SOC-East one: DISPEXT0
SYS/FE/CPU at +0x340/0x348/0x350, DISPEXT1 at +0x490/0x498/0x4a0 (ADT
/arm-io/pmgr power-state devices, group 0; = t6040-pmgr.dtsi
ps_dispext{0,1}_*). They share the internal panel's pmc-dcp voter
(disp0 reg[4] + 0xa9c14 = 0x5048a9c14).

Publish one display-power node over the SOC-PS block plus the shared
voter and point both external DCPs at it, mirroring how t8140 shares a
single dcp_power node; the driver picks each DISPEXT's own offsets by
the coprocessor's reg base. Windows are read from the ADT and validated
before any DT write; on any mismatch nothing is published and the
external outputs stay off across the sleep, which is left unaffected.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The boot core back from a sleep wrote one line to the DockChannel before
it jumped to the OS, and dockchannel_uart_putbyte() waits up to 1 s per
byte for room in the FIFO. A T6040's OS keeps the DockChannel off, so
nothing drains the FIFO aura's boot filled: the wake sat there for tens
of seconds, its OS's resume stub never ran, and the SMC's AP watchdog
reset the SoC about a minute after the sleep. With aura before this
line the same kernel woke every time.

Write the line only if the whole of it fits, without waiting.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
@fbalazsy fbalazsy changed the title J616s at EL2: hib=1 fixed layout, T6040 S2R windows and the 26.7 display handoff J616s at EL2: hib=1 fixed layout, T6040 S2R windows, the 26.7 display handoff and the S2R wake path Nov 11, 2026

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

Reviewed and tested on current main (v1.0.0b11, eca16db). The branch merges with no conflicts. The Stage 2 release build (clang, CHAINLOADING=1 ESP_STAGE2=1 RELEASE=1) links.

What I checked in the code:

  • hib=1 changes nothing when it is unset. kboot_decide_hibernate_layout() returns at once, dt_reserve_hibernate_layout() adds no reservation, and kboot_hibernate_handoff_dt() hands over the same dt. On chips other than T6040 the fixed window is never requested.
  • The three S2R publishers stand down unless their target is there. apcie needs an apple,t6040-sleep node and an apcie,t6040/t6041 ADT host. display and dcpext need t6041-dcp/t6041-dcpext and the exact T6040 pmgr window base, and anything else is skipped with a log line. They publish nothing until every window has validated.
  • firmware_os_components() only remaps the mBoot-18000.161.10. train. Everything else gets os_firmware.version back unchanged.
  • dockchannel_uart_try_puts() writes only when the whole line fits in DATA_TX_FREE. Of the callers, only the S2R wake path changes.
  • The PMP boot arguments are copied only when the ADT has them, as exact u32 values.

Hardware: the Stage 2 was this branch merged into main (1.0.0b11-g34e965d6). Only the aura head was swapped into each Mac's committed image, via aura-try, and nothing was committed. Each row compares against that Mac's production boot on the same kernel:

Mac Boot Result
J616s (T6040, iBoot mBoot-18000.161.10) Enforcing, 0 failed units, 0 AVC, 0 kernel errors, 0 DART faults eDP + DP up. USB 4 buses / 8 devices and the DCP error count match production. 38 reserved-memory nodes, 229.92 MiB, identical to production. apple,display-power is on all three DCP nodes, and DCP firmware-version reads 26.6.2. s2idle 3/3 on the PMU RTC, with Wi-Fi back after each.
J316s (M1 Pro) Enforcing, 0 failed, 0 AVC, 0 kernel errors, 0 DART faults NVMe and Wi-Fi up. 31 reserved-memory nodes, 200.41 MiB, identical. s2idle 3/3.
J700 (A18 Pro, fleet64 tree) Enforcing, 0 failed, 0 AVC, 0 DART faults eDP + DP up, USB 2 buses / 37 devices as on production. 38 reserved-memory nodes, 189.89 MiB, identical. The new apple,dram-channel-disable reaches the PMP node with no change in the rows. s2idle 3/3. One phy-apple-atc pipehandler line, which shows up intermittently on production too.
J413 (M2) Enforcing, 0 failed, 0 AVC, 0 kernel errors, 0 DART faults eDP, NVMe and Wi-Fi up. 29 reserved-memory nodes, 137.16 MiB, and iomem identical. Its ADT carries none of the three PMP arguments, so nothing new is published. s2idle 3/3.

hib=1 and the S2R windows need linux#1477 to be exercised, so those were not tested here. Each Mac went back to its committed Stage 2 afterwards.

@RyanTheTide
RyanTheTide merged commit 9887a6b into aurora-silicon:main Nov 12, 2026
9 checks passed
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