Skip to content

pcie, kboot: T6050: optional N1 (Wi-Fi/Bluetooth) training and hand-off behind chosen.asahi,t6050-n1 (stacked on #33) - #34

Closed
rolotrealanis98 wants to merge 17 commits into
omacom:integration/aurorafrom
rolotrealanis98:omacom-t6050-n1
Closed

rolotrealanis98 wants to merge 17 commits into
omacom:integration/aurorafrom
rolotrealanis98:omacom-t6050-n1

Conversation

@rolotrealanis98

@rolotrealanis98 rolotrealanis98 commented Nov 7, 2026 •

Copy link
Copy Markdown

Base: PR-1 (omacom/t6050-bringup): #30 + the CI test fixes + the RVBAR relay. This PR adds five commits. Branch: omacom/t6050-n1.

This is optional. The training only runs when the payload sets chosen.asahi,t6050-n1. #30 does not train the N1: edimoldovan's J714c kernel trains the link itself, and we are testing that kernel-side training on the J716s now. If it works there, the DT fill-in (commit 1) is the only part a loader still needs to provide, and the training (commits 2-5) can wait or be dropped. I am posting the whole series because it is what brings the N1 up on the J716s today, including across restarts.

iBoot does not train apcie0 port 0 on the J716s (MacBook Pro 16-inch, M5 Pro, T6050), so Linux never sees the N1. Linux's pcie-apple adopts a root port only if the loader trained it, and the centauri driver needs the firmware name, platform ID and port tunables that only the ADT holds.

  1. kboot: n1: fill the T6050 N1 hand-off in the DT (new kboot_n1.c). For an apple,t6050-pcie host:

    • The N1 control function (pci106b,1900) gets firmware-name = "apple/centauri/<target-type>-ftab.bin", apple,centauri-platform-id (board-id << 16 | chip-id) and apple,centauri-protocol = <27>, if they are unset.
    • Each apple,link-trained-by-bootloader root port gets the ADT pci-bridge<n> config, rc and gen3/4/5 shadow tunables.
    • The root port and its DART are enabled only if the port meets the adoption's preconditions: the root complex is running, the port is ready, the link is up and not retraining, LTSSM is on, an Apple endpoint sits behind it, there is no RID route yet, the endpoint's command bits are clear, and the DART's protection and stream registers are still 0. Otherwise both stay disabled: the DART of a port that is not up takes an SError when Linux probes it.

    This commit trains nothing.

  2. pcie: t6050: train apcie0 port 0 (the N1) behind chosen.asahi,t6050-n1 (pcie_t6050.c). This ports Aura's measured T6050 GP-port bring-up (aurora-silicon/aura proxy: use numpy for the checksum if possible AsahiLinux/m1n1#60/Add an option to disable checksumming if possible AsahiLinux/m1n1#61, Jeff Queisser) to port 0. Every address comes from the ADT.

    • Storage registers (ANS, NVMe, SART, power) are compared with a reference before and after each stage that touches the shared GP PHY. Once a valid reference exists, they are compared again whenever the training stops, including partway through a stage. A failed check before the training only refuses it. A change after that resets the SoC through the watchdog after 15 s, instead of booting a kernel that could not mount its root.
    • Any other stop keeps port 0 and its DART disabled.
    • Adds tunables_check_local_addr(), pmgr_psreg_by_name(), and kboot_get_chosen() (a wrapper around kboot_chosen_param() for other files). pmgr_power_is_on() now skips virtual devices, because T6050 has a no_ps APCIE_PHY_SW beside the real one. Its other caller queries DISPEXT0_CPU.
  3. pcie: t6050: start ANS for the N1 training's storage checks (=3, =4). If ANS is stopped (our A/B stage 1 stops it after reading boot.bin), the training starts it with nvme_init() and reads the GPT header. Afterwards it requires the same registers and the same block, and stops ANS again with the new nvme_stop(). That is nvme_shutdown() continued through the M1-M3 teardown, so no RTKit session or SART buffer outlives the call. If ANS is already running, as in T6050 (M5 Max, J714c): boot from disk through the Omarchy chain #30's Omarchy chain where stage 1 hands its live session to U-Boot (asahi,nvme-adopt), =3/=4 train as =1/=2 and leave ANS alone, so nvme_adopt_live_session and T6050 (M5 Max, J714c): boot from disk through the Omarchy chain #30's marking are untouched. T6050 (M5 Max, J714c): boot from disk through the Omarchy chain #30's opt-in coprocessor stop (nvme_t6050_stop_coproc, off by default) is checked before nvme_stop()'s teardown and wins when set. The RTKit HELLO wait becomes settable; it stays 1 s by default, and the training uses 10 s. Like the training, this runs once per boot: a second kboot preparation gets the first result and does not start a second ANS session.

  4. pcie: t6050: pulse the N1 reset through the SMC as on J813 (=2, =4). On the J716s, pci-bridge0 function-reset is pKW4("gP13", 0x00800000), as on J813. The commit writes template | 0, waits 50 ms, writes template | 1, waits 50 ms, then waits 100 ms before the port reset. The link-up wait is 1 s.

  5. pcie: t6050: handle a warm N1 and a live port 0 at entry (=2, =4). A restart resets the SoC but not the N1, which keeps running its firmware with gP13 released. With the SMC release:

    • The entry state and gP13 are printed.
    • A live link is parked first: LTSSM off, PERST# asserted, link down within 100 ms.
    • If gP13 reads released, the reset is held for 250 ms.
    • The endpoint must then answer in its ROM personality (106b:1900). An N1 that kept running (106b:1901) is never handed to Linux.
    • The SMC client gets bounded waits: each command, and the initialisation, has one 2 s deadline from the moment it is sent, which notifications do not extend ("SMC: no reply"). It also gets smc_read_u32().

    This is what made restarts work on the J716s.

Values of chosen.asahi,t6050-n1:

Value Behaviour
1 train only
2 SMC reset pulse, then train
3 1, with ANS started for the storage checks
4 2, with ANS started for the storage checks; the mode that brings the N1 up

Unset, nothing is trained, and a root port that does not meet the adoption preconditions stays disabled.

Testing

MacBook Pro 16-inch, M5 Pro (J716s, Mac17,8), macOS 27.3 beta 1 stub (26C5035r, mBoot-20457.60.65.0.1). Boot chain: our A/B stage 1 chainloads a stage 2 that carries the kernel, DTB and initramfs. Kernel: integration/aurora with the T6050 series, the pcie-apple adopted-port patches (park on shutdown, ASPM off, link kept through s2idle) and centauri.

This stack on hardware (2026-11-07). The full stack on #30 (omacom/wdt-keep at 6653bb2, m1n1 v1.6.1-429-g6653bb2, before the review fixes) booted the J716s on the first pass, 74 s to SSH, with chosen.asahi,t6050-n1=4. The loader started ANS, pulsed gP13 and trained the N1 (pcie-t6050: port 0 link Gen1 x1, port 0 up, N1 at 01:00.0, n1: port 0 up: root port and DART okay). Linux had 18 CPUs, and Wi-Fi associated with Bluetooth up. The same stack on #26 had done the same earlier. The review fixes since (DT values kept, storage re-checked on a stop, the ANS path once per boot, one deadline per SMC command) have not booted. See PR-1 for one unexplained fallback on the warm restart after the session.

Earlier runs with the same code in our own stage 2 (under the name chosen.m5pro,n1), all on 2026-11-07:

Run Variable Result
W0 unset iBoot leaves port 0 untrained (ltssm 0x0). Root port and DART stay disabled; Linux boots normally.
W1 =1 Refused by its own guard ("ANS is not running (before)"); NVMe unaffected.
W2 =3 m1n1 started the stopped ANS, read the GPT header, ran stages A and S with storage unchanged, and stopped ANS again. The link stayed down (N1 still in reset).
W2c =4 After the gP13 pulse: port 0 link Gen1 x1, endpoint 01:00.0 is 0x1900106b, NVMe read identical, ANS stopped again. Linux: adopted port 0, endpoint 01:00.
W3b =4, FTAB with the board's manifest stitched in 106b:1902/1903 appear, and wlan0 and hci0 register. It associates (WPA2, 5 GHz), gets a DHCP lease and passes traffic.
W4 =4, with commit 5 Three systemctl reboot cycles with wlan0 associated and a ping running: all three came back on the primary slot with the N1 adopted. A loader without commit 5 hung once on the warm N1, and the stage 1 watchdog booted the fallback.
daily =4 Daily payload since then: 18 CPUs, N1 adopted, wlan0 and hci0.

This branch:

Differences from the loader that was tested:

Dependencies:

  • Kernel: pcie-apple adoption of a loader-trained port, and the T6050 centauri driver. The adopted-port shutdown park is what lets a restart reach m1n1 with the link parked.
  • Firmware: the FTAB with the board's Image4 manifest stitched in comes from the distro or installer, not from m1n1. It is per board and per macOS build, not per unit.

Questions:

  • @edimoldovan: your J714c kernel trains the N1 itself. Does it still want the DT fill-in from commit 1 (firmware-name, platform ID, root port tunables), or does it read those elsewhere? If kernel-side training works on the J716s too, I would cut this PR down to commit 1.
  • If the training stays: should it be gated by board, like Aura's j813_n1_prepare(), instead of the opt-in? And should the modes collapse to =4 only? 1-3 exist only for bring-up comparisons.

edimoldovan and others added 9 commits November 7, 2026 21:47
kboot_boot programs only the MTP filter on T6050, dapf_init on reg 1 of
dart-mtp at 0x294810000: the firmware's first access is PMGR at
0x28830c000, entry 0 of the ADT dapf-instance-0, and without it the MTP
never sends HELLO. The AOP entry of dapf_init_all points at the block
shared by every DART at 0x2890fc000 and faults with an SError on T6050.

cpu_start_bit uses one bit per CPU index on T6050, as on T8142; the
4*cluster+core layout never releases cores 14-17 of its three 6-core
clusters.

The J714c ADT has nine i2c nodes; the i2c limit of
dt_disable_missing_devs is raised to 16.

Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- nvme: admit the J714c ADT's 64 KiB nvme window at 0x45dcc0000 with
  nvmmu at 0x41dcc0000 and use the 0x30000 aperture, as for T8140.
- kboot: retain the loader's heap on T6050 as on T8140, so the live
  NVMe session's buffers survive into the next stage.
- nvme: a shutdown path that stops the coprocessor and leaves its
  firmware resident, behind nvme_t6050_stop_coproc (default off, the
  session is preserved for the next stage).

Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Cluster table for the M5 Pro/Max: MCPU0 at 0x210e00000, default
P-state 4; the chip shares T8142's P-state register handling and keeps
the firmware voltage, PLL and throttling configuration.

Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Before starting the next stage on T6050, every USB port is brought up as
for the proxy (power, usb2phy, pipe handler, dwc3 device init) and
flipped to host: usb2phy host bits, gadget stopped, core soft reset,
port capability host, PHY auto-suspend off, pipe handler link detection
forced off (the parking the kernel PHY driver does for a USB 2.0-only
host).

On J714c the first flip never shows a plugged device; the second
shutdown, bring-up and flip shows it at once. usb_t6050_host_prep polls
PORTSC.CCS after each flip (50 ms the first time, 100 ms after that) and
redoes the bring-up and flip up to three times. A port without a device
stays in host mode after the last attempt.

usb_t6050_host_record, called after the display handoff, writes
/chosen/apple,t6050-usbprep with four words per port: attempts, PORTSC
after the prep, PORTSC before the jump, and ms until PORTSC.CCS. It goes
through the new kboot_set_chosen_u32s, which reopens the packed tree
from a copy, since kboot_prepare_dt has packed it. The P_VECTOR path
skips usb_hpm_restore_irqs on T6050.

Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Generalise dt_set_gpu_t8140 into dt_set_gpu_g17 parameterised by the G17
perf-state shape (count, active states, table count) and the accepted
compatibles, and call it for T6050 (apple,agx-t6050; 14/13/4) as well as
T8140. Fills the OPP table and the four UAT reserved-memory regions from the
ADT and leaves the node enabled when the data validates.

Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ainload target

A stage 1 with boot= loads the kernel, DTB and initramfs from the ESP
itself, so the secondaries start from the image iBoot loaded and their
locked RVBAR needs no relay. The embedded stage 1 config is the only
source of the USB proxy window, but a valid config also set the
chainload target, and boot= plus chainload= is refused. With boot= set,
the config now only provides the window.

Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add /arm-io/dart-pmp0 to dapf_entries[] so dapf_init programs the T6050
PMP's DAPF filter. Without it the PMP ASC MMIO window stays fabric-gated
and AP access SYNC-faults. dart-pmp0 is dart,t8110 with a
dapf-instance-0 property, which dapf_init -> dapf_init_t8110 already
handles; the DAPF aperture is reg[1] (0x2841b0000). After
dapf_init("/arm-io/dart-pmp0", 1) the PMP ASC CPU_CONTROL reads cleanly,
where a raw read without the filter faults.

On the FDT path the kernel DT aliases pmp0 to the PMP's DART with
status = okay to match this entry.

Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ithout its chainload target

A stage 1 that carries its next stage (U-Boot as the kernel payload, with
its devicetree) uses the embedded config for the proxy window only, as
boot= does. The default stage 2 target would otherwise replace the
appended kernel.

Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stage 1 reads m1n1/boot.bin with its own NVMe driver and hands the ANS
session over live (nvme.adopt=live-rtkit-v1). The ANS firmware takes
its RTKit handshake once per boot, so U-Boot must adopt that session
instead of starting one. Set /chosen/asahi,nvme-adopt for the appended
next stage; U-Boot's T6050 NVMe driver adopts when it is present.

Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rolotrealanis98 rolotrealanis98 changed the title pcie, kboot: T6050: optional N1 (Wi-Fi/Bluetooth) training and hand-off behind chosen.asahi,t6050-n1 (stacked on PR-1) pcie, kboot: T6050: optional N1 (Wi-Fi/Bluetooth) training and hand-off behind chosen.asahi,t6050-n1 (stacked on #33) Nov 7, 2026
@greptile-apps

greptile-apps Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] No new blocking issue was found; the PR appears safe to merge.

Summary

Adds optional T6050 N1 training and fills the device tree for the next kernel.

  • T6050 loaders can bring up the N1 before Linux takes over.
  • T6050 boots now pass CPU and GPU setup data to Linux.
  • T6050 secondary cores can reach the moved loader image.
  • Chainloaded T6050 boot memory stays reserved through Linux handoff.
  • T6050 USB ports reach Linux already in USB 2.0 host mode.

The earlier DT-overwrite and failed-training storage-check findings are fixed. rolotrealanis98 deferred the unused USB gadget resources to inherited PR #30; the stack now reserves late heap growth. rolotrealanis98 also explained that the earlier ANS finding targeted an inherited branch whose flag stays off, and Greptile withdrew it.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Prepare T6050 device tree] --> B[Fill unset N1 settings]
    B --> C{Training requested?}
    C -->|No| G[Check port adoption requirements]
    C -->|Yes| D[Check storage and optionally start ANS]
    D --> E[Optionally pulse SMC reset, then train]
    E --> F{Storage still safe?}
    F -->|No| R[Watchdog reset]
    F -->|Yes| S[Stop ANS if started here]
    S --> G
    G --> H[Enable eligible ports and DARTs]
    H --> I[Reserve late heap growth]
    I --> J[Enter next stage]
Loading

Reviews (4) · Last reviewed commit: "pcie: t6050: handle a warm N1 and a live..." · Reviewed by Greptile

Comment thread src/kboot_n1.c Resolved
Comment thread src/pcie_t6050.c Resolved
Comment thread src/usb.c Resolved
@rolotrealanis98

Copy link
Copy Markdown
Author

Thanks. Of the findings here:

Both fixes are folded into the commits that introduced the code; the branch is force-updated.

Comment thread src/nvme.c Resolved
@rolotrealanis98

Copy link
Copy Markdown
Author

Hardware update: the current tip of this stack (m1n1 v1.6.1-429-g02785a3, i.e. the branches after the review fixes) booted the J716s first pass tonight with the 87-patch daily kernel: watchdog left armed, RVBAR relay installed, N1 trained by the loader, MTP DAPF, #30's USB host prep on all three ports, 18 CPUs, Wi-Fi and Bluetooth up, 74 s to SSH; the following warm restart into our regular daily was clean. Log excerpt in m5pro-linux contrib/validated/integration/RESULTS.md (OMACOM-WDT-KEEP-v30 review-fixed).

edimoldovan and others added 8 commits November 8, 2026 08:47
On T6050 the USB host flip runs after kboot_prepare_dt() reserved the
retained heap and after chainload_image() set the next stage's
top_of_kernel_data. Its dwc3 bring-up allocates DART tables, which can
extend the heap past that boundary, so the next stage could reuse memory
the USB DART still points at.

Right before the jump, kboot_retain_late_heap() reserves the heap added
since the reservation, and chainload_retain_late_heap() raises the staged
top_of_kernel_data over the heap added since the staging. When the late
reservation fails, m1n1 returns to the proxy, as the display handoff does.

Tested on J714c: stage 2 with this change (m1n1-aurora 1.6.1.aurora22-104)
boots from disk into Omarchy, 22 of 22 feature checks pass.

Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Six host tests compile production bodies that aurora-silicon#30 extends for T6050
and stop compiling or matching on its head:
- test_nvme_adoption and test_smp_handoff_gate: nvme_init() and
  kboot_boot() now name T6050, and kboot_boot() calls dapf_init().
  Define T6050 and stub dapf_init() beside the existing stubs.
- test_smp_handoff_gate also compiles kboot_prepare_dt(), which since
  140a36b sets retained_heap_end. Declare it.
- test_m3_defaults_optout: payload_run() names T6050 for the live ANS
  session hand-off. Define it.
- test_universal_boot: the stage 1 config block now reads boot_spec and
  kernel (an appended next stage takes only the proxy window). Declare
  both, and add the cases aurora-silicon#30 introduces: with boot_spec or an appended
  kernel set, a configured target adds neither a chainload target nor
  its ESP hint, and a chainload= line is kept rather than refused. T6050
  joins the chip list of the configured-target cases.
- test_chainload_run_base compiles chainload_image(), which since 140a36b
  keeps the staged boot_args and heap high-water in file statics. Declare
  them beside the other model state.
- test_t8103_inherited_reservation ends its block at the T8140 heap
  check, which is now "T8140 || T6050" with a comment line before it.
  Match both forms.

integration/aurora passes all six before and after; on aurora-silicon#30's head
they fail without this.

Signed-off-by: Rolando Trevino <rolotrealanis@gmail.com>
iBoot locks the RVBAR of every T6050 secondary to the base of the image
it loaded, stage 1. A stage 2 with a kernel appended (about 38 MiB) does
not fit between that base and the secondary-only CTRR window that ends
at top_of_kernel_data (about 12 MiB on a J716s), so a stage 1 that puts
it above the window runs it at another address. Its secondaries then
reset into the retired stage 1's vectors, smp_prepare_rvbar() refuses
every start, and kboot disables CPUs 1-17 ("is not alive").

On T6050, rewrite slot 0 of that vector table, once, with the stub
start.S already writes at a moved M3 image's old base ("ldr x16, 1f;
br x16; 1: .quad _vectors_start"); T8140's single branch can be out of
reach at this distance. Only a table with our four slot tags, in RAM
below this image and outside the CTRR window, at EL2, is rewritten, and
kboot reserves its 16K page so a core reset later still finds the relay.
The write and read-back are shared with the T8140 relay, whose behaviour
is unchanged.

tests/python/test_smp_legacy_rvbar.py now builds the shared helper,
and a new case runs the T6050 relay: it is written once, read back, and
refused without a write outside EL2, for a foreign table, inside the
CTRR window, above this image or below RAM, for an unlocked RVBAR and
on other SoCs.

Tested on the J716s (MacBook Pro 16-inch, M5 Pro): our stage 2, chainloaded
above the CTRR window by our A/B stage 1, has started all 18 CPUs every
day since 2026-11-04 through the same forwarding stub.

Signed-off-by: Rolando Trevino <rolotrealanis@gmail.com>
The protocol-27 centauri driver and pcie-apple's T6050 adoption need from
the boot loader what only the ADT knows. For the apple,t6050-pcie host:

- the N1 control function (pci106b,1900) gets firmware-name
  "apple/centauri/<target-type>-ftab.bin", apple,centauri-platform-id
  (board-id << 16 | chip-id) and apple,centauri-protocol 27, each only if the DT leaves it
  unset;
- each apple,link-trained-by-bootloader root port gets the ADT
  pci-bridge<n> config, rc and gen3/4/5 shadow tunables as
  (offset, 4, mask, value) groups, which Linux replays in the root-port
  reset of the N1's post-ROM port cycle;
- each such root port and the DART its endpoint maps to are enabled only
  if the port meets the adoption's preconditions: root complex running,
  port ready, link up and not retraining, LTSSM on, an Apple endpoint,
  no RID route yet, the endpoint's command bits clear and the DART's
  protection and stream registers still 0 (the root port's buses are
  numbered if they are 0). Otherwise both stay disabled, since the DART
  of a port that is not up takes an SError when Linux probes it.

The MAC addresses already travel through the wifi0/bluetooth0 aliases.
Nothing here trains a link.

Signed-off-by: Rolando Trevino <rolotrealanis@gmail.com>
Port Aura's measured T6050 GP-port bring-up (aurora-silicon/aura PR
aurora-silicon#60/aurora-silicon#61, src/pcie_t6050.c, Jeff Queisser) to the J716s N1 on apcie0
port 0: the GP power closure and the shared GP PHY (stages A and S, only
while no GP port has a link), then the port's reset table, config
tunables, reset handshake, Gen3 x1 DBI policy, lane PHY, PERST# and
LTSSM (B-E), the bus numbers and the endpoint's ID (F, 106b:1900 or
1901) and Linux's adoption preconditions (G). Every address comes from
the ADT (apcie0 reg[16..21], pci-bridge0, gpio0, dart-apcie0).

Storage (ANS, NVMe, its SART and power) is compared with a reference
before and after each stage that touches shared state. A failed check
before the training only refuses it; a change after a stage, or after
a stage that stopped partway (checked again on every stop once the
reference is taken), returns N1_STORAGE_LOST, and kboot_setup_n1() then resets the SoC through the
watchdog after 15 s instead of booting a kernel that may not mount its
root. Any other stop leaves port 0 and its DART disabled, even if the
link came up (a stage G failure).

It only runs when the payload sets chosen.asahi,t6050-n1=1; =2 also
writes the N1's reset release through the SMC first (pci-bridge0
function-reset: pKW4 "gP13", template 0x00800000, written as
template | 1). adt_getprop_copy() returns the copied length, so the
function-reset descriptor is taken only when the whole descriptor was
copied.

Adds pmgr_psreg_by_name(), and makes pmgr_power_is_on() skip virtual
devices: T6050 has a no_ps APCIE_PHY_SW beside the real one. Adds
tunables_check_local_addr() (Aura's read-back with per-record strobe
bits excused), and kboot_get_chosen(), kboot_chosen_param() for the
other kboot files.

Signed-off-by: Rolando Trevino <rolotrealanis@gmail.com>
…sahi,t6050-n1=3|4)

On a boot chain whose chainloading stage-1 reads boot.bin from the ESP
and then stops ANS (as the J716s A/B stage-1 does), the stage-2 m1n1
finds ANS stopped, and the storage reference of the port-0 training
refuses before any write ("STOP: ANS is not running (before)":
/arm-io/ans reg[0] + 0x44, CPU control RUN bit 4, reads 0).

With chosen.asahi,t6050-n1=3 (=4 with the SMC reset release of =2),
stage-2 starts ANS with nvme_init(), reads NVMe block 1 (the GPT
header), runs the =1/=2 training with storage live as designed, then
requires the same storage registers and the same block read again, and
stops ANS again with the new nvme_stop(). If storage is in doubt, it
resets the SoC through the watchdog after 15 s instead of booting a
kernel that could not mount its root. With ANS already running, =3/=4
train as =1/=2, with the same fatal handling of a storage change.

nvme_stop() is nvme_shutdown() without the post-M4 hand-off: on M4 and
later nvme_shutdown() disables the controller but leaves ANS, its RTKit
session and its SART-mapped buffers live for a later stage to adopt.
Here nothing adopts them: Linux's nvme-apple boots a stopped ANS
itself, and the buffers would sit in RAM that Linux sees as free while
the firmware still owns them. nvme_stop() goes on to the M1-M3 teardown
(RTKit sleep, ANS reset, SART and queues freed), which is what the
tested J716s boots ran.

rtkit_boot()'s HELLO and endpoint-map wait becomes settable (1 s by
default, as before); the training sets 10 s around nvme_init(), as
Linux waits for this ANS (it can take about 3 s to answer after a stop).

Like the training itself, this runs once per boot: a second kboot
preparation gets the first result and leaves ANS alone.

=1 and =2 are unchanged.

Signed-off-by: Rolando Trevino <rolotrealanis@gmail.com>

# Conflicts:
#	src/nvme.c
…ahi,t6050-n1=2|4)

The J716s ADT's /arm-io/apcie0/pci-bridge0 function-reset is phandle
654 (the SMC PMU nub), "pKW4", key "gP13", template 0x00800000: the
descriptor Aura's J813 code uses. Release the N1's reset as J813 does
(aurora-silicon/aura 21c3f70, src/j813_n1.c): write template | 0,
wait 50 ms, template | 1, wait 50 ms, shut the SMC client down, then
100 ms before the port reset table; the link-up wait becomes 1 s. The
SMC's RTKit boot gets the same 10 s HELLO/endpoint-map wait as ANS.

On the J716s, =4 brings the link up at Gen1 x1 with the N1 (106b:1900)
at 01:00.0; without the pulse (=3) the link did not come up in 500 ms.
=1 and =3 are unchanged (same register sequence, 500 ms link wait).

Signed-off-by: Rolando Trevino <rolotrealanis@gmail.com>
…i,t6050-n1=2|4)

A restart from a boot with the N1 trained and in use resets the SoC but
not the N1: it keeps running its firmware with the SMC's gP13 left
released. On the J716s, a loader without this change hangs once on that
warm N1 (the stage 1 watchdog then boots the fallback payload), and m1n1
had never seen that state.

With the SMC release (=2, =4):
- print the entry state of port 0 (link status, LTSSM control, PERST#
  pad) and what gP13 reads before the pulse;
- a port that still has a link is parked first: LTSSM off, PERST#
  asserted, link down within 100 ms, or STOP "link down after PERST#";
- if gP13 reads released (template | 1), hold the reset 250 ms instead
  of 50 ms;
- the endpoint must then answer in its ROM personality (106b:1900);
  106b:1901 means the N1 kept running, and the training stops instead
  of handing it to Linux.
=1 and =3 still adopt a live link and accept 106b:1901, as before.

The SMC client gets bounded waits: a command, and the initialisation,
ends with "SMC: no reply" if its reply has not come 2 s after it was
sent, however much other traffic (notifications) arrives meanwhile (it
used to spin forever, also on an RTKit receive error), and
smc_read_u32() reads a key of up to 4 bytes.

Tested on the J716s (MacBook Pro 16-inch, M5 Pro) with the same change
on our stage 2: three systemctl reboot cycles with wlan0 associated and
a ping running all came back on the primary slot with the N1 adopted.

Signed-off-by: Rolando Trevino <rolotrealanis@gmail.com>
@rolotrealanis98

Copy link
Copy Markdown
Author

Rebased onto 140a36b with no change; the SMC and ANS sessions the N1 training starts now fall inside the heap range #30 reserves just before the jump. Booted on the J716s after the rebase (stage-2 log: FDT: late heap [...] retained, N1 trained, 18 CPUs, Wi-Fi and Bluetooth up, 54 s to ssh).

@edimoldovan

Copy link
Copy Markdown

@rolotrealanis98 the J714c kernel doesn't need commit 1. It reads all of those from its own device tree, as values taken from the J714c ADT:

  • the N1 node in t6050-j714c.dts sets firmware-name = "apple/centauri/j714c-ftab.bin", apple,centauri-platform-id = <0x000a6050> and apple,centauri-protocol = <27>
  • the root port and PHY tunables (apple,apcie-config-tunables, apple,pcie-rc-tunables, the gen3/4/5 shadow tunables, apple,tunable-phy*) are in t6050-j714c-pcie-tunables.dtsi, and pcie-apple applies them when it trains the port

Commit 1 fills only what the DT leaves unset, so it doesn't conflict with that. For the J716s it depends on whether its DT carries its own copies of these values.

@rolotrealanis98

Copy link
Copy Markdown
Author

Thanks, that settles the J714c side. For the J716s it is half and half:

  • Its DT on integration/aurora carries the N1 node's own firmware-name ("apple/centauri/j716s-ftab.bin"), apple,centauri-platform-id (0x000c6050) and apple,centauri-protocol (27), so commit 1 leaves those alone, as on the J714c.
  • It has no PCIe tunables. There is no J716s counterpart to t6050-j714c-pcie-tunables.dtsi, so the root port tunables (apple,apcie-config-tunables, apple,pcie-rc-tunables and the gen3/4/5 shadow tunables) still reach the kernel through commit 1, which copies them from the ADT onto each port marked apple,link-trained-by-bootloader.

So the J716s still needs commit 1 for the tunables. The other way would be a J716s tunables dtsi like yours, with the values from its ADT; I can send that to linux if you would rather keep them in the DT for both boards.

@edimoldovan

edimoldovan commented Nov 10, 2026 •

Copy link
Copy Markdown

@rolotrealanis98 let's keep commit 1 for the J716s tunables, no J716s dtsi.

@rolotrealanis98

Copy link
Copy Markdown
Author

The M5/T6050 loader work now lands in aurora-silicon/aura, the m1n1-based loader the J716s boots through, so I am closing this stack here. Superseded: aura hands off N1 (Wi-Fi/Bluetooth) on T6050, and the J716s Wi-Fi and Bluetooth work through it.

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