Skip to content

kboot, pcie, smp: T8103 (G13G) GPU 27.2 handoff and S2R wake PCIe/exception restore - #529

Merged
DjDeveloperr merged 4 commits into
mainfrom
feat/t8103-gpu-s2r
Nov 25, 2026
Merged

DjDeveloperr merged 4 commits into
mainfrom
feat/t8103-gpu-s2r

Conversation

@erikwb

@erikwb erikwb commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

What: Publish the T8103 (G13G) GPU firmware 27.2 DT handoff and harden the S2R wake return path (masked DAIF + VBAR_EL2 setup, PCIe complex re-initialization on pre-M4 SoCs without nvme-secure-bar, and watchdog coverage through failure reboot).
Tested: J313 (M1 MacBook Air, f5ddfff2 with combined Linux exact heads 3577ce0e4885 + 697fc879d990 at c808a9c12341, live accelerated Hyprland): boot + GPU 27.2 handoff + 3 consecutive physical S2R wakes (0 -> 1 -> 2 -> 3), Wi-Fi/BT/audio/Borealis compute & render passing every wake. J713 (M4 MacBook Air, f5ddfff2 on 7.3.0-ewb-daily+): boot + 2 consecutive physical S2R wakes (0 -> 1 -> 2), NVMe + PCIe/radio intact, 0 failed units, 0 new kernel errors. Host tests (test_pcie_sequence.py, test_smp_handoff_gate.py, test_smp_timeouts.py) and clang-format --dry-run --Werror pass.
Risk: two-way door · M1 (T8103) GPU 27.2 handoff and shared S2R wake return / PCIe complex replay path (other Macs gated by ADT nvme-secure-bar and controller boot state).
Not yet: M1 Pro/Max/Ultra (T600x) and M2/M3 (T8112/T8122) S2R wake PCIe replay; J713 tested on non-27.2 firmware.

Details
  1. kboot: gpu: publish the T8103 (G13G) firmware 27.2 handoff (a1f20632) — adds the T8103 struct gpu26_target entry selected by ADT compatibility (sgx,t8103 / sgx,g13g), publishes apple,firmware-compat = <27 2 0>, reserves the coredump copy buffer, and enables the DT GPU node on firmware 27.2+.
  2. exception: keep DAIF masked and set VBAR_EL2 when returning from S2R (3526be04) — installs VBAR_EL2 and leaves DAIF masked across the S2R wake return into the OS.
  3. pcie, smp: re-initialize PCIe complex on S2R wake before returning to the OS (8893cb58) — replays pcie_init_controller() on wake for boot-initialized controllers when the OS does not own APCIe tables and the ADT has no nvme-secure-bar, powering ANS domains first as at boot.
  4. smp: keep S2R PCIe watchdog armed until failure reboot (f5ddfff2) — keeps the hardware watchdog armed across the wake PCIe replay and failure-reboot path so a stalled replay cannot hang indefinitely.
Evidence
  • J313 (ewb-m1, M1 MacBook Air) at f5ddfff2 (BIOS aura 1.0.0b17-gf5ddfff2, Linux combined merge c808a9c12341 of 3577ce0e4885 + 697fc879d990):
    • Cold boot published T8103 GPU 27.2 handoff (G13 firmware 27.2 running; DRM device registered), live accelerated Hyprland on Apple M1 (G13G B1).
    • Pre-sleep Borealis: compute-check 5 4460 runs / 0 bad, render-check 200 200/200; s2idle 4459/0; pm_test=core 4497/0.
    • 3 consecutive physical S2R wakes (boot object resumes 0 -> 1 -> 2 -> 3):
      • Cycle 1: PCIe link back, Wi-Fi reconnected, BT MGMT ver 1.23, audio OK, GPU back in 5071 us, Borealis 4203/0 + 200/200, same Hyprland PID 4646.
      • Cycle 2: PCIe link back, Wi-Fi reconnected, BT MGMT ver 1.23, audio OK, GPU back in 4031 us, Borealis 4167/0 + 200/200, same Hyprland PID 4646.
      • Cycle 3: PCIe link back, Wi-Fi reconnected, BT MGMT ver 1.23, audio OK, GPU back in 2800 us, Borealis 4174/0 + 200/200, same Hyprland PID 4646.
    • Regression counts: SELinux disabled (0 denials); aurora-sep.service failed (expected before first password unlock after cold boot, same as daily boot); 0 new S2R/PCIe/GPU kernel errors.
  • J713 (ewb-m4, M4 MacBook Air) at f5ddfff2 (BIOS aura 1.0.0b17-gf5ddfff2, Linux 7.3.0-ewb-daily+):
    • One-shot /boot/efi/aura-try boot clean; 2 consecutive physical S2R wakes (boot object resumes 0 -> 1 -> 2); NVMe (nvme0n1) + PCIe (00:00.0, BCM4388 Wi-Fi/BT) intact; 0 failed units; 0 new kernel errors.
  • Build & host checks: build/aura.bin (3,932,160 bytes) and build/aura-boot.macho build clean; clang-format --dry-run --Werror clean on all touched C/H files; test_pcie_sequence.py, test_smp_handoff_gate.py, and test_smp_timeouts.py pass.

Recognize the headerless T8103 (G13G) firmware 27.2 (26B131) image in
firmware.c and extend the G14G 27.2 handoff in kboot_gpu26.c to cover
T8103:

- Allow the 3-segment preloaded firmware layout on T8103 where the
  __DATA segment flags word is 0 (0x10 on G14/G15).
- Make ADT perf-states-sram optional on T8103 (which has no
  perf-states-sram property and derives SRAM voltage from
  apple,min-sram-microvolt in the device tree).
- Mark the GPU power domain both apple,no-auto-pm and
  apple,sleep-retained when publishing the 27.2 handoff so Linux PMGR
  does not auto power-gate or suspend-gate ps_gfx under the live ASC.

Signed-off-by: Erik Bourget <erik@ebourget.net>
Once the S2R mailbox is published, a core reset brings the cores back
through this image on their way back to the OS that slept. That OS owns
every interrupt source by then, so exception_initialize() keeps debug,
SError, IRQ and FIQ masked instead of unmasking them on the boot core.

At EL2 it now writes VBAR_EL2 by name, before any other register
access, instead of VBAR_EL1. VBAR_EL1 reached EL2's vector base only
through the E2H alias, which a core reset need not have set up yet;
VBAR_EL2 is the same register wherever that alias was in place, so
nothing changes for a normal boot.

smp_s2r_return_to_os() keeps its explicit mask; its comment now says why.

Signed-off-by: Erik Bourget <erik@ebourget.net>
… the OS

A system sleep takes the PCIe complex's power with the rest of the SoC.
Where kboot hands the OS the ADT's APCIe tables (pcie_apcie_tables_fdt(),
an ANS with nvme-secure-bar: M4 on), the OS brings the block back
itself. Elsewhere, T8103 among them, only aura's boot-time setup
describes the complex, and after an S2R wake the M1 MacBook Air (J313)
resumed into a complex that was no longer set up.

The gate is what the ADT says and what aura actually did, not a chip.
The boot core, back from the sleep and on its way to the OS, sets the
complex up again only if all of these hold (pcie_needs_sleep_reinit()):
- a controller came up at boot through pcie_init_controller(), so a SoC
  whose PCIe comes up another way (T6050) is never replayed;
- kboot did not hand the OS the APCIe tables (it records whether it did,
  pcie_set_os_restores_apcie());
- the ADT has an ANS without nvme-secure-bar (pcie_sleep_reinit_possible()),
  so an M4 or later Mac is never replayed, even if its table export
  failed.
The saved J313 ADT has no nvme-secure-bar; the J713, J714s and J716c
ADTs have it.

pcie_reinit_after_sleep() replays only the controllers that came up at
boot, each from the ADT node it came up from (recorded in its slot), and
fails if any one of them fails or none came up. pcie_init() tries
/arm-io/apcie and /arm-io/apcie0 against the same slot, and the replay
does not repeat that. On the replay the APCIe controller's RC word at
+4, which boot clears, is read first and written only if the sleep left
it set; boot is unchanged.

smp_s2r_pcie_reinit():
- turns the console off first: nobody drains it now, and a full FIFO
  holds the core;
- runs under a watchdog, wdt_s2r_guard_enter()/exit(). It reads the
  watchdogs before any write. If the OS left one of the two it uses
  armed (the primary with its reset enable, as Linux's T8103 sleep
  does, or the third, at +0x2c of the primary block, with its enable),
  that covers the step and nothing is written. Otherwise, on the ADT's
  version 2 layout with the secondary watchdog off, it borrows the
  primary for 30 s (Linux's default period), reads it back, and
  afterwards restores the control, count and alarm it read. The
  secondary is never written. Without a watchdog either way, the step
  doesn't run and the Mac reboots;
- powers ANS's domains before the PHY comes up, as they already are at
  boot;
- reboots if the complex doesn't come back, rather than resuming the OS
  into a state it doesn't know.

So that a reboot from that step always works, the S2R mailbox is
published only where the step is ruled out by the ADT or the watchdog
layout it needs is there (wdt_s2r_guard_supported(), which also keeps
the primary's base in memory for wdt_reboot()). Otherwise
aurora,s2r-unavailable says why. kboot publishes the mailbox before it
sets PCIe up, so that check uses the ADT part of the gate.

The PCIe sequence host test covers the replay: the same MMIO accesses
and polls as boot for the one controller that came up, the RC word read
first and cleared only when set, failure propagation, nothing to replay
when nothing came up, and the gate's cases (tables handed over, an ANS
with nvme-secure-bar, no ANS, PCIe up without a replayable controller).
The SMP handoff gate host test stubs the new kboot call.

Signed-off-by: Erik Bourget <erik@ebourget.net>
In smp_s2r_pcie_reinit(), only exit the borrowed S2R watchdog guard on
the success path before returning to the OS, keeping the watchdog armed
across reboot() if PCIe re-initialization fails.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb
erikwb requested a review from a team as a code owner November 25, 2026 18:48
@erikwb
erikwb requested a review from Acelogic November 25, 2026 18:48
@github-actions github-actions Bot added blast:m1 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Merge readiness at f5ddfff2: not ready yet

Check Detail
CI at head running running: Pytest (macos-15 + llvm-brew)
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at f5ddfff2
Conflicts ok none
PR text ok Risk: two-way · M1 (T8103) GPU 27.2 handoff and shared S2R wake return / PCIe complex replay path (other Macs gated by ADT nvme-secure-bar and controller boot state).

Areas: none matched in CODEOWNERS

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

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — audited the full diff across exception/VBAR_EL2 EL2 S2R handling, G13G GPU 27.2 handoff (3-segment zero-data flag, optional SRAM, apple,sleep-retained), wake PCIe replay gating (up_path tracking + !nvme-secure-bar), WDT v2 ADT guard/restore + PoC cache clean, and SMP wake ordering/tests, with 2-gen physical S2R verification on J313 (M1) and J713 (M4).

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Nov 25, 2026
@DjDeveloperr
DjDeveloperr merged commit a703a9b into main Nov 25, 2026
24 of 25 checks passed
@RyanTheTide
RyanTheTide deleted the feat/t8103-gpu-s2r branch November 27, 2026 13:21
DjDeveloperr added a commit that referenced this pull request Dec 3, 2026
pcie_os_restores_host_fdt() took an apple,pcie-host claim from any
node whose own status was enabled. A claimant that is enabled itself
but sits below a disabled bus never gets a device: Linux's OF platform
population stops at the disabled bus. aura still skipped the #529
wake-time replay for that host, and no OS driver brought it back.

Count a claim only when the claimant and every node above it are
enabled, with the same status rule as pcie_fdt_node_enabled(). A tree
lookup error counts as no claim, so the replay runs as before.

The host test adds an enabled claimant below a disabled simple-bus,
and below a disabled group under an enabled bus. Both must leave the
replay on; the claim counts once every ancestor is enabled.

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

blast:m1 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants