Skip to content

drm/asahi: g16: run the M4 GPU on the macOS 27.2 firmware (26B123) - #2676

Draft
DjDeveloperr wants to merge 6 commits into
integration/aurorafrom
djdev/g16-272
Draft

DjDeveloperr wants to merge 6 commits into
integration/aurorafrom
djdev/g16-272

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Runs the G16 GPU (M4, T8132) on the 26B123 GPU firmware (also shipped in 26B131). 25G83 keeps its existing start and every 25G83 byte is unchanged. The driver selects the firmware layout strictly from the firmware's own identity — the boot loader's handoff fields (apple,g16-handoff-version, segment VAs and flags) and the loaded TEXT digest — and fails closed on unknown builds. It never checks a board, SoC compatible, or OS firmware version string for this.

Depends on the GPU temperature input workstream (apple_pmp_telemetry_get_gpu(), branch lab/j713-g16-agx-temp once on integration/aurora).

Commit series (origin/integration/aurora..2244998f3fc6, 6 commits)

  1. 45b05cdbf811 — soc: apple: pmp: detect retained T8132 PMP bridge from the device tree
    Detects the retained T8132 PMP power-vote bridge from the DT pmp node (apple,t8132-pmp-v2, available, apple,tunable-soc-device present) rather than gating on a board list, root SoC compatible, or OS firmware version string.
  2. 9717482bed54 — drm/asahi: g16: admit J773g 25G83 images, derive DVFS table from ADT, and run to top p-state
    Admits J773g 25G83 and boot-filled B000 images, derives the firmware DVFS row count (10-row vs 11-row) directly from the preserved ADT performance-state table (no board-gated asahi_g16_perf_rows()), and lets the governor, cooling ceiling, and p-state check run up to the board's top state (S10 on 11-row tables).
  3. 0fb26972a7d6 — drm/asahi: g16: reuse PB epochs, keep compute in flight, share 64 MiB PB heap, and close VM caches
    Unconditionally reuses retired pass-slot PB epochs (no g16_pb_reuse parameter or aurora-g16/tune mutable debugfs; aurora-g16/stats stays read-only), keeps compute in flight on per-unit UMA slots, shares one 64 MiB PB heap per VM with PB manager descriptor fields sized to actual backed heap_blocks, and closes resources::Cache in both Registry::prune() and Gpu::vm_closed() to break the spare-epoch Arc<VmState> reference cycle.
  4. b0b5e93eb066 — drm/asahi: g16: run the M4 GPU on 26B123 firmware with ADT config and idle power-off
    • ABI & layout: V25G83/V26B123 InitData, devctl, queue-info, and TA/FS/compute work tables with compile-time layout_fits() bounds and collision checks; drops undocumented static GLOBALS/POWER_PERFORMANCE policy words.
    • ADT derivation: Derives 26B123 power sampling (+4/+8, +0x2b48/+0x2bbc/+0x2c10) and average-power IIR filter (+0x29e4..+0x29f8) from /arm-io/sgx gpu-pwr-sample-period-aic-clks, CNTFRQ_EL0, and /arm-io/pmgr/clpc cpu-avg-limiter-input-tc; derives the low-peak (PPM) limiter filter and PI gains (+0xa80..+0xae0) from cpu-lowpeak-limiter-{input-tc,ki,kp} and gpu-power-sample-period (Q16.16 unity 65536.0 integrator clamp at +0xaa8); reads coredump-copy-buffer from /arm-io/gfx-asc/iop-gfx-nub for InitData MAIN +0xfa8 and the 26B123 host crash-log buffer. Fails closed with EINVAL when any required property is missing or zero.
    • Boot & idle power-off: Admits 26B123 firmware-owned page tables and completes the PPL magic handshake (clearing handoff +8 before RUN and returning ETIMEDOUT on timeout); starts 26B123 without a PMP AGX vote and runs the standard boot NOP + separate IMPORT_GLOBALS and START doorbells (no boot idle workarounds or 1 ms sleep); publishes RETENTION at RUNTIME +0x2c8 (leaving MAIN +0xfa0 zero) and guards all SGX MMIO reads/writes (engine_state, pstate(), runtime set_generation()) inside Session::while_powered() under the PPL handoff lock.
    • Runtime: Non-short-circuiting fail-stop floor_power() across all three Globals ceiling selectors, full receive-ring drain per pass, 26B123 queue-info busy flag (+0x54), tear-free hi/lo/hi reads of compute::Layout::work_ticks (+0x7ec/+0x7f4), and single-check-per-pass polling with session.check() before publish_checked().
  5. ed41e08f7a02 — selftests: drm/asahi-m4: add 26B123 ABI offset-oracle and update host tests
    Adds check-abi-26b123.rs / test-abi-26b123.py (independent per-field offset oracle + policy-collision assertions), extends test-perf.py (ADT power sampling, low-peak limiter, coredump-copy-buffer) and test-vm.py (26B123 firmware page tables, +8 clear, ETIMEDOUT), and updates the remaining host suites.
  6. 2244998f3fc6 — drm/asahi: g16: Write all four 26B123 power-up words, so the GPU survives a deep wake (from drm/asahi: g16: Write all four 26B123 power-up words, so the GPU survives a deep wake #2742)
    Writes all four 26B123 POWER_PERFORMANCE power-up words (0x9c, 0xa0, 0xa4, 0xa8 = 1). A/B on J713: with only 0xa4 = 1, the first deep wake crashes the firmware right after the RTKit handshake; with all four set, 3/3 deep wakes complete with GPU alive (vkmark across sleep, glmark2, Vulkan smoke after each).

Tests

Compile & Host Tests

  • Host tests (tools/testing/selftests/drivers/gpu/asahi-m4/run-host-tests.py): 24/24 PASS at 2244998f3fc6.
  • Kernel compile check (CONFIG_DRM_ASAHI_G16=y, LLVM=1): drivers/soc/apple/apple-pmp.o and drivers/gpu/drm/asahi/aurora.ko built cleanly with 0 errors and 0 new warnings.

Hardware Tests

Machine Kit / Head Result
MacBook Air M4 (J713), Apple M4 G16G B0, firmware 26B123 2244998f3fc6 (#2742 A/B on J713) 3/3 deep wakes PASS with GPU alive (vkmark across sleep, glmark2, Vulkan smoke after each); without +0x9c/+0xa0/+0xa8 first deep wake crashes firmware.
Mac mini M4 (J773g), Apple M4 G16G B0, firmware 26B123 dcp45d (pr2676-drop-a1cb982f, exact G16 code of ed41e08f7a02 built against 7.3.0-ARCH-m4drv8 010c3eb7) PASS across all gates: booted cleanly to S10 (1578 MHz); 40/40 idle/wake PASS (0 Fail); 87/87 vk-mustpass-short PASS; vk-smoke 4/4 PASS; KWin on GPU (0.0% CPU); gpubench: compute.heavy alu 554.38 us (down from 595.17 us at S9), render.heavy fill 1080p 388.21 us, render.heavy geom 495.42 us, bw 2922.50 us, buf2buf 2939.50 us, fill 708.23 us; 0 GPU fault/recovery/stall/SError lines across full boot (3,803 journal lines), PMU panic counter 0x00 -> 0x00. Re-run at 2244998f3fc6 (with deep sleep) in progress (dcp63).

Remaining notes (why still draft)

  • Kept in draft pending J773g 2244998f3fc6 boot + deep-sleep row (dcp63, in progress), J713 sustained-load + power/die-temp + deep-sleep-under-load rows, 25G83 regression row, and one more T8132 board (J715 or J604).
  • The G16 cooling path uses the upstream CPU/ANE hotspot temperature input and J713 trip constants until apple_pmp_telemetry_get_gpu() (lab/j713-g16-agx-temp) lands on integration/aurora.
  • J773g on integration/aurora also requires the PMP side (#2533) for retained 27.2 PMP support; that is tracked separately.

Assisted-by: LLM (Gemini:4 Neon)

@DjDeveloperr
DjDeveloperr marked this pull request as draft November 21, 2026 06:25
@RyanTheTide

Copy link
Copy Markdown
Contributor

An early read of the power side, since it affects fanless machines:

  • 97e7743a ("Give the 26B123 power limiter its tuning") fixes the NaN estimate that took a data abort on the J773g, by writing the M4 Pro's values, including +0xaa8 = 65536.0 as the clamp's top. That value comes from a 14/16-core M4 Pro in a fan-cooled chassis. The table is per SoC, so it also applies to the fanless M4 MacBook Airs (J713/J715). If the clamp's top bounds the GPU's power budget, 65536.0 effectively removes the limit there, and only the PMP's die-temperature path would be left to stop a sustained load. Could the commit say what the clamp's units are, and whether a T8132 value should be read from the ADT (or captured on an M4 rather than an M4 Pro)? A sustained GPU load on a J713 with the die temperature logged would show whether the limiter or the thermal path is doing the work.
  • Keep the GPU powered while the 26B123 firmware idles (region C 0x9c0) trades the idle power-off for stability. Fine for bring-up, but worth a line in the description on what it costs at idle on a laptop, and a note that it should come back off once the wake-from-power-off crash is understood.

Assisted-by: LLM (Claude:Opus 5.5)

DjDeveloperr added a commit that referenced this pull request Nov 21, 2026
Hardware-row tree only. #2676's apple_pmp_t8132_retained_board() follows
apple_t8132_pmp_path() here, as it must once both land.

Signed-off-by: Diljit Singh <hey@djdev.me>
DjDeveloperr added a commit that referenced this pull request Nov 21, 2026
Hardware-row tree only. #2676's apple_pmp_t8132_retained_board() follows
apple_t8132_pmp_path() here, as it must once both land.

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

Copy link
Copy Markdown
Contributor

asahi_g16_perf_rows() in drivers/gpu/drm/asahi/g16/glue.c still returns of_machine_is_compatible("apple,j773g") ? 11 : 10, and include/linux/soc/apple/pmp-display.h picks the PMP display path with of_machine_is_compatible("apple,t8132"). The number of GPU performance states is in the GPU node's performance-state table and the display consumer is described by the PMP node and the DT's consumer nodes, so both can come from the device tree; with the board check the J713 and every other T8132 machine get 10 rows whether or not their table has 11. Same point as on #2239, which this branch carries. Until then this should stay a draft.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 6. Full review of all 39 commits at 923d1ec, paths under drivers/gpu/drm/asahi/g16/.

Unknown firmware builds fail closed: a handoff or loaded image that matches no known build is refused with EINVAL, and nothing falls through to 26B123. Selecting struct layouts and encoders by the firmware's own build identity is fine. The problems are the hardware-protecting values, the words replayed from macOS, and behaviour selected by board or firmware build.

Blockers

  1. Power limiter tuning is a constant table (d826a71, fw/initdata.rs:354-366, V26B123.power_policy). It applies to every T8132 board, including the fanless Airs. The commit says it holds the M4 Pro's values from linux#1954, but arm64: apple: t6041: support J616c (M4 Max) on macOS 27.2 (26B123) firmware #1954 is T6041 (M4 Max). The in-tree T6041 tables have other values at the claimed positions, and three of the words appear nowhere else in the tree, so where they came from can't be checked. The machine already describes its GPU power limits: the PMP clpc node carries pkg-power-limit-spl-gpu-*, pkg-power-split-gpu-fraction and pkg-avg-max-power. These differ between J713 and J604 and are absent on J773g. Map the limiter words to those properties, and refuse the 26B123 start when the machine provides none.
  2. The averaging filter time constant is hardcoded (cb62fb6, fw/initdata.rs:161 AVG_POWER_FILTER_TC_MS, used at :1024-1041). Every T8132 clpc node has *-avg-limiter-input-tc properties, so "the ADT has no property" doesn't hold. By the commit's own account, the word macOS keeps the time constant in is the one the encoder fills with 100 * ceiling (:1015); either the remap or the commit text is wrong. Power config +4/+8 (:1004-1005) are a constant that equals the ADT's gpu-pwr-sample-period-aic-clks; read them from power_sample_clks. The ADT's gpu-power-sample-period disagrees with the aic-clks property and is ignored without a reason.
  3. InitData words replayed from one board (22bda92, fw/initdata.rs:367-372; 4134471, region C at :344). The only justification given is that macOS has these values on the J773g, a fan-cooled machine, and they are applied to the Airs too. None of the words has a stated meaning. Find what each one does with an on/off A/B on hardware, drop the ones that aren't needed, and take any policy value from the ADT. Running the power_policy loop last only hides a collision with a remapped 25G83 word, because the policy word silently wins. A const assertion, like retention_fits, would make a collision fail the build.
  4. Values captured from macOS are in public text. d826a71, 22bda92, cb62fb6, 7dca270, 3c52087 and 4134471 quote, in commit messages and code comments, words read out of macOS's InitData, and the PR body lists macOS's limiter values next to the code's. Configuration that Apple's driver writes is tuning data even when we captured it ourselves. Keep it in private notes, strip the values from the commits, comments and body, and derive them from the ADT (points 1-3). 1474bfc also quotes raw header bytes of the firmware image in its comment and message; describe the check instead.
  5. New module parameter and a behaviour-changing debugfs file (ad24604 g16_pb_reuse, read on every render and retire; a7f8693 / 4bf66bd aurora-g16/tune, which sets compute units and depth, repoll interval, PB heap size and posted blocks at runtime). The feature has to work on the default command line, with no knob. Changing the heap or compute units live also leaves compute_exhausted() disagreeing with VMs that already grew.
  6. VM leak through a reference cycle (62f3b3b). Spare PB epochs hold their VM, the VM holds the cache, and the cache holds the spares. Only Registry::close() breaks the cycle. prune() (vm.rs:266) removes closed VMs without closing the cache, and vm_closed() skips registry.close() when the firmware state is gone (fail-stop or teardown). On those paths the VM, its TTBAT slot and its arenas are never freed.

Major

  1. DVFS row count is set per board (2cac938, c3d9029; glue.c:217-220, board/data.rs:25-43). apple,j773g gets 11 rows and every other board gets 10, which also sets the top state, the governor target and the pstate bound. The commit says an ADT-derived count gave the same result, so derive it from the ADT. S10 is enabled on the J773g with no thermal or power row, and the commit itself says S10 needs its own evidence.
  2. The "retained T8132 board" check is a board list or an OS version string (9b5a1c2, 3f2211f). apple_pmp_t8132_retained_board() is "an Air, or the OS firmware is 26.6.2". On 27.2 the J773g isn't covered, contrary to boot.rs:70 and the commit text, and the 25G83 admission (boot.rs:609-611) still depends on that string.
  3. Admission without the board check (67804cc). Any T8132 board whose handoff names 26B123 is now admitted (J715, J604, J623/J624), with no run on any of them.
  4. Workarounds for an unexplained crash after idle. These are: the single-doorbell boot pair with a 5 us busy-poll for up to 20 ms (c293b12, boot.rs:893-930), dropping the boot NOP (731f85a), and a 1 ms sleep "to keep macOS's order" (08ff1f6, boot.rs:359). 7dca270 (power-up target state) and 3c52087 (retention) look like the real fix. Re-test the plain sequence with those two in place, and drop the workarounds if it passes. The c293b12 comment says the firmware idles after about 0.5 ms, which contradicts the 40 ms idle delay.
  5. The PPL answer wait accepts a stale value (595cf1c, uat.rs:346-372). A timeout only warns. Cold admission accepts the word already holding the 27.2 value, and nothing clears it before RUN, so a leftover value satisfies the wait at once.
  6. GPU register access while the GPU may be off (632fa50's own rule). pstate() reads sgx+0xe01000 on every poll pass, idle passes included. set_generation() writes and reads back sgx+0xd60000 on every device-control submit. Neither goes through the powered-GPU guard.
  7. The fail-stop floor can fail silently (b21eba6, recovery.rs:265-293). .all(|..| w32().is_ok()) short-circuits: if a middle write fails, the earlier selectors are already lowered while the log says "unchanged" and power.effective isn't updated. Write all three and report each one. After fail-stop, service_power returns early (power.rs:268), so on a fanless machine this floor is the only host-side thermal action left. No row shows that it lowers the die temperature.
  8. The PB heap size doesn't match the image (4bf66bd). The heap is 64 MiB, but pb_manager_image() (fw/buffer.rs:101-110) still describes the full 256 MiB window to the firmware. Pass heap_blocks into the image, or show that those fields are never walked past the posted count. The 64 MiB figure rests on one 25G83 observation.
  9. Sizes taken from the ADT elsewhere are constants here. LOG_BUFFER_SIZE/COREDUMP_COPY_SIZE (hw.rs:315, fw/initdata.rs:204) are constants, though the comment names coredump-copy-buffer, which carries the size. The 26B123 power-config offsets are inferred from the T6041 build (fw/initdata.rs:293,316-324). Only the temperature pointer was checked against a T8132 capture, and the selftest oracle (2297ef2) is built from the same inference, so it can't catch a wrong offset.
  10. Provenance of the ABI comments (01bcfd6). The comments describe firmware internals a host trace can't show: opcode renumbering, a per-opcode tally byte, where the timestamp op stores, and TEXT segment ranges. Say how each was established, or drop the details that came from reading the image.

Nits: compute_ticks (d5cf17e) picks the tick location from the Start enum rather than an ABI field, and the 64-bit tick reads can tear. publish_checked (923d1ec) skips the ASC RUN recheck after retirement. 1e22d27 now skips a register-map record without a slot instead of refusing it. Stale docs at slots.rs:5 and hw.rs:685 (each compute unit now has its own UMA slot, engine.rs:1365). Three carried commits from Sean and ad24604 have Assisted-by: LLM trailers; fix those in their source PRs. Every commit has a human Signed-off-by.

Rows. No machine has run this head yet. To merge:

  • a compile check;
  • a 26B123 boot at this head on J713 and J773g, with idle power-down, the limiter and the filter all active;
  • a 25G83 regression boot on both, because the 25G83 path was rerouted;
  • one more T8132 board (J715 or J604), since admission now covers them;
  • a sustained GPU load on J713 and J715 with package power and die temperature logged, showing which path limits;
  • an idle/wake soak with idle power measured;
  • a forced fail-stop under load with die temperature logged for 60 s.

Pass for every run: 0 GPU faults or recoveries, 0 AVC, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

Rename the retained-session predicate to apple_pmp_t8132_retained_board()
and detect the retained T8132 PMP power-vote bridge from the device tree's
own `pmp` node (`apple,t8132-pmp-v2`, available, `apple,tunable-soc-device`
present) rather than gating on a board list, root SoC compatible, or OS
firmware version string. Keep apple_pmp_j713_board() as an inline alias
for existing callers.

Signed-off-by: Diljit Singh <hey@djdev.me>
… and run to top p-state

Admit the J773g 25G83 firmware images, including the boot-filled B000
ranges zeroed before digest verification, and cover them in fwid.rs unit
tests.

Derive the firmware DVFS table row count (10-row 6-pair vs 11-row
5-pair+top) directly from the preserved ADT performance-state table
rather than gating on a board compatible, and let the utilization
governor, cooling ceiling, and reported p-state bound run up to the
board table's top state (S10 on 11-row tables).

Signed-off-by: Diljit Singh <hey@djdev.me>
… PB heap, and close VM caches

Carry the G16 parameter-buffer and compute-pipelining updates needed
under the 26B123 runtime:
- unconditionally reuse a pass slot's retired PB epoch for the same VM
  and binding (no runtime toggle or mutable debugfs);
- keep compute commands in flight on dedicated per-unit UMA slots;
- share one 64 MiB PB heap per VM across render allocators, sizing the
  PB manager descriptor fields to the actual backed heap_blocks rather
  than hardcoding 256 MiB, and recycle never-exposed spare epochs;
- let closed VMs release arenas while slot leases retain only their own
  backing, and drain spare epochs in both Registry::prune() and
  Gpu::vm_closed() to break the Cache -> Arc<VmState> cycle;
- avoid redundant submit-path publication while a render is active.

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

Support the 26B123 G16 GPU firmware (also shipped in 26B131) while
leaving 25G83 byte-for-byte unchanged. Firmware selection keys strictly
on the boot loader's handoff fields and loaded TEXT digest, failing
closed on unknown builds.

Firmware layout, ABI, and ADT derivation:
- Add V25G83/V26B123 layout tables for InitData, device-control opcodes,
  queue info, and TA/FS/compute work records, with compile-time
  layout_fits() bounds and collision checks.
- Set POWER_PERFORMANCE +0xa4 = 1 (required power-up state selector)
  with no undocumented static InitData policy words.
- Derive 26B123 power sampling (+4/+8, +0x2b48/+0x2bbc/+0x2c10) and the
  average-power IIR filter (+0x29e4..+0x29f8) from /arm-io/sgx
  gpu-pwr-sample-period-aic-clks, CNTFRQ_EL0, and /arm-io/pmgr/clpc
  cpu-avg-limiter-input-tc; derive the low-peak (PPM) limiter filter and
  PI gains (+0xa80..+0xae0) from cpu-lowpeak-limiter-{input-tc,ki,kp}
  and gpu-power-sample-period (65536.0 PI integrator clamp at +0xaa8).
  Fail closed with EINVAL when any required ADT property is missing or 0.
- Read coredump-copy-buffer from /arm-io/gfx-asc/iop-gfx-nub in the
  preserved ADT to size InitData MAIN +0xfa8 and the 26B123 host
  crash-log buffer (failing closed when absent or invalid).

Start, idle power-off, and runtime:
- Admit 26B123 firmware-owned page tables and perform the PPL magic
  handshake, clearing handoff +8 before RUN and returning ETIMEDOUT if
  the firmware answer does not arrive.
- Start 26B123 without a PMP AGX vote (enabling GFXCAXI2AF and leaving
  loaded DATA to the firmware), hand over the host crash-log buffer
  before AP power-on, and run the standard boot NOP + IMPORT_GLOBALS +
  START sequence while accepting a pending InitData scheduler request.
- Publish the RETENTION table at RUNTIME +0x2c8 (leaving MAIN +0xfa0
  zero) so 26B123 can power the GPU down when idle, and guard all SGX
  MMIO reads/writes (engine busy/fault state, pstate(), and runtime
  set_generation()) inside Session::while_powered() under the PPL lock.
- Attempt all three Globals ceiling selectors without short-circuiting
  in floor_power() at fail-stop, drain all receive rings per pass, read
  the 26B123 queue-info busy flag at +0x54, read compute work ticks from
  compute::Layout::work_ticks with a tear-free hi/lo/hi loop, and check
  the session once per poll pass plus before publish_checked().

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

Add check-abi-26b123.rs and test-abi-26b123.py to verify 26B123 layout
selection, compile-time policy collision guards, and exact byte-for-byte
InitData/work/queue encoding parity against independent per-field offset
tables.

Extend test-perf.py for ADT power-sampling, low-peak limiter, and
coredump-copy-buffer parsing; extend test-vm.py for 26B123 firmware page
tables, +8 clear before RUN, and ETIMEDOUT on missing magic answer; and
update the remaining host suites for the 26B123 ABI and compute work
tick layout.

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

Copy link
Copy Markdown
Contributor Author

Rebased onto integration/aurora (a84637dca209), squashed/reworded into a clean-room 5-commit series (ed41e08f7a02, draft), and addressed all 6 blockers, Majors 7–16, and nits:

Blockers (1–6)

  1. ADT average-power filter TC (Blocker 1): Removed hardcoded AVG_POWER_FILTER_TC_MS; now parsed from /arm-io/pmgr/clpc cpu-avg-limiter-input-tc and /arm-io/sgx gpu-pwr-sample-period-aic-clks (+4/+8 written from power_sample_clks), failing closed with EINVAL when missing or zero.
  2. ADT low-peak (PPM) power limiter (Blocker 2): Removed all hardcoded +0xa80..+0xae0 limiter words; derived from /arm-io/pmgr/clpc cpu-lowpeak-limiter-{input-tc,ki,kp}, /arm-io/sgx gpu-power-sample-period, and CNTFRQ_EL0 (standard M1–M5 65536.0 clamp at +0xaa8), failing closed with EINVAL when missing or zero.
  3. Undocumented InitData words & policy collision checks (Blocker 3): Hardware drop-test kit (dcp45d / pr2676-drop-a1cb982f) passed every gate with all 12 undocumented words dropped (GLOBALS 0x38/0x7f0/0x9dc/0xe0c, POWER_PERFORMANCE 0x44/0x84/0x9c/0xa0/0xa8/0x2b74/0x2f34/0x6ac8). Dropped all 12 from V26B123 (keeping only +0xa4 = 1) and added compile-time layout_fits() bounds and collision checks across all policy, sampling, limiter, selector, and remapped offsets.
  4. Clean-room scrub (Blocker 4): Scrubbed code comments, all 5 commit messages (Signed-off-by only; no Assisted-by/Co-Authored-By trailers), and the PR body of macOS-captured values, hypervisor-capture references, raw firmware header bytes, and superseded M4 Pro/macOS tables.
  5. Remove g16_pb_reuse & aurora-g16/tune (Blocker 5): Removed the g16_pb_reuse module parameter and the mutable aurora-g16/tune debugfs file (keeping aurora-g16/stats read-only and PB epoch reuse unconditionally enabled).
  6. VM resource cache reference cycle (Blocker 6): Registry::prune() now calls cache.close() before dropping removed entries, and Gpu stores Arc<vm::Registry> directly so Gpu::vm_closed() always closes the cache even during fail-stop/teardown (covered by a new regression test in test-vm-registry.py).

Majors (7–16) & Nits

  • Major 7 & 8 (board/SoC/OS-fw checks): Removed asahi_g16_perf_rows() (DVFS row count derived directly from ADT) and replaced the board/SoC/26.6.2 check in include/linux/soc/apple/pmp-display.h with a DT check on the pmp node (apple,t8132-pmp-v2, available, apple,tunable-soc-device).
  • Major 10 (boot idle workarounds): Verified on hardware in dcp45d (pr2676-drop-a1cb982f) that none of the boot workarounds are needed; dropped the 1 ms fsleep in publish_log_buffer(), restored the standard boot NOP and separate IMPORT_GLOBALS / START doorbells, and deleted dead await_boot_control_prompt() / devctl_submit_batch().
  • Major 11 (PPL magic wait): Window::bootstrap() now clears handoff +8 before RUN and returns ETIMEDOUT if the firmware answer never arrives (tested in test-vm.py).
  • Major 12 (unguarded SGX MMIO): Routed Session::check()'s pstate() read and runtime set_generation() writes through Session::while_powered() under the PPL handoff lock.
  • Major 13 (floor_power() short-circuit): Removed .all() short-circuiting so fail-stop attempts all three Globals ceiling selectors, logs individual write failures, issues wmb() if any write succeeded, and reports full/partial/unchanged status.
  • Major 14 (PB manager sizing): buffer::pb_manager_image() now sizes +0x34/+0x3c/+0x54/+0x7c/+0x80 to the actual backed heap_blocks (rejecting 0 in PbEpoch::prepare()).
  • Major 15 (coredump-copy-buffer from ADT): Parsed /arm-io/gfx-asc/iop-gfx-nub coredump-copy-buffer from the preserved ADT (rejecting 0, non-4KiB-aligned, or > 1 MiB) for InitData MAIN +0xfa8 and the host crash-log buffer, removing hardcoded size constants.
  • Major 16 & Nits: Stripped firmware-internal speculation from fw/{channels,work,graph}.rs comments, fixed stale UMA-slot docs in slots.rs/hw.rs, moved 26B123 compute work ticks onto compute::Layout::work_ticks with a tear-free hi/lo/hi read loop, and added session.check()? at the start of publish_checked().

Verification

  • Host tests (run-host-tests.py): 24/24 PASS at ed41e08f7a02.
  • Compile check (CONFIG_DRM_ASAHI_G16=y, LLVM=1): apple-pmp.o and aurora.ko build with 0 errors and 0 new warnings; checkpatch.pl reports 0 errors (0 warnings on C/H changes).
  • J773g (M4 Mac mini, 26B123) hardware test (dcp45d, pr2676-drop-a1cb982f, exact G16 code of ed41e08f7a02): booted cleanly to S10 (1578 MHz); 40/40 idle/wake PASS; 87/87 vk-mustpass-short PASS; vk-smoke 4/4 PASS; KWin on GPU (0.0% CPU); gpubench compute.heavy alu 554.38 us (down from 595.17 us at S9), render.heavy fill 1080p 388.21 us, render.heavy geom 495.42 us; 0 GPU fault/recovery/stall/SError lines across full boot (3,803 lines), PMU panic counter 0x00 -> 0x00.

Keeping in draft pending CI on ed41e08f7a02 and J713/J715/J604 rows.

Assisted-by: LLM (Gemini:4 Neon)

…ives a deep wake

The 26B123 POWER_PERFORMANCE layout inserts four u32s at +0x9c. G16
writes only +0xa4, the powered-up state selector. That is enough for a
cold boot, but not for the firmware's warm restart after a deep sleep:
on the J713 (M4 Air) the first deep wake ends with "GPU firmware back
in 691 us" and, 0.3 ms later, "RTKit: co-processor has crashed" in the
firmware's power-up path, before any client has submitted work. The GPU
is gone until reboot.

macOS 27.2 sets all four words to 1, and so did this driver before the
26B123 layout was reworked. Write +0x9c, +0xa0 and +0xa8 again, next to
+0xa4. The words belong to the 26B123 layout, so they are selected by
the firmware ABI, as before; 25G83 is unchanged.

On the J713 (macOS 27.2 firmware, default kernel command line) with
the external monitor and the USB4 peer attached: 3 of 3 deep sleeps
wake with the GPU alive, with vkmark running across the first sleep,
then dEQP-VK smoke and glmark2 after the wakes. Without the change the
same kernel crashed on the first wake. The host tests and the 26B123
offset oracle are updated for the three words.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review at 2244998 (series rewritten since our last review at 923d1ec). Most of the earlier points are fixed. Remaining and new:

Still open

  • Point 1/2, limiter source. The limiter is now computed from the ADT and fails closed, which is the right shape (fw/initdata.rs:1135-1157). But the gains and the filter time constant come from the CPU controller's properties (cpu-lowpeak-limiter-{input-tc,ki,kp}, cpu-avg-limiter-input-tc; g16/adt/perf.rs:33-47). The same T8132 clpc node also carries a package set (pkg-lowpeak-limiter-*, pkg-avg-limiter-input-tc) with very different values (on J713, input-tc 60 vs 16 ms, avg tc 900 vs 248 ms). The GPU budget properties (pkg-power-limit-spl-gpu-*, pkg-power-split-gpu-fraction) are still unused, so no limit value from the machine reaches the firmware. Please say why the CPU limiter's set is the one the GPU firmware's limiter wants, and where its target comes from. A sustained GPU load on the J713 at this head with package power and die temperature logged would show whether this limiter or the thermal path holds the fanless machine. The +0xaa8 = 65536.0 clamp is fine if it is the Q16.16 unity (fw/initdata.rs:185), but "shared across M1-M5" needs a source or should go.
  • Point 9: admission still covers every T8132 board on 26B123, with no J715 or J604 run.
  • Point 13: the fail-stop floor is fixed in code (recovery.rs:265-305). No run yet shows it lowering the die temperature under load.

New in 2244998

  • The A/B for +0x9c/+0xa0/+0xa8 (crash on the first deep wake without them, 3/3 wakes with them) is the kind of evidence point 3 asked for. It also shows that the drop test at ed41e08, which covered cold boot and idle/wake but not deep sleep, can't prove a word is unneeded. The other nine dropped words (GLOBALS 0x38/0x7f0/0x9dc/0xe0c, POWER_PERFORMANCE 0x44/0x84/0x2b74/0x2f34/0x6ac8) only have that test behind them. Several deep-sleep cycles on the J713 at this head, under load, would cover them.
  • fw/initdata.rs:367 and the commit message justify the words by what macOS writes. As with point 4, state the A/B result as the reason and leave out the captured values.
  • g16/params.rs:31-49 replaces the old knobs with fixed depths (64 MiB heap, 2048 posted blocks, 6 compute units, 16 flights) and gives no derivation. 6usize.clamp(2, ...) clamps a literal. A line on where each number comes from would help.
  • The PR body still describes the 5-commit series at ed41e08 with "only +0xa4 = 1", and the J713 row in the commit message doesn't name the exact head or kit.

Rows at 2244998: J713 deep-sleep cycles plus a sustained load with package power and die temperature, J773g boot and idle/wake on this head, a 25G83 regression boot on both, one more T8132 board (J715 or J604), and a forced fail-stop under load with die temperature logged.

Assisted-by: LLM (Claude:Opus 5.5)

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