Skip to content

Bring the M5 Pro Linux boot and shared ANS handoff to main - #144

Merged
DjDeveloperr merged 56 commits into
mainfrom
m5pro/t6050
Nov 10, 2026
Merged

DjDeveloperr merged 56 commits into
mainfrom
m5pro/t6050

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Merged into public main as 014a758bc1400ba772f5512749d9843a6cf00895 after 10/10 CI checks passed.

T6050 Linux receives the firmware-owned platform state needed to boot the internal SSD and use the M5 Pro display, GPU, cameras, USB-C and N1. The series includes the shared ANS idle/power-off/warm-start path.

This branch merges public main at the frozen base 9befaa04e8b9f668199a9bb242af930d53cbdcb4, preserving the published M5 commit IDs and original authorship. Final merged head: 87efd06bf9142965133706920c3ee2555e224b28; source tree: 3d99c51dec6cea97092ec6c9afc40bd8adfb3d2f. The two descendants of hardware-tested c838e966 only complete the USB fixture's T6050 constant and mark its existing unobserved counter unused; all tracked files outside tests/ are byte-identical to that tested head.

The integration preserves main's PMP, J604/J715 radio/DAPF, Stage 1 watchdog, trial-boot recovery and distinct Stage 1/ESP CI artifacts. NVMe retains both the M5 ANS lifecycle and main's timed-write/failed-I/O recovery. USB retains main's generalized EP0 status sequencing and HS reset recovery, with T6050 included alongside T8122 in the bounded console flush. Existing fixtures retain their assertions, sanitizers and compiler flags with API/source-fragment compatibility updates.

The M5 changes cover DCP/DCPEXT firmware reservations, ATC tuning, GPU platform/leakage data, camera handoff, CTXR/S2R mailbox, board-discovered PCIe GP ports and bus numbering, split NVMe/SSD boot, shared RTKit/SART/PMGR/ASC storage lifecycle, SMP/USB/SMC and early-fault watchdog handling. T6041 Max's display entry is preserved alongside T6050. Jeff Queisser/Erik Bourget authorship and SPDX licensing remain intact.

The macOS ESP/window/MTE loader and SPTM/NV2 work remain separate in #70. This Linux boot series does not depend on merging or building #70, which remains open and unmerged.

Validation (hardware/build head c838e966, followed by fixture-only descendants):

  • Clang default, Stage 1 and ESP Stage 2 builds pass. ESP uses USE_CLANG=1 BUILDSTD=1 CHAINLOADING=1 ESP_STAGE2=1 DEBUGUSB_PROXY=1, with experimental SPTM/HV/XNU flags unset. ELF-to-BIN reproduction, built-in Aurora logos and the existing buffer assertions pass. ESP vital end is 0x11af80, below the unchanged 0x120000 limit; the 128 MiB window semantics remain unchanged.

  • ESP aura.bin: 4,063,232 bytes; SHA-256 b05304c6d41dc51aabec673fed09ecc2d2f3e40f94fb9b15b9d31f0777a55dbc. Paired raw ELF SHA-256: 12a25557cb692a95239a0be8142363f703d13b80f2b11c212a6470ad02efb2be.

  • Production C/header/include formatting, Python AST parsing and whitespace checks pass. Bounded GCC/Clang fixture syntax checks pass. No local host runtime suite or benchmark was run. All 10 configured remote CI checks passed on 87efd06b.

  • All added lines and commit messages across the retained history, including the merge, were scanned for private paths, machine details and credential patterns: zero findings. No proprietary firmware, captured device state or binary source addition is included.

  • Exact c838e966 M5 SSD Linux gate: PASS. Current production files are byte-identical. The console identifies gc838e966; ANS powers off retaining its SART entries, warm-starts from off, then hands its live controller/RTKit session to Linux. A fresh boot of the known SSD kernel/root, all 18 CPUs, system state running, DRM nodes and a 64 MiB direct read passed. The installed default was restored with current/previous sets, boot variables and every composed Stage 2 hash identical to slot start. No ESP installation or boot-set rotation was performed.

  • During setup, before the candidate ran, one reboot of the installed baseline stopped at its PCIe storage-state guard; a clean retry restored the baseline. Setup failures are retained separately and are not credited as candidate results.

Other-chip physical qualification, default installation of the candidate and a final-source early-fault injection gate are not claimed. No macOS/HV boot, sleep/wake, GPU performance or forced-fault test was needed or run for this integration. #70 remains unchanged and unmerged.

funkzy and others added 30 commits November 2, 2026 04:11
…d DART

Linux probes every enabled DART, and the DART of a port that did not come
up takes an SError at probe (J775D's port 3, booted through an Aura
without its training: Linux panicked 0.03 s in). The port table already
knows which optional ports are left down, so kboot marks each one's
pci@<n>,0 node and the DART its secondary bus maps to (the host's
iommu-map) disabled before the handoff, and refuses the handoff if it
cannot.

Tested on J775D: with both ports up nothing changes (Linux adopts ports
2 and 3); with port 3 forced down (a wrong expected endpoint ID), Linux
adopts port 2 alone and boots through, with no SError.

Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

(cherry picked from commit e7f2008ddce6ace50dc2f9d9f430aeb3d2b701e8)

Signed-off-by: Diljit Singh <hey@djdev.me>
…and 3

Port 0 is the built-in N1 (106b:1900 in its ROM personality, 1901 once
its firmware runs). It is optional and last in the table: the SMC holds
the N1 in reset (pci-bridge0 function-reset, SMC key gP13), so a port
whose bridge names an SMC function-reset has it released before its
link sequence; B-G are then the same as for ports 2 and 3. Linux finds
it at 03:00.

With a third port, three paths that assumed a fixed, all-described set
are generalized:
- stage A drops an optional port whose PERST# is not output-low instead
  of stopping the shared init (and so the required port 2);
- stage G checks every function present, not only function 0;
- the DT edit skips a down port the tree does not describe (no root
  port and no iommu-map entry): nothing of it is Linux's to probe.
The any-port-down check also skips a port whose resources were not
found, instead of reading its unmapped control block.

Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d28dedf2e75af5af5491fbe2453bda3d72029995)

Signed-off-by: Diljit Singh <hey@djdev.me>
A port Linux resets and retrains itself (the N1's port 0, after its
ROM boot) needs the same port config, root port and Gen3/4/5 shadow
tunables this bring-up applied. Copy them from the ADT bridge onto the
port's pci@<n>,0 node as apple,<name>, in (offset, 4, mask, value)
cells, for every port that is up and described. A record that is not
32 bits refuses the handoff rather than handing over half a list.

Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 33af8bff63bdb7630c5427f680ec9afd9c43e672)

Signed-off-by: Diljit Singh <hey@djdev.me>
… that matches

Linux's PCI core renumbers every root port's secondary bus itself: 1, 2,
... in devfn order over the root ports that answer config space. The
fixed numbers in the port table matched that only while the ports that
came up were 2 and then 3; with port 0 up, Linux gave the N1 bus 1 and
the RTL8127A bus 2, the tree still mapped bus 1 to port 2's DART, and
the Ethernet's enable was refused.

So bus numbers are no longer in the table. Stage F numbers a port as it
trains (an adopted port keeps its own), and once every port has been
tried the up ports are renumbered in Linux's order. The handoff reads
each root port node's bus from its bus-range and makes the tree match:
an up port's bus-range, its functions' reg and its iommu-map entry move
to the bus it has, and its root port node and DART are enabled (a tree
may now ship an optional port disabled); a down port's are disabled and
its iommu-map entry dropped. Nodes are looked up again after each edit,
since one that resizes a property moves the nodes after it.

Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 859595d6c42f5777233373442afacf01da72ce72)

Signed-off-by: Diljit Singh <hey@djdev.me>
The GP bring-up is measured on J775D, whose apcie0 has its required
port 2 (RTL8127A). J716c's apcie0 has bridges for ports 0 and 1 only,
so the bring-up stopped and took storage down with it. Skip it there.

Developed with Claude Code.

Signed-off-by: Erik Bourget <erik@ebourget.net>
(cherry picked from commit 67b111e66a9a40702f8104dfaef3b686405a921e)

Signed-off-by: Diljit Singh <hey@djdev.me>
J716c's apcie0 has bridges for ports 0 (the N1) and 1 only. A port
without a bridge in the ADT is not on the board: it is neither required
nor tried, and the bring-up runs for the ports that are there. With
none of them present, the GP side stays as found.

Developed with Claude Code.

Signed-off-by: Erik Bourget <erik@ebourget.net>
(cherry picked from commit 59c2d169e9d184f507e34858a0a26bd8be506656)

Signed-off-by: Diljit Singh <hey@djdev.me>
A PCIe bridge's function-reset in the ADT names an SMC key write
(pKW4: four bytes of lo | level; pKW8: eight bytes of (hi << 32) | lo |
level). J873's N1 power decoded its pKW8 by hand; T6050's N1 has the
same reset as a pKW4. smc_adt_function_reset() decodes both and writes
level 0, then 1, and J873 uses it with its 10 ms settle unchanged.

Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 37c0da7dcf1435f7c3075729b722bd1d991318cf)

Signed-off-by: Diljit Singh <hey@djdev.me>
pmgr_adt_power_disable_under(path, name) powers off, children first, the
gates of an ADT node that are the named device or depend on it, a
virtual gate standing for its parent. pcie_ans_power_off() stops the
shared PHY of the APCIe controller (/arm-io/apcie, else /arm-io/apcie0)
and powers off its gates under ANS. It reuses pcie_init_controller()'s
ADT parse. PHY control keeps its value through the power cycle, so the
PHY goes down whole, up bit included, as in the J700's measured power
cycle, and stays off at least as long (100 ms).

On the Neo's live ADT that is APCIE_PHY_SW, APCIE_SYS_ST, APCIE_ST and
ANS, the order the J700 measured. APCIE_GP and APCIE_SYS_GP, which don't
come back without a real sleep, stay on. The ADT dumps of J713, J604 and
J773g (T8132) give the same four, and J773s (T6040) and J616c (T6041)
give APCIE_PHY_SW, APCIE_SYS_ST0, APCIE_SYS_ST1 and ANS under apcie0.
test_ans_gates_adt.py runs the real code on each dump in AURA_ADT_DUMPS.

pcie_init_controller() brings a T8140 PHY up whole when it finds it off
(RUN_EN2 clear): the PHY-IP PLL and lane tables, the PLL hold cleared,
RUN_EN2, PHY ready and the PHY up, as on T8122. A PHY that ANS runs on is
left as before.

(cherry picked from commit 70f4c72)

Signed-off-by: Diljit Singh <hey@djdev.me>
Each aura stage handed the next its live ANS session to adopt. Now a
stage works with post-M4 ANS as with M1-M3: the stage that started ANS
shuts it down after use, and every later stage that needs it starts it
again.

nvme_shutdown() shuts the controller down as macOS does before a sleep,
keeps the SART entries in use, idles the firmware and powers ANS and its
PCIe block off (pcie_ans_power_off()). The firmware keeps the buffers it
was given, so those stay allocated and reserved.

A later stage that needs NVMe brings ANS back with the existing
pcie_init(), writes the SART entries back and starts the firmware as
after a power loss. The entries travel as nvme.sart= to a chained aura
stage, and kboot writes them to the DT's ANS node as apple,sart-entries
for a payload: per entry (index << 8 | flags), address and size, 64 bits
each. A stage that doesn't use NVMe leaves ANS as it got it.

A stage that used NVMe and boots a payload other than Linux powers ANS
off before kboot's pcie_init(), which then brings the PCIe block, ANS's
power and the radio's link up again. The payload finds ANS powered with
its CPU stopped, and only writes the SART entries back and starts it.

nvme_init() on a post-M4 ANS:
- iBoot's running session gets its one-time RTKit handshake, as before.
- Off with entries passed on: power on, then the start above.
- Off without entries: refused with a message.
- Running with an earlier aura stage's queue setup (an older aura that
  still handed its session on): powered off, then started as above.

Gone: nvme.adopt and nvme_adopt_live_session, the T8132 AP quiesce, the
T8132 chip check in nvme_init(), and Stage 2's nvme_init() before an
inline payload. Linux still adopts a running ANS, so boot= leaves it
running for Linux, as before. kboot reserves the SART ranges and the
retained heap on every post-M4 ANS (nvme_post_m4()), not on a list of
chips. M1-M3 don't change. T8152, with its secure register layout, keeps
its session running as before, and now has its SART ranges reserved too.

(cherry picked from commit 7556201)

Signed-off-by: Diljit Singh <hey@djdev.me>
nvme_ans_power_off() idled the firmware with the controller still
enabled, after a sleep shutdown (CC.SHN 3) of a queue set whose I/O
queues had just been deleted, and the queue memory was freed after the
power-off. The next start from off, in U-Boot, got a restarted firmware
(both mailbox controls at their reset value) that reported IOP power on,
then said HELLO and never sent its endpoint map, so the start failed
with -110 (ANS-chain-kit-05 to -08 on the J700).

The same stage's first power-off, of a session the earlier stage had
left with its controller disabled, was followed by a clean start every
time. Disable the controller first, as M1-M3 do and as earlier stages
hand it over, with a normal shutdown only when this stage wrote.
Nothing else asks for CC.SHN 3, so nvme_ctrl_shutdown() goes back to the
normal shutdown alone.

(cherry picked from commit 7b3ba79)

Signed-off-by: Diljit Singh <hey@djdev.me>
When an earlier owner powered ANS off and passed its SART entries on,
nvme_init() still read ANS's CPU control, its NVMe and NVMMU registers
and, in sart_init(), all sixteen SART entries before
nvme_ans_power_on() brought the power back. That happens in a chained
stage that reads NVMe again (boot=), in Stage 1 after its proxy-request
window, and in any stage that starts ANS a second time. Bring ANS's
PCIe block up first; pcie_init() does nothing more when
nvme_ans_power_on() calls it again.

No row has read a powered-off ANS yet. The order is the one every
other driver keeps: power, then registers.

(cherry picked from commit ae1da31)

Signed-off-by: Diljit Singh <hey@djdev.me>
Validate the ADT and retired gadget before taking the selected USB2 PIPE. Apply device tunables and the T6050 dummy clock, initialize DART and DWC3, then route HPM0 after the scheduler reply. Preserve KIS retake and bound stale CDC console flushing. Based on public Aurora Linux c24e75ca USB2/PIPE code. On J714s, CDC enumerated at480Mb/s; two8MiB raw roundtrips matched at26MiB/s uploads, the full macOS guest loaded in8.7s, KIS retake and kernel entry passed.

Assisted-by: OpenAI Codex (gpt-6.1-sol)
Signed-off-by: DjDeveloperr <hey@djdev.me>

Signed-off-by: Diljit Singh <hey@djdev.me>
T6050 (J714s) has nine, i2c0-i2c8, so kboot_prepare_dt bailed with "too
many /arm-io/i2c devices" before booting Linux.

Signed-off-by: Diljit Singh <hey@djdev.me>
iBoot leaves dcp and dcpext0..3 running on T6050, and each one's __OS_LOG
buffer lies in the RAM handed to the OS (J714sAP, 27.0: five 0x27000-byte
buffers at 0x1000f39c000..0x1000f463000). Linux reused those pages while
the coprocessors kept writing them. dt_set_display() reached "unknown
compatible" for T6050 and reserved nothing.

Route T6050 to the display handoff and reserve every running nub's
__OS_LOG there on every boot, through the existing transactional
reservation and its /memreserve/, reserved-memory and carveout checks.
Print one summary line so the reservation is visible on a release console.

Signed-off-by: Diljit Singh <hey@djdev.me>
libfdt matches a path component without a unit address against the first
node of that base name. The T6050 trees have /soc@200000000 before /soc,
so the dcp alias "/soc/dcp@48ae00000" resolved "soc" to /soc@200000000,
found no dcp there, and dt_set_fb() left apple,notch-height out without a
word: the DCP would drive the notch rows the boot framebuffer had hidden.
Linux matches full names and resolves the same alias.

Add kboot_fdt_path_exact(), which matches every component by its full name,
and fall back to it in dt_set_fb() when libfdt finds nothing, so trees that
resolve today keep their behaviour.

Signed-off-by: Diljit Singh <hey@djdev.me>
Linux's apple,t6050-dcp adopts the DCP session iBoot leaves running, but
probe returned -ENODEV without apple,firmware-compat <27 0 0>, and bind
also needs apple,bw-scratch, apple,clock-ids with clocks, and a
"framebuffer" memory-region. aura published none of them on T6050.

When the device tree describes the internal display (aliases dcp and disp0,
the dcp, its mailbox, both DARTs and the display subsystem all disabled),
take every value from the ADT and check it before writing anything:

- OS firmware 27.0 and the DCP image UUID the kernel's interface matches;
  the nub running an internal panel
- dcp coproc, iop-vbar and disp-0..4, the mailbox at coproc + 0x8000, and
  iommus dart-dcp 23 and dart-disp0 0/16 with the ADT DVA window
- /vram is region-id-14 and a DCP segment, holds the boot framebuffer and
  lies outside the OS's RAM, as does every DCP segment but __OS_LOG
- with the display powered, the ASC runs and the three streams translate,
  locked, through the ADT's four-level roots

Then publish, as one transaction: firmware-version/-compat/-uuid; a
pmc-metadata node (disp0 reg[4]) and apple,bw-scratch at the PMGR
bandwidth agent disp0's interrupt names (0x20000 + 0x4000 * agent);
fixed clocks for disp0's clock-ids from /arm-io clock-frequencies; /vram as
the dcp's and the display's framebuffer region; the panel's
apple,max-brightness from user-accessible-max-nits; the artwork gamut; and
enable the five nodes. No iommu-addresses: the kernel resolves firmware
DVAs through the live four-level tables and reserves their slots itself.

On any failure the nodes stay disabled and the boot framebuffer keeps the
panel. /chosen/asahi,t6050-dcp-handoff says "published" or "refused". A
panel child must come from the device tree (the OS reads its dimensions
from the ADT).

Every node is found with kboot_fdt_path_exact(): with libfdt's lookup,
"/soc/..." lands in /soc@200000000 on these trees.

The code runs once per boot and is built for size. The ADT and device tree
checks go into .init's free room, the rest into .text, which keeps the
image under the DCP log limit: with CHAINLOADING=1 SPTM_VIRT=1, 1400 bytes
of .text and 780 of .init remain.

J714sAP, 27.0 ADT: bw-scratch 0x286700000 + 0x20000 (agent 0, BIRQ 0x96),
clocks 361 = 810 MHz and 458 = 402.28 MHz, 1000 nits, gamut P3.

Signed-off-by: Diljit Singh <hey@djdev.me>
The T6050 combo PHY driver takes 14 tunable lists, each applied to one
register bank: 11 at probe, then the USB2 and PIPE handler lists. aura
produced none, so the probe stopped at apple,tunable-axi2af and dwc3
waited on it.

Copy each list from the ADT list the driver's sequences name for that
bank (atc-phyN, and usb-drdN for the PIPE handler). First check that the
ADT reg the list belongs to is the bank the driver maps from the DT, and
that usb-drdN is atc-phyN's controller. A port gets every list or none.
Port 0, aura's debug link, is never touched.

Signed-off-by: Diljit Singh <hey@djdev.me>
Every T6050 boot printed "ADT: GPU: unsupported chip!", so the Linux
device tree never got the GPU's reservations, and the GPU, its PMGR
states and mailboxes stayed disabled. Linux's driver now runs the M5
Pro (G17S) on bare metal from four UAT reservations, fw-text and
fw-data.

When the device tree describes the GPU (alias "gpu", apple,agx-g17s,
disabled), take every value from the ADT and check it first:

- /arm-io/sgx gpu-region, gfx-shared-region, gfx-shared-l2-region and
  gfx-handoff: present, non-zero and 16 KiB aligned
- fw-text from gfx-asc's __TEXT, 0xa4000 for both roles back to back;
  fw-data from gfx-data-base, which must be gfx-asc's __DATA, to the end
  of gfx1-data-shared-ro, which must be 0x184000 on
- fw-text is the 26A428 G17S build Linux admits: the SHA-256 of its TEXT
  with the boot-filled ranges zeroed (the entropy records among them),
  the digest of Linux's hw/t6050.rs CONFIG
- every node it enables exists: the GPU PMGR at 0x2300e80000 with GPX,
  AFR and GFX, the mailboxes at 0x2302600000 and 0x2302e00000, the GPU

Then fill the six no-map reservations and enable those nodes, parents
first and the GPU last. On any mismatch nothing is enabled and the
boot framebuffer and DCP handoff are as before; the log says which check
refused.

Built for size, since .init and .text had 440 and 504 bytes left: the
ADT and firmware checks are one .text function, the device tree part
is in .init, and T6050 reaches it through dt_set_gpu()'s default case,
which keeps the unsupported-chip message for other chips. There is no
room for apple,firmware-version, which Linux takes only as a hint for
this GPU.

J714sAP, 27.0 ADT: ttbs 0x10ffffa8000, pagetables 0x10ffff28000+0x80000,
l2 0x10ffff24000, handoff 0x10ffff20000, fw-text 0x10000fd4000,
fw-data 0x100024f4000.

Signed-off-by: Diljit Singh <hey@djdev.me>
The SPTM-virt image had 36 bytes left in .init and 8 in .text. One more
64 KiB step of code moves .data past the DCP log-buffer limit, so the
two sections' total can't grow at all.

Build sptm_virt_cl4.c at -Oz: its cL4 register switches, one SAFE_MRS or
SAFE_MSR per case, are 5 KiB smaller (8528 to 3520 bytes). Then move
three more objects that only run while aura hosts a guest, hv_virtio,
hv_vuart and hv_wdt (3856 bytes), from .text into .init next to hv_vm
and hv_sprr. A Linux boot runs none of this code.

.init now has 1188 bytes left and .text 3864; the section layout and
.data are unchanged.

Signed-off-by: Diljit Singh <hey@djdev.me>
An OS that aura starts at EL2 has no monitor below it, so it powers cores
off and suspends the system itself. From M4 on, the A18 Pro included,
iBoot locks every core's reset vector to the boot object, so a wake
restarts each core in aura, and the boot core would rerun the boot flow
over the live OS.

When the OS runs at EL2 and a running secondary's locked RVBAR reaches
this image (the address smp_prepare_rvbar() accepted before starting
it), publish /chosen/aurora,s2r-mailbox. On a reset with it published,
the boot core takes the resume address the OS left there, or reboots if
it left none. A secondary needs nothing new: its spin table entry still
holds the OS's release address. Reset paths stop printing once the
mailbox is out, since the OS owns the UART and the display.

The CPUs keep spin-table, which every kernel knows. The property is the
whole contract: a kernel that reads it may power its spin-table CPUs off,
and one that doesn't ignores it. Whether to deep-sleep stays the OS's
choice. Nothing here is chip-specific beyond the locked RVBAR. On A7 to
M3 it isn't locked and nothing is published, and a guest at EL1 gets
nothing.

The mailbox is 32 bytes in aura's .data, inside the image kboot already
reserves, so nothing new is reserved.

Linux reads it in arch/arm64/kernel/cpu_ops.c and
drivers/soc/apple/t8140-sleep.c. The return path is the one every Linux
deep sleep on the Neo since 2026-11-06 ran on, from a Stage 2 built on
1.0.0b5 that set the CPUs' enable method instead.

Signed-off-by: Diljit Singh <hey@djdev.me>
The mailbox went out only when a running secondary's locked RVBAR
reached this image. An OS started without secondaries, as the M5 Pro
Linux kit boots unless asked for SMP, suspends with the boot core alone
and got no mailbox, so its first sleep could only reboot.

With no secondary running, check the boot core's own RVBAR the same way,
after smp_prepare_rvbar() has installed or confirmed the relay at the
locked address, as smp_start_secondaries() does for the boot core.
T8142 and T8152 keep their own reset vector code and still need a
running secondary.

Signed-off-by: Diljit Singh <hey@djdev.me>
T6050 has three clusters of six cores, and cpu_start_bit() packed them
four to a cluster. Cluster 1 core 0 got bit 4, cluster 0 core 4's, and
no core ever got bits 14 to 17. XNU's own stop requests at CPU-start
+0x0 on the M5 Pro are 0x2 for cpu1 through 0x20000 for cpu17, one bit
per core in cpu-id order, and the ADT's cpu reg is cluster << 8 | core.

The +0x4 bit is the one that enables a core's IRQs, and +0x0 is the
stop request smp_stop_cpu() and an OS's sleep use.

Signed-off-by: Diljit Singh <hey@djdev.me>
Once the mailbox is out, the boot core's reset path prints nothing, so a
first sleep that doesn't come back can't tell a wake that never came
from one that reached aura. Write one line on the DockChannel, which
stays powered through the sleep, before jumping to the OS or rebooting.
It goes to the DockChannel directly, not through iodev, since USB and
the display belong to the OS by then.

Signed-off-by: Diljit Singh <hey@djdev.me>
With no secondary running there was nothing to probe, so the OS ran
outside CTXR_D on the boot core. The M5 Pro's first Linux suspend to RAM
went down at the commit and never came back to Linux: the machine
rebooted through iBoot with DRAM cleared. A wake resets the boot core,
which then leaves reset like a secondary, and an M5 Pro secondary is
confined at EL2 (the heap probe faults), so it reaches the relay in this
image and stalls at the kernel's resume entry outside the window.

When CTXR_D is armed and a window is usable, take every core leaving
reset as confined, so kboot puts the kernel in the window as it does with
SMP. Where CTXR_D is armed and the OS is outside a window, publish no
S2R mailbox: such an OS couldn't resume.

Signed-off-by: Diljit Singh <hey@djdev.me>
The T6050 kernel powers the ISP up and starts its firmware itself, so
aura only reserves the firmware iBoot preloaded. Publish the two ADT
segments (__TEXT and __DATA) as reserved memory with their DART
addresses, add a 32 MiB main-memory window, set the firmware version,
platform ID and camera connection scheme, and enable the ISP and its
three DARTs. Anything unexpected leaves the camera disabled.

Based on the J716c handoff (4c2b33e8, ewb/j716c-daily). The J714sAP
ADT has the same two segments at the same DART addresses; its sensor
type is 0x74 where J716c's is 0x75.

Signed-off-by: Diljit Singh <hey@djdev.me>
T6050 device trees have both a "soc" bus and "soc@200000000". libfdt
resolves the "soc" component of "/soc/isp@580000000" to the first node
of that base name, so the camera handoff never found the ISP. Look the
ISP and its DARTs up with kboot_fdt_path_exact(), as the display
handoff does.

Signed-off-by: Diljit Singh <hey@djdev.me>
The exact-path camera lookups pushed .text past its 64 KiB step. The
segment check and the memory-region helper run once per boot, so place
them in .init, which the SPTM-virt image keeps room in.

Signed-off-by: Diljit Singh <hey@djdev.me>
On T6050 the stages before Linux leave ANS SART entries that allow DMA
into RAM, and Linux keeps entries it did not create. Reserve every
SART-allowed RAM range in the FDT, as on T6041 and T8142. The M5 RAM-boot
kit did this from the host; an ESP boot has no host to do it.

Signed-off-by: Diljit Singh <hey@djdev.me>
A Stage 2 that reads its kernel from the ESP on T6050 stopped at
"nvme: invalid split BAR geometry": T6050 has T6041's layout, a 64 KiB
NVMe block with the linear submission queue in the NVMMU block. Select
that layout for T6050, and keep this stage's heap out of Linux's
allocator, since the live ANS handed on keeps its RTKit buffers there.

This is the NVMe and kboot part of 444bf267 (Jeff Queisser). Its apcie0
bring-up before storage is left out: the M5's Stage 1 drives storage
without one.

Signed-off-by: Diljit Singh <hey@djdev.me>
The M5's Stage 1 has no debugusb window but chains its Stage 2 with
nvme.adopt, which marks the boot as chained. The Stage 2 then skipped its
own window too, and once it was on the ESP a debug host had no way left to
take a proxy on a normal reset. aura.host-window=done is the signal that
an earlier stage offered a window: an ESP Stage 2 now goes by that alone.

Signed-off-by: Diljit Singh <hey@djdev.me>
What a post-M4 ANS needs to be powered off by the stage that used it and
started again by a later one:

- rtkit_idle() puts AP and IOP power in IDLE (0x201), as macOS does
  before a sleep, waits for the CPU to read stopped in its idle loop, and
  clears the run bit twice. rtkit_switch_power_state() takes the AP state
  as a parameter for it.
- rtkit_boot_warm() starts an IOP after a power cycle under kept firmware
  state. The firmware says HELLO by itself, the endpoint map is answered
  as macOS does after a wake, and no endpoint is started again. It is the
  existing boot with a flag. A crash log request on such a session is a
  crash, and rtkit_crashed() no longer reads a buffer it doesn't have.
- sart_get_entries() and sart_set_entries() read the entries in use and
  write them back, since the SART loses them with ANS's power.
- asc_cpu_idle() reads the stopped-and-idle CPU state.

Nothing calls them yet.

(cherry picked from commit 49da8f7)

Signed-off-by: Diljit Singh <hey@djdev.me>
With the T6050 PCIe bring-up, the camera and the external display
engine handoffs on top of the ESP Stage 2, .text grows 9.5 KiB past
its tenth 64 KiB step, and .data then reaches the DCP log buffer.
.init has no room to take the extra code.

kboot.c runs once, when aura hands the machine to an OS, and its T6050
helpers are already built minsize. At -Oz it is 15 KiB smaller.

.init now has 1016 bytes left and .text 5372.

Signed-off-by: Diljit Singh <hey@djdev.me>
…rents

The handoff left every external engine with iBoot as "not powered" (run cp4): dispextN
has no ADT clock-gates, so asking whether it was powered failed. Check the power words
dcpextN's gate resolves to instead, its virtual device's real parents with theirs (the
CPU, front end and system domains its DARTs sit in), each on or targeted on under
automatic power management: iBoot leaves the CPU at DISPEXTn_CPU 0x1404024f.

(cherry picked from commit 7d577ac72b2460a37f3f983bdfecab6e9496db60)

Signed-off-by: Diljit Singh <hey@djdev.me>
On T6050 ANS drives its own storage PHYs (AUS5, ANS's msp-phy-fw-path),
the APCIe PHY serves only the GP ports, and pcie_init() is the GP port
bring-up, so the T8140 path doesn't apply. Run 28 (macOS 26A428 under
SPTM-virt, two S2R cycles) gives the PMGR side:

- before the sleep macOS lowers APHY_ST0_AUS5, APHY_ST0_AUS5_A,
  APHY_ST1_AUS5 and APHY_ST1_AUS5_A, each in two steps (AUTO_ENABLE off
  with the domain on, then off); the SoC's sleep then takes ANS and the
  APCIE_SYS_ST0/1 gates that depend on it (J714s ADT);
- at the wake it raises ANS, APCIE_SYS_ST0, APCIE_SYS_ST1, then the
  storage PHYs, _A parents first, each with AUTO_ENABLE off until it
  reads on, then back on.

The power-off does the first list and then lowers APCIE_SYS_ST1, _ST0
and ANS the same way, for longer than the 21.5 ms S2R cycles after which
macOS restarted ANS. The power-on does the second list. PHY_SW and the
GP side stay up for the GP ports.

Signed-off-by: Diljit Singh <hey@djdev.me>
The installed Stage 1 passes its running ANS session with nvme.adopt.
nvme_init() now finds such a session by itself, but the line still says
an earlier aura stage ran, which the proxy windows go by.

Signed-off-by: Diljit Singh <hey@djdev.me>
From the trace lane's cp9d (macOS 26A428 under SPTM-virt on the M5 Pro,
COPROC hooks on ANS's CPU control, mailbox and wrapper pages, one real
sleep and wake):

- before the sleep: AP power IDLE 0x201, IOP power IDLE 0x201 (acked in
  17.7 ms), the mailbox's receive side turned off, IDLE_STATUS 0x6e, the
  run bit cleared twice;
- at the wake: the receive side turned on, the run bit set 70 ms after
  the storage PHYs are back; the firmware sends HELLO unasked, EPMAP is
  answered 0x51f then 0x1 with LAST, no endpoint is started again, and
  the firmware reports IOP on (0x20) by itself 282 ms later, then AP on.
  IORVBAR is never touched.

rtkit_idle() and the warm start already matched that apart from the
receive side; they now set it as macOS does. The T6050 power-on waits
the 70 ms before the run bit.

Signed-off-by: Diljit Singh <hey@djdev.me>
…OS does

Traced on the M5 Pro (J714sAP, macOS 26A428 under aura's hypervisor,
runs a3 and a5): before each sleep XNU reads CC 0x460001, writes CC
0x46c001 (SHN 11b with EN kept) and polls CSTS through 0x5 to 0x9
(SHST done) in 3.8 ms, then idles ANS with AP and IOP power 0x201. Do
the same on T6050 instead of disabling the controller, with the 35 ms
timeout XNU's console reports. Other post-M4 chips keep the disable.

Signed-off-by: Diljit Singh <hey@djdev.me>
Linux's G17S driver applies the J714 controller configuration only when
the GPU node's apple,leakage-calibration-words match the part it was
made for; without it the GPU ran about 4.9x slower. The words are this
part's fuses, so a board DT can't carry them. On J714s they are three
words at 0x74198 in the PMGR window that starts at 0x88300000 on the
GPU's die: the ADT's pmgr reg entry on the same die as sgx's reg[0]
(0x2388374198 on this unit, where the M5 lane's DT took them from).

Read them under the fault guard once the GPU is handed over, and set
the property on the gpu node.

Signed-off-by: Diljit Singh <hey@djdev.me>
Only wdt_disable() and the trial arming set wdt_base, so a stage that
faulted earlier in init (firmware_init, heapblock_init, mmu_init) printed
"rebooting..." and then spun in reboot: the M5 stayed on the logo after
run k6. wdt_reboot() now finds the watchdog in the ADT itself.

Signed-off-by: Diljit Singh <hey@djdev.me>
The DCPEXT handoff needs the clock-gate parent closure already used by public SPTM virtualization. Carry that existing public helper into the Linux series rather than depending on guest-only code.

Signed-off-by: Diljit Singh <hey@djdev.me>
This branch has no guest coroutine. Use the normal delay and register poll already used by the standalone ATC bring-up, keeping the same timeout and sequence.

Signed-off-by: Diljit Singh <hey@djdev.me>
The current public main plus the M5 Linux handoffs crosses the raw-image vital-data boundary. kboot preparation fits in the existing init alignment slot and moves text back one 64 KiB step. Keep both linker scripts in sync and preserve the DCP buffer assertion.

Signed-off-by: Diljit Singh <hey@djdev.me>
The SSD Linux validation hit the same CSTS.RDY timeout as the macOS ESP loader. Put the single recovery implementation in the shared storage series: suspend and idle the inherited session, retain its SART entries, then power-cycle and warm-start ANS once. The macOS series depends on this implementation.

Signed-off-by: Diljit Singh <hey@djdev.me>
Signed-off-by: Diljit Singh <hey@djdev.me>
The power-off series replaces live adoption with an owned warm start. Retry that existing session rather than creating a second RTKit owner. Retain the saved SART set and allow only one retry.

Signed-off-by: Diljit Singh <hey@djdev.me>
Signed-off-by: Diljit Singh <hey@djdev.me>
Keep the existing SoC scenarios, assertions and sanitizer coverage while updating stand-in declarations and fail-closed hardware boundaries. Extract only the T6041 GPU fill, include the PMGR lookup dependencies, and honor the CI host compiler environment.

Signed-off-by: Diljit Singh <hey@djdev.me>
Provide the boot-args prefix referenced by the unmodelled T6050 display source so the existing T8122 and T6041 fixtures link on both host compilers. Keep the out-of-scope T6050 helpers fail-closed. Account for the separate admission and warning reads in the no-secondary CTXR case without changing production code.

Signed-off-by: DjDeveloperr <hey@djdev.me>
The copied T6050 init attribute names an ELF section, which a Darwin host linker cannot accept. Translate only that section name in the macOS host fixture copies while retaining the function attributes, source, assertions and sanitizer checks. Production ELF source stays unchanged.

Signed-off-by: DjDeveloperr <hey@djdev.me>
Preserve the M5 ANS power lifecycle alongside main’s timed writes and failed-I/O recovery. Retain the generalized EP0 status sequencing and bounded T8122/T6050 console flush. Combine the existing chainload fixtures’ failure accounting and SART handoff assertions.

Signed-off-by: DjDeveloperr <hey@djdev.me>
Copy the timed write helper into the poisoned-I/O fixture and keep it outside the ANS lifetime fragment. Mark only the unobserved write-path flag unused in the host copy, retaining the assertions and warning flags.

Signed-off-by: Diljit Singh <hey@djdev.me>
Signed-off-by: DjDeveloperr <hey@djdev.me>
Signed-off-by: DjDeveloperr <hey@djdev.me>
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.

3 participants