Skip to content

drm/asahi: enable T8103 (G13G) on GPU firmware 27.2 and support g14_v27_2 deep sleep warm restart - #3171

Merged
RyanTheTide merged 6 commits into
mainfrom
feat/t8103-gpu-27-2-s2r
Nov 26, 2026
Merged

RyanTheTide merged 6 commits into
mainfrom
feat/t8103-gpu-27-2-s2r

Conversation

@erikwb

@erikwb erikwb commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

What: Enable T8103 (M1 / G13G) GPU acceleration on firmware 27.2 (g14_v27_2), populate the missing GPU power-controller parameters, and add deep-sleep warm restart and failure-handling hardening for the g14_v27_2 backend.
Tested: J313 (M1 MacBook Air, exact head 3577ce0e4885 merged unchanged with T8103 S2R 697fc879d990 at c808a9c12341 + companion aura-silicon/aura#529 f5ddfff2, live accelerated Hyprland on Apple M1 (G13G B1)): cold boot G13 firmware 27.2 running, pre-sleep Borealis compute (4460/0) & render (200/0), s2idle (4459/0), pm_test=core (4497/0), and 3 consecutive physical S2R wakes (0 -> 1 -> 2 -> 3) with GPU warm restart in 2.8-5.1 ms and Borealis compute & render passing on every wake.
Risk: two-way door · M1 (T8103 / G13G) and M2 (T8112 / G14G) GPUs using the g14_v27_2 firmware 27.2 backend.
Not yet: M2 (T8112 / G14G) runtime verification on 3577ce0e4885 (G14 gpu/v27_2.rs paths preserved unchanged from origin/main).

Details

Companion Aura PR: aurora-silicon/aura#529 (publishes the T8103 GPU 27.2 DT handoff).

Commits:

  1. drm/asahi: enable T8103 (G13G) on GPU firmware 27.2 (e4a69b150876) — adds T8103/G13G hardware and v27_2 initdata/firmware wiring alongside G14G without altering G14G behavior.
  2. drm/asahi: g14_v27_2: populate the GPU power controller parameters (baf523ed93a3) — populates the power-controller fields needed for clean T8103/G13G firmware bring-up and runtime stability.
  3. drm/asahi: g14_v27_2: support deep sleep warm restart (f03b064ad184) — drains queues, halts the ASC at sleep commit, and warm-restarts GPU firmware 27.2 on physical wake.
  4. soc: apple: sleep: export apple_sleep_coproc_wake_error() (3bdddf1caa53) — exports the wake-error query used by the g14_v27_2 driver.
  5. drm/asahi: g14_v27_2: harden deep-sleep prepare, rollback, and DT power gating (33239c32c0b3) — handles refused sleeps before commit (pm_test=core), restores keep-powered state on rollback, and gates power transitions via DT properties.
  6. drm/asahi: g14_v27_2: skip hardware teardown after failed sleep or wake (3577ce0e4885) — avoids touching dead GPU MMIO during teardown if sleep commit or wake fails.
Evidence
  • J313 (ewb-m1, M1 MacBook Air) at exact head 3577ce0e4885 (combined test merge c808a9c12341 with T8103 S2R 697fc879d990, BIOS aura 1.0.0b17-gf5ddfff2, stock mesa-aurora):
    • Cold boot: aurora 206400000.gpu: G13 firmware 27.2 running; DRM device registered, live accelerated Hyprland PID 4646 on Apple M1 (G13G B1).
    • Pre-sleep: Borealis compute-check 5 4460 runs / 0 bad; render-check 200 200/200 (0 wrong).
    • s2idle: GPU held/released cleanly (running=Ok(1) pending=0); Borealis compute-check 5 4459 runs / 0 bad.
    • pm_test=core: GPU: deep sleep refused before commit; restoring keep-powered; Borealis compute-check 5 4497 runs / 0 bad.
    • Physical S2R Cycle 1 (boot object resumes 0 -> 1): GPU firmware 27.2 back in 5071 us (commit idle=0 130 us, pending=0), Borealis 4203/0 + 200/200, Hyprland PID 4646 unchanged.
    • Physical S2R Cycle 2 (boot object resumes 1 -> 2): GPU firmware 27.2 back in 4031 us (commit idle=0 140 us, pending=0), Borealis 4167/0 + 200/200, Hyprland PID 4646 unchanged.
    • Physical S2R Cycle 3 (boot object resumes 2 -> 3): GPU firmware 27.2 back in 2800 us (commit idle=0 150 us, pending=0), Borealis 4174/0 + 200/200, Hyprland PID 4646 unchanged.
    • Regression counts: SELinux disabled (0 denials); aurora-sep.service failed (expected after cold boot before first interactive password unlock, same as daily boot); 0 new GPU/DRM kernel errors.
  • Standalone build: Image and drivers/gpu/drm/asahi/aurora.ko build cleanly at 3577ce0e4885 against origin/main; git diff --check clean; clean merge with origin/main (0c1f4530e220).

Extend the g14_v27_2 backend to support T8103 (G13G) on firmware 27.2
(26B131) on the default kernel command line:

- Map ASC control and MMU fault-status registers with ioremap_np() to
  honor Apple SoC nonposted-mmio; a posted write to ASC_CPU_CONTROL
  resets T8103 immediately.
- Add T8103 REGISTERS_V27_2 and WRITABLE_V27_2 register aperture tables
  (including PMP doorbell slot 2 and PMGR scratch / PMP telemetry slot 5)
  and route apple,agx-t8103 with apple,firmware-compat = <27 2 0> to
  probe_g14_v27_2().
- Build the G13G 27.2 HwDataB, globals, power, and calibrated thermal /
  DVFS controller from the 13.5 configuration and device tree (deriving
  SRAM voltages from apple,min-sram-microvolt when adt-perf-states-sram
  is absent, and omitting G14-only CRE and per-sensor coefficient tables).
- Encode G13 vertex and fragment JobParameters1 layouts in
  g14_v27_2_render.rs and allow 3000 ms for the initial idle-policy
  handshake while G13G runs its first DVFS transition.

Signed-off-by: Erik Bourget <[email protected]>
RootV27_2::controller() seeded the power-controller output at +0xa48 to
max_state and relocated pwr_min_duty_cycle to +0xa00, but left the power
controller's own parameter block (+0x9c8..+0xa14) zero.

While the GPU stays powered, +0xa48 keeps its initial max_state value.
Once the GPU powers off for at least two 8 ms power-sample periods (such
as across deep sleep or an idle power-off), the firmware's power-up
replay recomputes +0xa48 from +0xa08, +0xa04, and the controller gains.
With +0xa04 and +0xa08 zero, +0xa48 clamps to 0, driving the overall
performance target (+0x50) to 0 (reason 1) and forcing the firmware into
below-minimum-pstate duty-gating on an 8 ms cadence (~26x slowdown).

Populate +0x9c8..+0xa14 from the board's calibrated 13.5 hwdata_a
parameters (derived from device tree) and reject a zero
pwr_filter_time_constant in RootV27_2::build().

Signed-off-by: Erik Bourget <[email protected]>
Allow the G13/G14 firmware 27.2 backend to participate in firmware-driven
deep sleep (S2R) via commit-time coprocessor stop and warm restart:

- In driver.rs, pass pm_suspend_via_firmware() into backend.sleep_prepare()
  instead of unconditionally refusing deep sleep with -EBUSY.
- In g14_v27_2.rs, map the Fender operating-point page alongside the ASC
  control page, drain pending work and worker queues during deep sleep
  prepare, switch the firmware idle policy to allow-off, and register a
  commit-time stop callback (apple_sleep_coproc_register_first) that runs
  apple_rtkit_sleep_idle_polled(), disables mailbox receive, and clears
  ASC_RUN only after all sleep refusals have passed.
- In sleep_complete(), restore keep-powered if the sleep was refused
  before commit; after a real firmware-driven wake, warm-restart RTKit
  (apple_rtkit_warm_restart), re-assert ASC_RUN, re-boot RTKit, restore
  keep-powered, and wait for the Fender operating point to report powered.
- In gpu/v27_2.rs, add PoC cache maintenance to drain() and
  firmware_running(), enable the G13 sleep/wake and RTKit power-callback
  inline words, remove the stale zeroing of +0x10cc/+0x10d0 that clobbered
  uat_ttb_base, add compile-time offset assertions before 0xfc0, and
  populate the warm-restart wake operands (+0x9c..+0xa8).

Signed-off-by: Erik Bourget <[email protected]>
Track per-coprocessor platform wake errors on apple_sleep_coproc (reset
alongside stop_ret when readied) and export apple_sleep_coproc_wake_error()
so coprocessor drivers can check whether their power domain and fabric
restored cleanly after a deep-sleep wake before touching MMIO or RTKit.

Signed-off-by: Erik Bourget <[email protected]>
…er gating

Address deep-sleep concurrency, rollback, and DT calibration invariants:

- Track whether all four GPU power-controller tuning properties were
  explicitly supplied by the machine's DT/ADT (pwr_controller_from_dt) in
  PwrConfig::load(). Only populate the 27.2 power controller (+0x9c8..+0xa14)
  and allow deep sleep when those properties are present, avoiding fallback
  coefficients on boards whose DT omits them.
- Synchronize deep_sleeping toggles under Notify::runtime's spinlock so no
  RTKit notification or retry can race queue.drain().
- Track whether an allow-off idle-policy record was published during
  sleep_prepare(), confirm keep-powered rollback before reopening
  submissions (failing the backend if rollback cannot be confirmed), and
  require Fender to report powered-off with no request pending (0x1f == 0)
  before arming commit stop.
- In g14_v27_2_commit_stop(), return immediately without clearing ASC_RUN
  if RTKit idle fails. In sleep_complete(), check commit.idle_ret and
  apple_sleep_coproc_wake_error() before touching ASC or RTKit.
- Hold CommitStop alive across apple_sleep_coproc_unregister() in stop(),
  use typed *mut bindings::device FFI prototypes, and remove redundant PoC
  cache maintenance on shared telemetry/status cursors in gpu/v27_2.rs.

Signed-off-by: Erik Bourget <[email protected]>
Persist hardware_unreachable in State when sleep_complete() sees a
refused sleep after commit stop or a commit/wake error, and skip live
RTKit and ASC MMIO operations in stop() while still retaining the
firmware's page-table backing.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb
erikwb requested review from a team and DjDeveloperr as code owners November 25, 2026 18:49
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m2 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

Merge readiness at 3577ce0e: ready to merge

Check Detail
CI at head ok 25 checks passed
Review ok approved by DjDeveloperr, satchlj
Requested changes ok none
Hardware row at head ok in the PR body at 3577ce0e
Conflicts ok none
PR text ok Risk: two-way · M1 (T8103 / G13G) and M2 (T8112 / G14G) GPUs using the g14v272 firmware 27.2 backend.

Areas: area:gpu, area:platform
Merge: gh pr merge 3171 --merge (Owners and Core through the bypass: add --admin).

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

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verdict: MERGE at 3577ce0e4885

Blockers: none

Checked: Full 8-file diff audit across drivers/gpu/drm/asahi/{driver,g14_v27_2,g14_v27_2_render,gpu/v27_2,hw/mod,hw/t8103}.rs and drivers/soc/apple/sleep.c / include/linux/soc/apple/sleep.h (verified G13/G14 register and JobParameters1 separation preserves G14 paths unchanged, non-posted ioremap_np + paired iounmap on ASC/Fender/FaultStatus, deep_sleeping spinlock ordering and worker/queue drain before commit-stop registration, try_set_idle_policy rollback only when published, CommitStop lifetime held across apple_sleep_coproc_unregister, hardware_unreachable teardown guard on failed sleep/wake, and mutex-guarded apple_sleep_coproc_wake_error with reset on set_ready); no Apple material, no model/board gates, human DCO across all 6 commits; exact-head J313 hardware verification row (cold boot, s2idle, pm_test=core, 3 consecutive S2R wakes with live Hyprland and Borealis compute/render); all 26 CI check-runs green with zero active checks.

Evidence
  • Head: 3577ce0e4885ca23f43b62087503b078b2fbee64 (6 commits, all signed off by Erik Bourget).
  • Diff audited: 8 files (+1009/-368), g14_v27_2 deep-sleep prepare/rollback/commit-stop/warm-restart and hardware_unreachable teardown invariants verified.
  • Author hardware evidence at exact head 3577ce0e4885: M1 MacBook Air (J313, G13G B1) cold boot (G13 firmware 27.2 running), pre-sleep Borealis compute (4460/0) & render (200/0), s2idle (4459/0), pm_test=core (4497/0), and 3 consecutive physical S2R cycles (0 -> 1 -> 2 -> 3, warm restart 2.8-5.1 ms).
  • CI: 26/26 check-runs completed and passing (0 active, 0 failing).

@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 8-file diff across T8103 (G13G) firmware 27.2 registration/register-table wiring, g14_v27_2_render.rs G13 vs G14 layout split (preserving G14 unchanged), gpu/v27_2.rs optional SRAM table & DT-gated power controller parameters, non-posted MMIO (ioremap_np), IRQ-off CommitStop registration with race-free Notify::set_deep_sleeping queue drain, abort_deep_prepare rollback, hardware_unreachable teardown guard, and apple_sleep_coproc_wake_error() export. All 25 CI jobs are green with 3-cycle J313 S2R + Borealis verification; holding merge for an M2 (T8112/G14G) no-regression check covering the shared g14_v27_2 path.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 25, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

3577ce0e4885 (merged cleanly onto main 61c7b88aca91 with 0 merge-tree diffs, default cmdline) J473 (M2 Mac mini, T8112, G14G B0) PASS: aurora 206400000.gpu: G14 firmware 27.2 running; DRM device registered, pre-sleep Borealis gpubench-vk render.light ok (827 submits) + compute.light ok (1,586 submits) + Asahi GL 32/32 (hw=true), 1/1 rtc1 s2idle wake, post-sleep Borealis render.light ok (620 submits) + compute.light ok (922 submits) + Asahi GL 32/32 (hw=true), 0 GPU faults/recoveries, 0 new kernel errors, 0 failed units, Enforcing, 0 AVC; stock 7.3.0-aurora-fleet89 restored and verified.

@RyanTheTide
RyanTheTide merged commit c54fb81 into main Nov 26, 2026
28 checks passed
@RyanTheTide
RyanTheTide deleted the feat/t8103-gpu-27-2-s2r branch November 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m2 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants